X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matitaB%2Fmatita%2Fmatitaweb.js;h=fc90080d255a16cd18ed359ef624a2f8e8e83046;hb=83fa6fc1317f18af956b194b996afae10ec859a7;hp=48acfe13e223a0118b03b5d96ddc7b1a36250513;hpb=b352c0b72bb62f7b4a44952aebc01f405f6af817;p=helm.git diff --git a/matitaB/matita/matitaweb.js b/matitaB/matita/matitaweb.js index 48acfe13e..fc90080d2 100644 --- a/matitaB/matita/matitaweb.js +++ b/matitaB/matita/matitaweb.js @@ -695,27 +695,45 @@ function saveDialog() { callback = function (fname) { dialogBox.style.display = "none"; - current_fname = fname; - saveFile(fname,false); + saveFile(fname, + (locked.innerHTML.html_to_matita()).sescape(), + (unlocked.innerHTML.html_to_matita()).sescape(), + false,saveDialog); }; showLibrary("Save file as", callback); } -function saveFile(fname,force) +function newDialog() +{ + callback = function (fname) { + dialogBox.style.display = "none"; + saveFile(fname,"","",false,newDialog); + }; + showLibrary("Create new file", callback); +} + + +function saveFile(fname,lockedtxt,unlockedtxt,force,reloadDialog) { if (!is_defined(fname)) { fname = current_fname; + lockedtxt = (locked.innerHTML.html_to_matita()).sescape(); + unlockedtxt = (unlocked.innerHTML.html_to_matita()).sescape(); + force = true; + // when force is true, reloadDialog is not needed } 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); + if (confirm("File already exists. All existing data will be lost.\nDo you want to proceed anyway?")) { + saveFile(fname,lockedtxt,unlockedtxt,true); } else { - saveDialog(); + reloadDialog(); } - } else - debug("file saved!"); + } else { + current_fname = fname; + debug("file saved!"); + } } else { debug("save file failed"); } @@ -724,8 +742,8 @@ function saveFile(fname,force) if (is_defined(fname)) { pause(); callServer("save",processor,"file=" + escape(fname) + - "&locked=" + (locked.innerHTML.html_to_matita()).sescape() + - "&unlocked=" + (unlocked.innerHTML.html_to_matita()).sescape() + + "&locked=" + lockedtxt + + "&unlocked=" + unlockedtxt + "&force=" + force); } else { debug("no file selected"); }