-
Notifications
You must be signed in to change notification settings - Fork 1
/
uitest_chaotic.html
84 lines (63 loc) · 3.25 KB
/
uitest_chaotic.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
<!DOCTYPE html>
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="main.js" type="text/javascript"></script>
<script src="glue.js" type="text/javascript"></script>
<body onload="onload()">
<script type="text/javascript">
var goverment
var inputs={}
function findDepartment(goverment, name)
{
for (i in goverment.departments)
{
if (goverment.departments[i].name == name)
{
return goverment.departments[i]
}
}
}
function onload()
{
var income = parseFloat(document.getElementById("income").value)
goverment = loadJSON(income, data_load())
var br, input, label
var div = document.getElementById("d")
for (i in departments)
{
input=document.createElement("input")
input.value = departments[i].amount
input.id = departments[i].name
input.addEventListener("input", function()
{
findDepartment(goverment, this.id).amount = parseFloat(this.value)
console.log("Set "+this.id+" to "+this.value+" billion pounds.")
})
document.body.appendChild(input)
label = document.createTextNode(departments[i].name)
document.body.appendChild(label)
br=document.createElement("br")
document.body.appendChild(br)
inputs[departments[i].name] = input
}
}
function on_step_button_click()
{
console.log("Stepping")
goverment.step()
console.log("Income: " + goverment.income)
console.log("Debt: " + goverment.debt)
console.log("Outgoing: " + goverment.outgoing)
document.getElementById("debt").value = goverment.debt
document.getElementById("outgoing").value = goverment.outgoing
}
</script>
<div id="controls" style="position: fixed; right: 15%;">
All values are measured in billions of pounds.<br></br>
<input id="income" value="100" oninput="goverment.income = parseFloat(this.value)"></input>Income<br></br>
<input id="debt" readonly="true" value=""></input>Debt<br></br>
<input id="outgoing" readonly="true" value=""></input>Outgoing<br></br>
<button id="step" style="width: 100%;" onclick="on_step_button_click()">step</button>
</div>
</body>
</html>