Commit 3e108276 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-12-28 14:22:09 by afrisch] Demo

Original author: afrisch
Date: 2004-12-28 14:22:09+00:00
parent aeac89de
function clearreq(pr)
{ document.getElementById(pr+"req").value = ""; }
{ document.getElementById(pr+"edit").value = ""; }
function show_result(pr,res)
{ document.getElementById(pr+"res").innerHTML = res; }
......@@ -8,8 +8,12 @@ function clearres(pr)
{ show_result(pr,""); }
function defreq(pr)
{ document.getElementById(pr+"req").value =
document.getElementById(pr+"def").value; }
{ var req = document.getElementById(pr+"req");
var edit = document.getElementById(pr+"edit");
var def = document.getElementById(pr+"def");
edit.value = def.value;
req.innerHTML = def.value;
}
function submit(pr) {
var xmlhttp = new XMLHttpRequest();
......@@ -19,4 +23,27 @@ function submit(pr) {
}
show_result(pr,"Computing...");
xmlhttp.send(document.getElementById(pr+"req").value);
}
function editable(pr,b) {
var ct = document.getElementById(pr+"container");
var req = document.getElementById(pr+"req");
var edit = document.getElementById(pr+"edit");
var btn = document.getElementById(pr+"btn");
var btnclear = document.getElementById(pr+"btnclear");
if ((req.style.visibility=='hidden') || (b == "init")) {
req.innerHTML = edit.value;
req.style.visibility='visible';
edit.style.visibility='hidden';
btnclear.style.visibility='hidden';
btn.value="Edit";
ct.style.height = req.offsetHeight;
}
else {
req.style.visibility='hidden';
edit.style.visibility='visible';
btnclear.style.visibility='visible';
btn.value="Unedit";
ct.style.height = edit.offsetHeight;
}
}
\ No newline at end of file
......@@ -261,15 +261,20 @@ let demo(no : Int)(txt : String) : H:Flow =
<tr>[
<td style="width:50%">[
(button "Evaluate" ("submit('"@n@"');"))
(button "Clear" ("clearreq('"@n@"');"))
(button "Default" ("defreq('"@n@"');"))
<input type="submit" id=(n@"btnclear") value="Clear" onclick=("clearreq('"@n@"');")>[]
]
<td style="width:50%">[
<input id=(n@"def") type="hidden" value=txt>[]
(button "Clear" ("clearres('"@n@"');"))
] ]
<tr>[
<td valign="top">[ <textarea id=(n@"req") cols="60" rows="25">txt ]
<td valign="top">[
<div style="position:relative; height:100px;" id=(n@"container")>[
<pre style="position:absolute; z-index:2; height:auto;" id=(n@"req")>[]
<textarea id=(n@"edit") cols="60" rows="25" style="position:absolute; z-index:1; height:auto;">txt
]
]
<td valign="top">[ <div id=(n@"res")>[] ] ] ] ]
(* Main transformation function *)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment