Files
LAFF/Spark/menu.html
Julien Lengrand-Lambert d4dce71599 Create repo
2018-05-02 09:13:08 +02:00

381 lines
9.8 KiB
HTML
Executable File

<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" onSubmit="setCookie()" 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 = 1;
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 = 0;
</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\" maxlength=\"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>
document.write(GenChoices( "Language", Language, nlanguages, LanguageChoices ));
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>