X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matitaB%2Fmatita%2Fmatitaweb.js;h=30c138385e33b659b9c5f323273f7e79a8a2d8f7;hb=11a20b624a4b5ed18008678cf6cd46dd9a32634d;hp=343d539e66deda5c23cc8a963430f0f693bb72c5;hpb=04168c737e0916ebdbcdb1457f228bef670c657b;p=helm.git diff --git a/matitaB/matita/matitaweb.js b/matitaB/matita/matitaweb.js index 343d539e6..30c138385 100644 --- a/matitaB/matita/matitaweb.js +++ b/matitaB/matita/matitaweb.js @@ -497,22 +497,6 @@ String.prototype.matita_to_html = function() return (unescape(result)); } -function pause() -{ - advanceButton.disabled = true; - retractButton.disabled = true; - cursorButton.disabled = true; - bottomButton.disabled = true; -} - -function resume() -{ - advanceButton.disabled = false; - retractButton.disabled = false; - cursorButton.disabled = false; - bottomButton.disabled = false; -} - function is_defined(x) { return (typeof x != "undefined"); @@ -580,109 +564,122 @@ function callServer(servicename,processResponse,reqbody) } -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"); +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; + var 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 + + "" + + mid + "" + post; + + var title = "
Errors at node " + choiceno + " = " + choicedesc + "
"; + var subtitle = "Errors at node " + cpno + " = " + choicedesc + "
"; disambcell.innerHTML = title + subtitle; var failures = get_failure_opts(cpno,choiceno); @@ -998,6 +997,7 @@ function gotoTop() callServer("top",processor,"body=" + (unlocked.innerHTML.html_to_matita()).sescape()); } + function gotoPos(offset) { if (!is_defined(offset)) { @@ -1005,6 +1005,8 @@ function gotoPos(offset) } processor = function(xml) { if (is_defined(xml)) { + try { + /* parsed = xml.getElementsByTagName("parsed")[0]; len = parseInt(parsed.getAttribute("length")); // len0 = unlocked.innerHTML.length; @@ -1022,6 +1024,8 @@ function gotoPos(offset) statements = listcons(len2,statements); unlocked.scrollIntoView(true); // la populate non andrebbe fatta a ogni passo + */ + var len = advOneStep(xml); if (offset <= len) { init_autotraces(); populate_goalarray(metasenv); @@ -1029,6 +1033,11 @@ function gotoPos(offset) } else { gotoPos(offset - len); } + } catch (er) { + init_autotraces(); + populate_goalarray(metasenv); + resume(); + } } else { init_autotraces(); unlocked.scrollIntoView(true); @@ -1422,7 +1431,8 @@ function get_checked_index(name) { function cancel_disambiguate() { matita.disambMode = false; - $('#whitemask').hide(); + enable_toparea(); + enable_editing(); updateSide(); } @@ -1449,7 +1459,8 @@ function do_disambiguate() { unlocked.innerHTML = pre + mid + post; matita.disambMode = false; - $('#whitemask').hide(); + enable_toparea(); + enable_editing(); updateSide(); } } @@ -1510,3 +1521,36 @@ function disable_toparea() { $('#whitemask').css('height',$('#toparea').outerHeight() + "px"); $('#whitemask').fadeTo('fast',0.7); } + +function enable_toparea() { + $('#whitemask').hide(); +} + +function disable_editing() { + unlocked.contentEditable = false; +} + +function enable_editing() { + unlocked.contentEditable = true; +} + +function pause() +{ + // advanceButton.disabled = true; + // retractButton.disabled = true; + // cursorButton.disabled = true; + // bottomButton.disabled = true; + disable_toparea(); + disable_editing(); +} + +function resume() +{ + // advanceButton.disabled = false; + // retractButton.disabled = false; + // cursorButton.disabled = false; + // bottomButton.disabled = false; + enable_toparea(); + enable_editing(); +} +