-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.html
More file actions
109 lines (85 loc) · 3.26 KB
/
test.html
File metadata and controls
109 lines (85 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="js/xsltTransform.js"></script>
<script type="text/javascript" src="lib/jLouvain.js"></script>
</head>
<body class="sunset">
<img id="logo" src="img/skylikes-logos.svg"/>
<h1>Skylikes</h1>
<p id="status">hello</p>
<script src="js/goodreadsDataFetches.js"></script>
<script src="js/goodreadsDataTransformations.js"></script>
<script>
var svgWidth = 600
var svgHeight = 50
var svgContainer = d3.select("body") //create container
.append("svg")
.attr("width", svgWidth)
.attr("height",svgHeight)
svgContainer.append("rect")
.attr("transform", "translate(" + svgWidth/2 + "," + svgHeight/2 + ")")
.attr("x", -svgWidth/2)
.attr("y", -svgHeight/2)
.attr("width",svgWidth)
.attr("height", svgHeight)
.style("fill","white")
.style("stroke-width",0.5)
.style("stroke","#555555")
var progress = svgContainer.append("rect")
.attr("transform", "translate(" + svgWidth/2 + "," + svgHeight/2 + ")")
.attr("x", -svgWidth/2)
.attr("y", -svgHeight/2)
.attr("width",0)
.attr("height", svgHeight)
.style("fill","blue")
//.style("stroke-width",0.5)
//.style("stroke","#555555")
goodreadsDataFetches.statusUpdate = function(percentage,state){
console.log("percentage " + percentage +" state "+ state)
var newwidht = (percentage/100*svgWidth);
progress.attr("width", newwidht);
document.getElementById("status").innerHTML = "state: "+ state + " percentage: "+percentage +"%"
}
goodreadsDataFetches.finished = function(data){
console.log("done")
var jsonString = parseXMLString(data,"./xslt/AllDataTrafo.xslt")
var jsonData = jQuery.parseJSON( jsonString);
console.log(jsonData)
document.getElementById("status").innerHTML = "done"
goodreadsDataTransformations.setData(jsonData)
var allFriends = goodreadsDataTransformations.allFriends()
console.log("allfriends")
console.log(allFriends)
var myBooks = goodreadsDataTransformations.myBooks()
myBooks.sort(function(a,b) {
return b.friendsWhoAlsoRead.length - a.friendsWhoAlsoRead.length
} );
console.log("myBooksSorted")
console.log(myBooks)
/*
allFriends.forEach(function(d,i){
console.log("id "+ i +" commonwithme " + d.commonBooks + " community "+d.community+ " totalbooks "+d.totalBooks )
})*/
}
var isUsingTestingDataset = getParameterByName("testingData") == "1"
if(isUsingTestingDataset){
console.log("startWithTestingData")
goodreadsDataFetches.startWithTestingData()
}else{
console.log("start realData!")
goodreadsDataFetches.start()
}
//http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
</script>
</body>
</html>