-
Notifications
You must be signed in to change notification settings - Fork 0
/
substage.php
executable file
·152 lines (136 loc) · 3.65 KB
/
substage.php
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
<?php
/*
All substage's info
3 Inputs: level (string), sublevel (string), index (integer)
*/
if(!isset($_GET['index'])) die('error: index not defined');
if(!isset($_GET['level'])) die('error: level not defined');
if(!isset($_GET['sublevel'])) die('error: sublevel not defined');
$level = $_GET['level'];
$sublevel = $_GET['sublevel'];
$index = $_GET['index'];
?>
<!doctype html><html><head>
<?php include'imports.php'?>
<script>
<?php
//set the substage pointer and parent stage
echo "
var substage = Substages['$level']['$sublevel'][$index];
var sublevel = Global['$level']['$sublevel'];
";
?>
/** Update all */
function init() {
//copy all functions from parent sublevel into the substage
for(var field in sublevel) {
if(typeof(sublevel[field])!="function") continue;
substage[field]=sublevel[field];
}
//redisplay table
updateSubstage();
Caption.listeners();
updateResult();
}
//redisplay table
function updateSubstage() {
var t=document.querySelector('table#substage');
for(var field in substage) {
if(typeof(substage[field])=="string") continue;
//new row
var newRow=t.insertRow(-1);
//code
newRow.insertCell(-1).innerHTML="<a href='variable.php?id="+field+"'>"+field+"</a>";
//name
newRow.insertCell(-1).innerHTML=translate(field+"_descr");
//type
newRow.insertCell(-1).innerHTML=(function(){
if(typeof substage[field]=="function")
{
return "Output";
}
else{
return "Input";
}
})();
//value
newRow.insertCell(-1).innerHTML=(function() {
var value;
if(typeof(substage[field])=="number")
{
value=substage[field]/Units.multiplier(field);
if(Info[field].magnitude=="Option")
{
return Tables.find(field,value);
}
}
else if(typeof(substage[field])=="function")
{
value=substage[field]();
}
return format(value);
})();
//units
newRow.insertCell(-1).innerHTML=(function()
{
return Info[field] ? Info[field].unit : "<span style=color:#ccc>no unit</span>";
})();
}
}
</script>
<style>
h1{
text-align: left;
line-height: 2.1em;
border-bottom: 1px solid #ccc;
background: white;
}
#substage tr td:first-child {font-family:monospace;font-size:11px}
table tr:nth-child(odd){
background:#eee;
}
</style>
</head><body onload=init()><center>
<!--sidebar--><?php include'sidebar.php'?>
<!--navbar--><?php include'navbar.php'?>
<!--linear--><?php include'linear.php'?>
<!--caption--><?php include'caption.php'?>
<!--TITLE-->
<h1>
<a href=sources.php><script>document.write(Global.General.Name)</script></a>
›
<?php echo "<a href='edit.php?level=$level'>$level</a>"?>
›
<?php echo "<a href='edit.php?level=$level&sublevel=$sublevel'>$sublevel</a>"?>
›
<span style=color:black;font-size:26px>
Substage <?php echo (1+$index)?>
— <script>document.write(substage.name)</script>
</span>
</h1>
</center>
<!--END TITLE-->
<!--go back to overview-->
<div style=text-align:center;padding:0.5em>
<a href=substages.php>←
<?php write('#Substages overview')?>
</a>
</div>
<!--subtitle-->
<h3 style=text-align:center;color:black>
<?php write('#Substage')?>
"<script>document.write(substage.name)</script>"
<?php write('#summary')?>
</h3>
<!--root container-->
<div>
<!--substage table-->
<table id=substage style=margin:auto;margin-top:0.5em> <tr>
<th><?php write('#Variable')?>
<th><?php write('#Name')?>
<th><?php write('#Type')?>
<th><?php write('#Current value')?>
<th><?php write('#Unit')?>
</table>
</div>
<!--CURRENT JSON--><?php include'currentJSON.php'?>