X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matitaB%2Fmatita%2Fmatitaweb.js;h=48acfe13e223a0118b03b5d96ddc7b1a36250513;hb=b352c0b72bb62f7b4a44952aebc01f405f6af817;hp=86481a1ed15417a77dc3cdbc732cc02d17ceb7ee;hpb=6c146035564b39f54a3c919135f179cec349c284;p=helm.git diff --git a/matitaB/matita/matitaweb.js b/matitaB/matita/matitaweb.js index 86481a1ed..48acfe13e 100644 --- a/matitaB/matita/matitaweb.js +++ b/matitaB/matita/matitaweb.js @@ -179,7 +179,7 @@ function debug(txt) // but google chrome's innerText is, in a sense, "write only" // what should we do? // logarea.innerText = txt + "\n" + logarea.innerText; - logarea.innerHTML = txt + "\n" + logarea.innerHTML; + logarea.innerHTML = txt; // + "\n" + logarea.innerText; } function listhd(l) @@ -508,7 +508,9 @@ function gotoBottom() if (len > 0) { // len0 = unlocked.innerHTML.length; unescaped = unlocked.innerHTML.html_to_matita(); - parsedtxt = parsed.childNodes[0].nodeValue; + // not working in mozilla + // parsedtxt = parsed.childNodes[0].nodeValue; + parsedtxt = parsed.childNodes[0].wholeText; //parsedtxt = unescaped.substr(0,len); unparsedtxt = unescaped.substr(len); lockedbackup += parsedtxt; @@ -612,7 +614,7 @@ function openFile() if (is_defined(xml)) { lockedbackup = ""; locked.innerHTML = lockedbackup; - unlocked.innerHTML = xml.documentElement.textContent; + unlocked.innerHTML = xml.documentElement.wholeText; } else { debug("file open failed"); } @@ -642,7 +644,7 @@ function retrieveFile(thefile) callServer("open",processor,"file=" + escape(thefile)); } -function showLibrary() +function showLibrary(title,callback) { var req = null; // pause(); @@ -673,7 +675,7 @@ function showLibrary() if(stat == 200) { debug(req.responseText); - showDialog("

Library

",req.responseText); + showDialog("

" + title + "

",req.responseText, callback); } } }; @@ -683,21 +685,48 @@ function showLibrary() } -function saveFile() +function openDialog() +{ + callback = function (fname) { retrieveFile(fname); }; + showLibrary("Open file", callback); +} + +function saveDialog() +{ + callback = function (fname) { + dialogBox.style.display = "none"; + current_fname = fname; + saveFile(fname,false); + }; + showLibrary("Save file as", callback); +} + +function saveFile(fname,force) { + if (!is_defined(fname)) { + fname = current_fname; + } processor = function(xml) { if (is_defined(xml)) { + if (xml.childNodes[0].textContent != "ok") { + if (confirm("File already exists. Do you want to proceed anyway?")) { + saveFile(fname,true); + } else { + saveDialog(); + } + } else debug("file saved!"); } else { debug("save file failed"); } resume(); }; - if (is_defined(current_fname)) { + if (is_defined(fname)) { pause(); - callServer("save",processor,"file=" + escape(current_fname) + + callServer("save",processor,"file=" + escape(fname) + "&locked=" + (locked.innerHTML.html_to_matita()).sescape() + - "&unlocked=" + (unlocked.innerHTML.html_to_matita()).sescape()); + "&unlocked=" + (unlocked.innerHTML.html_to_matita()).sescape() + + "&force=" + force); } else { debug("no file selected"); } } @@ -728,10 +757,11 @@ function showSequent() { workarea.appendChild(goalcell); } -function showDialog(title,content) { +function showDialog(title,content,callback) { dialogTitle.innerHTML = title; dialogContent.innerHTML = content; dialogBox.style.display = "block"; + dialogBox.callback = callback; } function removeElement(id) {