-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex_v3.html
208 lines (199 loc) · 4.68 KB
/
index_v3.html
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="../../dev/lexiconRainbow.d3v3.dev.js"></script>
<script src="./loadData.js"></script>
<style type ="text/css">
html {
background-color:White;
}
html * {
box-sizing:border-box;
}
body{
margin: 0px;
background-color:White;
}
body:after{
content:"";
display:block;
clear:both;
}
.row {
float:left;
width:100%;
font-size:16px;
position:relative;
overflow:hidden;
background-color:transparent;
}
.row:after{
content:"";
display:block;
clear:both;
}
.row:first-child, .row:last-of-type {
min-height:300px;
text-align:center;
font-size:30px;
font-family:advent-pro,Sans Serif,Arial;
}
.row:first-child span {
display:inline-block;
width:90%;
position:absolute;
left:0;
right:0;
bottom:20px;
margin-left:auto;
margin-right:auto;
}
.row:first-child span:first-child {
bottom:100px;
white-space:pre;
}
.row:last-of-type {
text-align: justify;
padding-left:30%;
padding-right:30%;
}
.row:last-of-type span:first-of-type {
display:inline-block;
width:100%;
text-align:center;
position:relative;
left:0;
right:0;
top:20px;
margin-left:auto;
margin-right:auto;
}
.row:last-of-type:after {
display:inline-block;
width:100%;
content:"";
clear:both;
}
#containerDiv {
width:70%;
margin:auto;
position:relative;
}
button {
border: 1px solid DarkSlateGray;
border-radius: 5px;
padding: 20px;
font-family: Arial;
font-size: 1.5rem;
max-width:20%;
color: DarkSlateGray;
background-color:transparent;
outline:none;
overflow:hidden;
box-shadow:0px 0px 0px transparent;
transition:box-shadow 0.25s ease;
}
button:hover {
box-shadow:3px 3px 9px Black;
}
@media screen and (max-width:800px) {
.row:last-of-type {
padding-left:10%;
padding-right:10%;
}
button {
max-width:40%;
}
}
</style>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="./IE.css"></link>
<![endif]-->
</head>
<body>
<div class="row">
<span id="moverSpan"> </span>
<span id="topSpan"></span>
</div>
<div class="row">
<div id="containerDiv">
</div>
</div>
<div class="row">
<span id="botSpan"></span>
</div>
<script type="text/javascript">
!function(){
////////////////////////////////////////////////////////////////////
/////////////////CREATE INSTANCE OF LEXICON RAINBOW/////////////////
////////////////////////////////////////////////////////////////////
var instance = new LexiconRainbow;
instance
.container("#containerDiv")
.dispersion(0)
.forceStyle()
.w(600).h(200)
.sW("100%").sH("auto")
.position("relative")
.sTop("0px")
.sLeft("0px")
.sMargin("0px auto 0px auto")
.handleEvent(handleEvent)
.lexID("lexiconRainbow")
.input(sample)
.GUI(false,{x:-20,w:40})
.append(true)
.render();
////////////////////////////////////////////////////////////////////
//////////////////////////MAKE SOME BUTTONS/////////////////////////
////////////////////////////////////////////////////////////////////
!function(data,container){
container.appendChild(document.createElement("br"));
Array.apply(null,Array(2)).forEach(function(d,i){
var btn = document.createElement("button");
btn.textContent = data[i][0];
btn.__ordinal = data[i][1];
btn.__linear = data[i][2];
container.appendChild(btn);
container.appendChild(document.createTextNode(" "));
})
container.addEventListener("click",function(e){
if(e.target.tagName !== "BUTTON"){return}
instance.ordinalG.update(e.target.__ordinal);
instance.linearG.update(e.target.__linear);
},false)
}([["Trump",2,8],["Clinton",3,14]],document.body.querySelector("div.row:last-of-type"))
////////////////////////////////////////////////////////////////////
/////////////////////////ATTACH THE HANDLER/////////////////////////
////////////////////////////////////////////////////////////////////
var topspan = document.getElementById("topSpan");
var botspan = document.getElementById("botSpan");
var moverspan = document.getElementById("moverSpan");
function handleEvent (data,type,eventType) {
switch (type) {
case "onload":
topSpan.textContent = data.ordinal.Info;
botSpan.textContent = data.linear.Info;
return;
case "onhighlight":
if(eventType==="mouseover") {
var dd = typeof data.item === "object" ? "Value: "+Math.abs(data.item[1]-data.item[0]) : "Value: "+dd;
var name = typeof data.name !== undefined ? "Name: "+data.name+", " : "";
moverspan.textContent = name+dd;
} else {
moverspan.textContent = " ";
}
return;
case "onrenderLinear":
botSpan.textContent = data.Info;
return;
case "onrenderOrdinal":
topSpan.textContent = data.Info;
return;
}
}
}()
</script>
</body>
</html>