-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathno_text.html
132 lines (119 loc) · 4.4 KB
/
no_text.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
<!DOCTYPE html>
<html>
<!--
Copyright 2013 Matthew Wigginton Conway
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Schelling's Spatial Segregation Model</title>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="html5slider.js"></script>
<script src="segregation.js"></script>
<link rel="stylesheet" href="segregation.css" />
</head>
<body>
<div id="content">
<div id="controls">
<form id="input" onsubmit="run(); return false;">
<table>
<tr>
<td>
<label for="tolerance">Threshold</label>
</td>
<td >
<input type="range" id="tolerance" oninput="toleranceReadout.value = '' + Math.round(this.value * 100) + '%'"
min="0" max="1" step="0.01" value="0.3" />
</td>
<td>
<output for="tolerance" class="inputReadout" name="toleranceReadout" />
</td>
</tr>
<tr>
<td>
<label for="fill">Fill factor</label>
</td>
<td >
<input type="range" id="fill" oninput="fillReadout.value = '' + Math.round(this.value * 100) + '%'"
min="0" max="1" step="0.01" value="0.95" />
</td>
<td>
<output for="fill" class="inputReadout" name="fillReadout" />
</td>
</tr>
<tr>
<td>
<label for="size">Grid size</label>
</td>
<td >
<input type="range" id="size" oninput="sizeReadout.value = '' + this.value + 'x' + this.value"
min="2" max="40" step="1" value="30" />
</td>
<td>
<output for="size" class="inputReadout" name="sizeReadout" />
</td>
</tr>
<tr>
<td>
<label for="balance">Balance</label>
</td>
<td>
<input type="range" id="balance" oninput="balanceReadout.value = '' + Math.round(this.value * 100) + '%'"
min="0" max="1" step="0.01" value="0.5" />
</td>
<td>
<output for="balance" class="inputReadout" name="balanceReadout" />
</td>
</tr>
<tr>
<td colspan="3">
<input type="submit" value="Run Model"</a>
</td>
</tr>
</table>
</form>
</div>
<div id="board" class="clearme">
<!-- board spaces will be populated here -->
</div>
<div id="statistics">
<div>
<span id="percentAlikeChart" class="clearme"></span>
<span id="percentAlikeReadout" class="readout clearme"></span>
</div>
<div>
<span id="percentUnhappyChart" class="clearme"></span>
<span id="percentUnhappyReadout" class="readout clearme"></span>
</div>
</div>
<div class="clear"></div>
</div>
<script type="text/javascript">
d3.selectAll('input')
.each(function () {
var evt = new Event('input');
this.dispatchEvent(evt);
});
function run() {
if (typeof(s) != 'undefined')
s.stop();
d3.selectAll('.clearme').html('');
var tol = d3.select('#tolerance')[0][0].value;
var size = d3.select('#size')[0][0].value;
var fill = d3.select('#fill')[0][0].value;
var totalAgents = fill * (Math.pow(size, 2) - 1); // there needs always to be a single vacant square
var n2 = d3.select('#balance')[0][0].value * totalAgents;
var n1 = totalAgents - n2;
s = new org.indicatrix.Segregation(size, 300, tol, n1, n2);
s.start();
}
</script>
</body>
</html>