/
uitest_pretty.html
101 lines (77 loc) · 4.28 KB
/
uitest_pretty.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
<!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()" style="/*color: #FFFFFF; background-image: url(http://www.thedrum.com/uploads/drum_basic_article/117188/main_images/Government.jpg); background-repeat: -repeat;background-position: center; background-size: 100% 100%;*/">
<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()
{
document.getElementById("debt").value = 732
document.getElementById("savings").value = 0
document.getElementById("income").value = 648
document.getElementById("outgoing").value = 0
var income = parseFloat(document.getElementById("income").value)
goverment = loadJSON(income, data_load())
var br, input, label
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)
console.log("Savings: " + goverment.savings)
document.getElementById("debt").value = goverment.debt
document.getElementById("outgoing").value = goverment.outgoing
document.getElementById("savings").value = goverment.savings
}
function on_reset_button_click()
{
goverment.debt = 732
goverment.savings = 0
document.getElementById("debt").value = 732
document.getElementById("savings").value = 0
}
</script>
<div id="controls" style="position: fixed; right: 15%;">
All values are measured in billions of pounds.<br></br>
<input id="income" value="648" oninput="goverment.income = parseFloat(this.value)"></input>Income<br></br>
<input id="savings" readonly="true" value="0"></input>Savings<br></br>
<input id="debt" readonly="true" value="732"></input>Debt<br></br>
<input id="outgoing" value="0" readonly="true" value=""></input>Outgoing<br></br>
<button id="step" style="width: 100%;" onclick="on_step_button_click()">step</button>
<button id="reset" style="width: 100%;" onclick="on_reset_button_click()">reset</button>
</div>
</body>
</html>