var dialogTitle;
var dialogContent;
var metasenv = "";
+var lockedbackup = "";
function initialize()
{
}
}
+// the following is used to avoid escaping unicode, which results in
+// the server being unable to unescape the string
String.prototype.sescape = function() {
var patt1 = /%/gi;
var patt2 = /=/gi;
// debug("advance: received response\nBEGIN\n" + req.responseText + "\nEND");
parsed = xml.getElementsByTagName("parsed")[0];
len = parseInt(parsed.getAttribute("length"));
- len0 = unlocked.innerHTML.length;
+ // len0 = unlocked.innerHTML.length;
unescaped = unlocked.innerHTML.html_to_matita();
parsedtxt = parsed.childNodes[0].nodeValue;
//parsedtxt = unescaped.substr(0,len);
unparsedtxt = unescaped.substr(len);
- locked.innerHTML = locked.innerHTML + parsedtxt; //.matita_to_html();
+ lockedbackup += parsedtxt;
+ locked.innerHTML = lockedbackup;
unlocked.innerHTML = unparsedtxt.matita_to_html();
- len1 = unlocked.innerHTML.length;
- len2 = len0 - len1;
+ // len1 = unlocked.innerHTML.length;
+ // len2 = len0 - len1;
+ len2 = parsedtxt.length;
metasenv = xml.getElementsByTagName("meta");
populate_goalarray(metasenv);
statements = listcons(len2,statements);
// debug("goto bottom: received response\nBEGIN\n" + req.responseText + "\nEND");
parsed = xml.getElementsByTagName("parsed")[0];
len = parseInt(parsed.getAttribute("length"));
- len0 = unlocked.innerHTML.length;
- unescaped = unlocked.innerHTML.html_to_matita();
- parsedtxt = parsed.childNodes[0].nodeValue;
- //parsedtxt = unescaped.substr(0,len);
- unparsedtxt = unescaped.substr(len);
- locked.innerHTML = locked.innerHTML + parsedtxt; //.matita_to_html();
- unlocked.innerHTML = unparsedtxt.matita_to_html();
- len1 = unlocked.innerHTML.length;
- len2 = len0 - len1;
- metasenv = xml.getElementsByTagName("meta");
- populate_goalarray(metasenv);
- statements = listcons(len2,statements);
- unlocked.scrollIntoView(true);
+ if (len > 0) {
+ // len0 = unlocked.innerHTML.length;
+ unescaped = unlocked.innerHTML.html_to_matita();
+ parsedtxt = parsed.childNodes[0].nodeValue;
+ //parsedtxt = unescaped.substr(0,len);
+ unparsedtxt = unescaped.substr(len);
+ lockedbackup += parsedtxt;
+ locked.innerHTML = lockedbackup; //.matita_to_html();
+ unlocked.innerHTML = unparsedtxt.matita_to_html();
+ // len1 = unlocked.innerHTML.length;
+ len2 = parsedtxt.length;
+ metasenv = xml.getElementsByTagName("meta");
+ populate_goalarray(metasenv);
+ if (len2 > 0)
+ statements = listcons(len2,statements);
+ unlocked.scrollIntoView(true);
+ }
} else {
debug("goto bottom failed");
}
if (is_defined(xml)) {
parsed = xml.getElementsByTagName("parsed")[0];
len = parseInt(parsed.getAttribute("length"));
- len0 = unlocked.innerHTML.length;
+ // len0 = unlocked.innerHTML.length;
unescaped = unlocked.innerHTML.html_to_matita();
parsedtxt = parsed.childNodes[0].nodeValue;
//parsedtxt = unescaped.substr(0,len);
unparsedtxt = unescaped.substr(len);
- locked.innerHTML = locked.innerHTML + parsedtxt; //.matita_to_html();
+ lockedbackup += parsedtxt;
+ locked.innerHTML = lockedbackup; //.matita_to_html();
unlocked.innerHTML = unparsedtxt.matita_to_html();
- len1 = unlocked.innerHTML.length;
- len2 = len0 - len1;
+ // len1 = unlocked.innerHTML.length;
+ len2 = parsedtxt.length;
metasenv = xml.getElementsByTagName("meta");
// populate_goalarray(metasenv);
statements = listcons(len2,statements);
// debug("advance: received response\nBEGIN\n" + req.responseText + "\nEND");
statementlen = parseInt(listhd(statements));
statements = listtl(statements);
+ /*
lockedlen = locked.innerHTML.length - statementlen;
statement = locked.innerHTML.substr(lockedlen, statementlen);
locked.innerHTML = locked.innerHTML.substr(0,lockedlen);
unlocked.innerHTML = statement + unlocked.innerHTML;
+ */
+ lockedlen = lockedbackup.length - statementlen;
+ statement = lockedbackup.substr(lockedlen, statementlen);
+ lockedbackup = lockedbackup.substr(0,lockedlen);
+ locked.innerHTML = lockedbackup;
+ unlocked.innerHTML = statement + unlocked.innerHTML;
metasenv = xml.getElementsByTagName("meta");
populate_goalarray(metasenv);
unlocked.scrollIntoView(true);
processor = function(xml)
{
if (is_defined(xml)) {
- locked.innerHTML = "";
+ lockedbackup = "";
+ locked.innerHTML = lockedbackup;
unlocked.innerHTML = xml.documentElement.textContent;
} else {
debug("file open failed");
processor = function(xml)
{
if (is_defined(xml)) {
- locked.innerHTML = "";
+ lockedbackup = ""
+ locked.innerHTML = lockedbackup;
debug(xml.getElementsByTagName("file")[0].childNodes[0].nodeValue);
unlocked.innerHTML = xml.getElementsByTagName("file")[0].childNodes[0].nodeValue;
}
};
dialogBox.style.display = "none";
+ current_fname = thefile;
callServer("open",processor,"file=" + escape(thefile));
}
}
+function saveFile()
+{
+ processor = function(xml) {
+ if (is_defined(xml)) {
+ debug("file saved!");
+ } else {
+ debug("save file failed");
+ }
+ resume();
+ };
+ if (is_defined(current_fname)) {
+ pause();
+ callServer("save",processor,"file=" + escape(current_fname) +
+ "&locked=" + (locked.innerHTML.html_to_matita()).sescape() +
+ "&unlocked=" + (unlocked.innerHTML.html_to_matita()).sescape());
+ }
+ else { debug("no file selected"); }
+}
+
+function commitAll()
+{
+ processor = function(xml) {
+ if (is_defined(xml)) {
+ debug("commit succeeded(?)");
+ } else {
+ debug("commit failed!");
+ }
+ resume();
+ };
+ pause();
+ callServer("commit",processor);
+}
+
var goalcell;
function hideSequent() {