-
Notifications
You must be signed in to change notification settings - Fork 44
/
menu.html
executable file
·380 lines (303 loc) · 9.87 KB
/
menu.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
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script language = "JavaScript1.2" src="Global.js"></script>
<script src="util.js"></script>
<script language = "JavaScript1.2" src="GenMenu.js"></script>
<script language = "JavaScript1.2" src="GenMscript.js"></script>
<script language = "JavaScript1.2" src="GenCscript.js"></script>
<script language = "JavaScript1.2" src="GenPscript.js"></script>
<script language = "JavaScript1.2" src="GenLscript.js"></script>
<script src="GenFlamePyscript.js"></script>
<script src="cookies.js"></script>
</head>
<body>
<form name="myForm" onReset="ResetCookie()">
<div>
<!-- <input type="submit" value="Generate Code and/or Update Form"> -->
<input type="reset" value="Reset Form">
</div>
<hr>
<script>
var j;
VarName = new Array( 0, 0, 0, 0, 0, 0 );
TypeName = new Array( 0, 0, 0, 0, 0, 0 );
DirName = new Array( 0, 0, 0, 0, 0, 0 );
IoName = new Array( 0, 0, 0, 0, 0, 0 );
author = cookieValue( "author" );
if ( author == -1 ) author = "Name of author";
email = cookieValue( "email" );
if ( email == -1 ) email = "Email of author";
FnName = cookieValue( "FnName" );
if ( FnName == -1 ) FnName = "Function Name";
FnType = cookieValue( "FnType" );
if ( FnType == -1 ) FnType = DefaultFnType;
Variant = cookieValue( "Variant" );
if ( Variant == -1 ) Variant = " ";
NumOpers = cookieValue( "NumOpers" );
if ( NumOpers == -1 ) NumOpers = 1;
for ( j=0; j<6; j++ ){
VarName[ j ] = cookieValue( "VarName" + j );
if ( VarName[j] == -1 ) VarName[j] = j;
TypeName[ j ] = cookieValue( "TypeName" + j );
if ( TypeName[j] == -1 ) TypeName[j] = 2;
DirName[ j ] = cookieValue( "DirName" + j );
if ( DirName[j] == -1 ) DirName[j] = 1;
IoName[ j ] = cookieValue( "IoName" + j );
if ( IoName[j] == -1 ) IoName[j] = 2;
}
Language = cookieValue( "Language" );
if ( Language == -1 ) Language = DefaultLanguage;
</script>
<table class="help">
<tr>
<td align="left">
<a href="intro.html#section1" target="output">learn about this section</a>
</td>
<td align="right">
<a href="intro.html" target="output">introduction to Spark</a>
</td>
</tr>
</table>
<p>
Name of the function to be generated:
<script>
prog = "<input type=\"Text\" name=\"FnName\" value=\"" + FnName + "\" size=\"25\">";
document.write( prog );
</script>
</p>
<p>
Type of function:
<script>
str = GenChoices( "FnType", FnType, nblkchoices, BlkChoices );
document.write(str);
document.getElementById('FnType').addEventListener("change", setCookie, false);
</script>
</p>
<p>
Variant number:
<script>
prog = GenChoices( "Variant", Variant, nvarchoices, VarChoices );
document.write( prog );
document.getElementById('Variant').addEventListener("change", setCookie, false);
</script>
</p>
<hr>
<table class="help">
<tr>
<td align="left">
<a href="intro.html#section2" target="output">learn about this section</a>
</td>
<td align="right">
<a href="intro.html" target="output">introduction to Spark</a>
</td>
</tr>
</table>
<p>
Number of operands:
<script>
function updateIo(){
var tbl = document.getElementById('propertyTbl');
var numOutputOperands = 0;
for (var i = 1; i != tbl.rows.length; ++i){
if (document.getElementById('IoName' + (i-1)).selectedIndex == 2){
numOutputOperands += 1;
}
}
if (numOutputOperands == 0){
this.selectedIndex = 2;
alert("There be at least one output operand.");
}
setCookie();
}
function updateType(){
var idNum = this.id.charAt(this.id.length-1);
var operandType = this.selectedIndex;
var oldDirSelector = document.getElementById('DirName' + idNum);
var newDirChoices = null;
var newDir = -1;
switch(operandType){
case 0: //scalar- only can be none
//make sure that there is at least one partitioned operand
var tbl = document.getElementById('propertyTbl');
var numPartitionedOperands = 0;
for (var i = 1; i != tbl.rows.length; ++i){
if (document.getElementById('TypeName' + (i-1)).selectedIndex != 0){
numPartitionedOperands += 1;
}
}
if (numPartitionedOperands == 0){
this.selectedIndex = 2;
newDirChoices = SDirChoices.concat(MDirChoices, VDirChoices);
newDir = 1;
alert("There must be at least one partitioned operand.");
}
else{
newDirChoices = SDirChoices;
newDir = 0;
}
break;
case 1: //vector - only none, L->R, R->L, T->B, B->T are possible
newDirChoices = SDirChoices.concat(VDirChoices);
newDir = (oldDirSelector.selectedIndex>4 ? oldDirSelector.selectedIndex-4 : oldDirSelector.selectedIndex);
break;
case 2: //matrix - all directions are possible so do nothing
newDirChoices = SDirChoices.concat(MDirChoices, VDirChoices);
newDir = oldDirSelector.selectedIndex;
if (newDir!=0)
newDir += 4;
break;
}
var str = GenChoices("DirName" + idNum, newDir, newDirChoices.length, newDirChoices);
var newSelector = document.createElement('div');
newSelector.innerHTML = str;
newSelector.firstChild.addEventListener("change", setCookie, false);
oldDirSelector.parentNode.replaceChild(newSelector.firstChild, oldDirSelector);
setCookie();
}
function updateProperties(){
var tbl = document.getElementById('propertyTbl');
var opChoice = document.getElementById('NumOpers').selectedIndex + 1;
if (opChoice + 1 == tbl.rows.length){
//do nothing
}
else{
if (opChoice + 1 < tbl.rows.length){
//delete row
while (tbl.rows.length > opChoice + 1){
tbl.deleteRow(-1);
}
}
else{
//insert row
while (tbl.rows.length < opChoice + 1){
var rw = tbl.insertRow(-1);
var i = tbl.rows.length-2;
var prog = "<td align=\"center\">" + (i + 1) + ":</td> \n";
prog += "<td> " + GenChoices( "VarName" + i, VarName[i], nchoices, MChoices ) + "</td>" +
"<td> " + GenChoices( "TypeName" + i, TypeName[i], ntypes, TypeChoices ) + "</td>" +
"<td> " + GenChoices( "DirName" + i, DirName[i], ndirs, DirChoices ) + "</td>" +
"<td> " + GenChoices( "IoName" + i, IoName[i], nios, IoChoices ) + "</td>" +
"\n";
rw.innerHTML = prog;
document.getElementById('VarName' + i).addEventListener("change", setCookie, false);
document.getElementById('TypeName' + i).addEventListener("change", updateType, false);
document.getElementById('DirName' + i).addEventListener("change", setCookie, false);
document.getElementById('IoName' + i).addEventListener("change", updateIo, false);
}
}
}
setCookie();
}
// document.write(GenChoices( "NumOpers", NumOpers, nOperChoices, OperChoices ));
str = "<select name=\"NumOpers\" id=\"NumOpers\"> \n\n";
for (var i = 0; i != OperChoices.length; ++i){
str += " <option value=" + i + " ";
if ( parseInt(NumOpers,10)-1 == i ) str += "selected";
str += "> " + OperChoices[ i ] + " </option>";
str += " \n\n";
}
str += "</select>";
document.write(str);
document.getElementById('NumOpers').addEventListener("change", updateProperties, false);
</script>
</p>
<p>
Pick properties of the operands
<table id="propertyTbl">
<tr>
<td align="center"> Operand </td>
<td align="center"> Tag </td>
<td align="center"> Type </td>
<td align="center"> Direction </td>
<td align="center"> Input/Output </td>
</tr>
</table>
<script>
var i;
for ( i=0; i<NumOpers; i++ ){
var prog = "";
var tbl = document.getElementById('propertyTbl');
var rw = tbl.insertRow(-1);
prog += "<td align=\"center\">" + (i + 1) + ":</td> \n";
prog += "<td> " + GenChoices( "VarName" + i, VarName[i], nchoices, MChoices ) + "</td>" +
"<td> " + GenChoices( "TypeName" + i, TypeName[i], ntypes, TypeChoices ) + "</td>" +
"<td> " + GenChoices( "DirName" + i, DirName[i], ndirs, DirChoices ) + "</td>" +
"<td> " + GenChoices( "IoName" + i, IoName[i], nios, IoChoices ) + "</td>\n";
rw.innerHTML = prog;
document.getElementById('VarName' + i).addEventListener("change", setCookie, false);
document.getElementById('TypeName' + i).addEventListener("change", updateType, false);
document.getElementById('DirName' + i).addEventListener("change", setCookie, false);
document.getElementById('IoName' + i).addEventListener("change", updateIo, false);
}
</script>
</p>
<hr>
<table class="help">
<tr>
<td align="left">
<a href="intro.html#section3" target="output">
learn about this section
</a>
</td>
<td align="right">
<a href="intro.html" target="output">
introduction to Spark
</a>
</td>
</tr>
</table>
<p>
Pick an output language:
<script>
str = GenChoices( "Language", Language, nlanguages, LanguageChoices );
document.write(str);
document.getElementById('Language').addEventListener("change", setCookie, false);
</script>
</p>
<hr>
<table class="help">
<tr>
<td align="left">
<a href="intro.html#section4" target="output">
learn about this section
</a>
</td>
<td align="right">
<a href="intro.html" target="output">
introduction to Spark
</a>
</td>
</tr>
</table>
<p>
Additional Information
</p>
<table>
<tr>
<td> <b> Name of Author </b> </td>
<td>
<script>
prog = "<input type=\"Text\" name=\"author\" value=\"" + author + "\" size=\"25\" maxlength=\"50\">";
document.write( prog );
</script>
</td>
</tr>
<tr>
<td> <b> E-mail of Author </b> </td>
<td>
<script>
prog = "<input type=\"Text\" name=\"email\" value=\"" + email + "\" size=\"25\" maxlength=\"50\">";
document.write( prog );
</script>
</td>
</tr>
</table>
<hr>
<div>
<!-- <input type="submit" value="Generate Code and/or Update Form">-->
<input type="reset" value="Reset Form">
</div>
</form>
</body>
</html>