-function advanceForm1()
-{
- processor = function(xml) {
- if (is_defined(xml)) {
- var parsed = xml.getElementsByTagName("parsed")[0];
- var ambiguity = xml.getElementsByTagName("ambiguity")[0];
- var disamberr = xml.getElementsByTagName("disamberror")[0];
- if (is_defined(parsed)) {
- // debug("advance: received response\nBEGIN\n" + req.responseText + "\nEND");
- var len = parseInt(parsed.getAttribute("length"));
- // len0 = unlocked.innerHTML.length;
- var unescaped = unlocked.innerHTML.html_to_matita();
- var parsedtxt = parsed.childNodes[0].wholeText;
- //parsedtxt = unescaped.substr(0,len);
- var unparsedtxt = unescaped.substr(len);
- lockedbackup += parsedtxt;
- locked.innerHTML = lockedbackup;
- unlocked.innerHTML = unparsedtxt.matita_to_html();
- // len1 = unlocked.innerHTML.length;
- // len2 = len0 - len1;
- var len2 = parsedtxt.length;
- var metasenv = xml.getElementsByTagName("meta");
- populate_goalarray(metasenv);
- init_autotraces();
- statements = listcons(len2,statements);
- unlocked.scrollIntoView(true);
- }
- else if (is_defined(ambiguity)) {
- var start = parseInt(ambiguity.getAttribute("start"));
- var stop = parseInt(ambiguity.getAttribute("stop"));
- var choices = xml.getElementsByTagName("choice");
-
- matita.ambiguityStart = start;
- matita.ambiguityStop = stop;
- matita.unlockedbackup = unlocked.innerHTML.html_to_matita();
- matita.interpretations = [];
-
- var unlockedtxt = unlocked.innerHTML.html_to_matita();
- var pre = unlockedtxt.substring(0,start).matita_to_html();
- var mid = unlockedtxt.substring(start,stop).matita_to_html();
- var post = unlockedtxt.substring(stop).matita_to_html();
- unlocked.innerHTML = pre +
- "<span class=\"error\" title=\"disambiguation error\">" +
- mid + "</span>" + post;
-
- var title = "<H3>Ambiguous input</H3>";
- disambcell.innerHTML = title;
- for (i = 0;i < choices.length;i++) {
- matita.interpretations[i] = new Object();
-
- var href = choices[i].getAttribute("href");
- var title = choices[i].getAttribute("title");
- var desc = choices[i].childNodes[0].nodeValue;
+function advOneStep(xml) {
+ var parsed = xml.getElementsByTagName("parsed")[0];
+ var ambiguity = xml.getElementsByTagName("ambiguity")[0];
+ var disamberr = xml.getElementsByTagName("disamberror")[0];
+ if (is_defined(parsed)) {
+ // debug("advance: received response\nBEGIN\n" + req.responseText + "\nEND");
+ var len = parseInt(parsed.getAttribute("length"));
+ // len0 = unlocked.innerHTML.length;
+ var unescaped = unlocked.innerHTML.html_to_matita();
+ var parsedtxt = parsed.childNodes[0].wholeText;
+ //parsedtxt = unescaped.substr(0,len);
+ var unparsedtxt = unescaped.substr(len);
+ lockedbackup += parsedtxt;
+ locked.innerHTML = lockedbackup;
+ unlocked.innerHTML = unparsedtxt.matita_to_html();
+ // len1 = unlocked.innerHTML.length;
+ // len2 = len0 - len1;
+ var len2 = parsedtxt.length;
+ metasenv = xml.getElementsByTagName("meta");
+ statements = listcons(len2,statements);
+ unlocked.scrollIntoView(true);
+ return len;
+ }
+ else if (is_defined(ambiguity)) {
+ var start = parseInt(ambiguity.getAttribute("start"));
+ var stop = parseInt(ambiguity.getAttribute("stop"));
+ var choices = xml.getElementsByTagName("choice");
+
+ matita.ambiguityStart = start;
+ matita.ambiguityStop = stop;
+ matita.unlockedbackup = unlocked.innerHTML.html_to_matita();
+ matita.interpretations = [];
+
+ var unlockedtxt = unlocked.innerHTML.html_to_matita();
+ var pre = unlockedtxt.substring(0,start).matita_to_html();
+ var mid = unlockedtxt.substring(start,stop).matita_to_html();
+ var post = unlockedtxt.substring(stop).matita_to_html();
+ unlocked.innerHTML = pre +
+ "<span class=\"error\" title=\"disambiguation error\">" +
+ mid + "</span>" + post;
+
+ var title = "<H3>Ambiguous input</H3>";
+ disambcell.innerHTML = title;
+ for (i = 0;i < choices.length;i++) {
+ matita.interpretations[i] = new Object();
+
+ var href = choices[i].getAttribute("href");
+ var title = choices[i].getAttribute("title");
+ var desc = choices[i].childNodes[0].nodeValue;
+
+ matita.interpretations[i].href = href;
+ matita.interpretations[i].title = title;
+ matita.interpretations[i].desc = desc;
+
+ var choice = document.createElement("input");
+ choice.setAttribute("type","radio");
+ choice.setAttribute("name","interpr");
+ choice.setAttribute("href",href);
+ choice.setAttribute("title",title);
+ if (i == 0) choice.setAttribute("checked","");
+
+ disambcell.appendChild(choice);
+ disambcell.appendChild(document.createTextNode(desc));
+ disambcell.appendChild(document.createElement("br"));
+ }