-
Notifications
You must be signed in to change notification settings - Fork 0
/
html.go
327 lines (240 loc) · 10.2 KB
/
html.go
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
package engine
const templText = `
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> mumax3 </title>
` + CSS + `
<script> ; </script>
{{.JS}}
<script>
// Toggle visibility of element with id
function toggle(id) {
var el = document.getElementById(id);
if(el.style.display != 'none'){
el.style.display = 'none';
} else {
el.style.display = 'block';
}
}
</script>
<style type="text/css">
* {box-sizing: border-box;}
.img-loupe-div { position: relative; }
.img-loupe {
position: absolute;
border: 1px solid #000;
border-radius: 2% 50% 50%;
box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.4) ;
cursor: crosshair;
width: 150px;
height: 150px;
image-rendering: pixelated;
display: none;
}
</style>
<script type="text/javascript">
// image Loupe
function updateLoupe(imgID, zoom) {
var img, loupe;
img = document.getElementById(imgID);
loupe = img.parentElement.getElementsByClassName("img-loupe")[0];
loupe.style.backgroundImage = "url('" + img.src + "')";
loupe.style.backgroundSize = (img.width * zoom) + "px " + (img.height * zoom) + "px";
}
function magnify(imgID, zoom) {
var img, loupe, w, h;
img = document.getElementById(imgID);
/* Create loupe: */
loupe = document.createElement("DIV");
loupe.setAttribute("class", "img-loupe");
img.parentElement.insertBefore(loupe, img);
img.style.cursor="crosshair";
/* Set background for loupe: */
loupe.style.backgroundImage = "url('" + img.src + "')";
loupe.style.backgroundRepeat = "no-repeat";
loupe.style.backgroundSize = (img.width * zoom) + "px " + (img.height * zoom) + "px";
/* Execute a function when someone moves the magnifier loupe over the image: */
img.parentElement.addEventListener("mousemove", moveMagnifier);
img.parentElement.addEventListener("mouseleave", function(e){loupe.style.display='none';});
function moveMagnifier(e) {
var pos, a, x = 0, y = 0;
/* Prevent any other actions that may occur when moving over the image */
e.preventDefault();
/* Calculate the cursor coordinates relative to the image: */
e = e || window.event;
a = img.getBoundingClientRect();
x = e.pageX - a.left - window.pageXOffset;
y = e.pageY - a.top - window.pageYOffset;
/* Prevent the magnifier loupe from being positioned outside the image: */
loupe.style.display='block';
if (x > img.width || x < 0 || y > img.height || y < 0) {loupe.style.display='none';}
/* Set the position of the magnifier loupe: */
loupe.style.left = (x-10+2) + "px";
loupe.style.top = (y+5+2) + "px";
/* Display what the magnifier loupe "sees": */
w = loupe.offsetWidth / 2;
h = loupe.offsetHeight / 2;
loupe.style.backgroundPosition = " " + (-(x * zoom) + w) + "px " + (-(y * zoom) + h) + "px";
}
}
</script>
</head>
<body>
<iframe src="http://mumax.github.io/header.html" width="100%" height="180" frameborder="0"></iframe>
<span style="color:gray; font-weight:bold; font-size:1.5em" >
{{.Span "title" "mumax3"}} </span>
{{.Progress "progress" 100 0}} {{.Span "busy" "" }} {{.ErrorBox}} <br/>
<hr/>
<script>
// auto scroll the console window down unless focused.
var console_focus = false;
function console_scrolldown(){
if (!console_focus){
var textarea = document.getElementById('console');
textarea.scrollTop = textarea.scrollHeight;
}
}
function setConsoleText(text){
var textarea = document.getElementById('console'); // id ignored
textarea.innerHTML = text;
console_scrolldown();
}
// CLI history
var clihistory = new Array();
var histindex = 0;
function clikeydown(event){
var cli = document.getElementById('cli');
var key = event.keyCode;
if (key == 13 && cli.value != ""){ // return key
notifyel('cli', 'value');
var backup = cli.value;
cli.value = "";
// history code goes last: prevent flackyness of messing up what came before
clihistory.push(backup);
histindex = clihistory.length;
}
if (key == 38){ // up key
if (histindex > 0) { histindex--; }
if (clihistory[histindex] != undefined) { cli.value = clihistory[histindex]; }
}
if (key == 40){ // down key
if (histindex < clihistory.length-1) { histindex++; }
if (clihistory[histindex] != undefined) { cli.value = clihistory[histindex]; }
}
}
</script>
{{.Data.Div "console"}}
{{.Console "console" 16 84 "" "onfocus=\"console_focus=true\"" "onblur=\"console_focus=false\"" "onmouseover=\"console_focus=true\"" "onmouseout=\"console_focus=false\"" "readonly" "style=\"font-family:monospace; font-size:0.8em;\"" }} <br/>
{{.CliBox "cli" "" "onkeydown=\"clikeydown(event);\"" "placeholder=\"type commands here, or up/down\"" "size=86" "style=\"font-family:monospace; font-size:0.8em;\"" }}
</div>
{{.Data.Div "mesh"}}
<table>
<tr> <td>gridsize: </td> <td>{{.TextBox "nx" "" "size=8"}} </td> <td> × {{.TextBox "ny" "" "size=8"}}</td> <td> × {{.TextBox "nz" "" "size=8"}}</td> <td> cells </td> </tr>
<tr> <td>cellsize: </td> <td>{{.TextBox "cx" "" "size=8"}} </td> <td> × {{.TextBox "cy" "" "size=8"}}</td> <td> × {{.TextBox "cz" "" "size=8"}}</td> <td> m<sup>3</sup> </td> </tr>
<tr> <td>PBC: </td> <td>{{.TextBox "px" "" "size=8"}} </td> <td> × {{.TextBox "py" "" "size=8"}}</td> <td> × {{.TextBox "pz" "" "size=8"}}</td> <td> repetitions </td> </tr>
<tr> <td>worldsize:</td> <td>{{.Span "wx" ""}} </td> <td> × {{.Span "wy" ""}}</td> <td> × {{.Span "wz" ""}}</td> <td> nm<sup>3</sup> </td> </tr>
</table>
{{.Button "setmesh" "update"}} {{.Span "setmeshwarn" ""}}
</div>
{{.Data.Div "geometry"}}
SetGeom( {{.Data.Shapes | .SelectArray "geomselect" "Universe"}} {{.TextBox "geomargs" "()" }} ) {{.Button "setgeom" "Set"}} </br>
{{.Span "geomdoc" "" "style=\"color:gray\""}}
</div>
{{.Data.Div "initial m"}}
m = {{.Data.Configs | .SelectArray "mselect" "Uniform"}} {{.TextBox "margs" "(1, 0, 0)" }} {{.Button "setm" "Set"}} </br>
{{.Span "mdoc" "" "style=\"color:gray\""}}
</div>
{{.Data.Div "solver"}}
Type: {{.Select "solvertype" "rk45" "bw_euler" "euler" "heun" "rk4" "rk23" "rk45" "rkf56"}}
<table>
<tr> <td>
<table>
<tr title="{{.Data.Doc "Run" }}"> <td> {{.Button "run" "Run" }}</td> <td> {{.TextBox "runtime" 1e-9 "size=8"}}s</td></tr>
<tr title="{{.Data.Doc "Steps" }}"> <td> {{.Button "steps" "Steps"}}</td> <td> {{.TextBox "runsteps" "1000" "size=8"}} </td></tr>
<tr title="{{.Data.Doc "Relax" }}"> <td> {{.Button "relax" "Relax"}}</td> <td></td> </tr>
<tr title="Break current run loop"> <td> {{.Button "break" "Break"}}</td> <td></td> </tr>
</table>
</td><td>
</td><td>
<table>
<tr title="Time steps taken"> <td>step: </td><td>{{.Span "nsteps" "0"}} </td></tr>
<tr title="{{.Data.Doc "t"}}"> <td>time: </td><td>{{.Span "time" "0"}} s </td></tr>
<tr title="{{.Data.Doc "dt"}}"> <td>dt: </td><td>{{.Span "dt" "0"}} s </td></tr>
<tr title="Maximum relative error/step"> <td>err/step: </td><td>{{.Span "lasterr" "0"}} </td></tr>
<tr title="Maximum absolute torque"> <td>MaxTorque:</td><td>{{.Span "maxtorque" "--"}} </td></tr>
</table>
</td><td>
</td><td>
<table>
<tr title="{{.Data.Doc "FixDt" }}"> <td>fixdt: </td><td>{{.TextBox "fixdt" "0" "size=8"}} s </td></tr>
<tr title="{{.Data.Doc "MinDt" }}"> <td>mindt: </td><td>{{.TextBox "mindt" "0" "size=8"}} s </td></tr>
<tr title="{{.Data.Doc "MaxDt" }}"> <td>maxdt: </td><td>{{.TextBox "maxdt" "0" "size=8"}} s </td></tr>
<tr title="{{.Data.Doc "MaxErr"}}"> <td>maxerr: </td><td>{{.TextBox "maxerr" "0" "size=8"}}/step</td></tr>
</table>
</td></tr>
</table>
</div>
{{.Data.Div "display"}}
<p>
Quantity: {{.Data.QuantNames | .SelectArray "renderQuant" "m"}} {{.Select "renderComp" "" "" "x" "y" "z"}} {{.Span "renderDoc" "" "style=\"color:gray\""}} <br/>
<table>
<tr title="Slice through z layers"> <td> Slice: {{.Range "renderLayer" 0 0 0 }} </td><td> {{.Span "renderLayerLabel" "0"}} </td></tr>
<tr title="Zoom out large images"> <td> Scale: {{.Range "renderScale" 0 31 31}} </td><td> {{.Span "renderScaleLabel" "1/1"}} </td></tr>
</table>
</p>
<p>
<div class="img-loupe-div" style="margin: 0">
{{.Img "display" "/render/m" "alt=\"display\""}}
<script>
/* Set loupe and update it as the image can change... */
magnify("display", 5);
setInterval(function () { updateLoupe("display", 5); }, tick*2);
</script>
</div>
</p>
</div>
{{.Data.Div "gnuplot"}}
<p title="{{$.Data.Doc "TableAutoSave"}}">
TableAutosave: {{.TextBox "tableAutoSave" "0" }} s
</p>
Plot of "table.txt", provided table is being autosaved and gnuplot installed.<br>
<b>plot "table.txt" using {{.TextBox "usingx" "1"}} : {{.TextBox "usingy" "2"}} with lines </b><br/>
<p class=ErrorBox>{{.Span "plotErr" ""}}</p>
{{.Img "plot" "/plot/"}}
</div>
{{.Data.Div "parameters"}}
Region: {{.Number "region" -1 255 -1}} </br>
<table>
{{range .Data.Parameters}}
<tr title="{{$.Data.Doc .}}"> <td>{{.}}</td> <td> {{$.TextBox . ""}} {{$.Data.UnitOf . }}</td> </tr>
{{end}}
</table>
</div>
<hr/>
<div style="font-size:0.9em; color:gray; text-align:center">
{{.Data.Version}} <br/>
{{.Data.GPUInfo}} ({{.Span "memfree" ""}} MB free) <br/>
© 2013 Arne Vansteenkiste, DyNaMat LAB, UGent.
</div>
</body>
</html>
`
const CSS = `
<style media="all" type="text/css">
body { margin-left: 5%; margin-right:5%; font-family: sans-serif; font-size: 14px; }
img { margin: 10px; }
table { border-collapse: collapse; }
td { padding: 1px 5px; }
hr { border-style: none; border-top: 1px solid #CCCCCC; }
a { color: #375EAB; text-decoration: none; }
div { margin-left: 20px; margin-top: 5px; margin-bottom: 20px; }
div#footer{ color:gray; font-size:14px; border:none; }
.ErrorBox { color: red; font-weight: bold; font-size: 1em; }
.TextBox { border:solid; border-color:#BBBBBB; border-width:1px; padding-left:4px; }
textarea { border:solid; border-color:#BBBBBB; border-width:1px; padding-left:4px; color:gray; font-size: 1em; }
</style>
`