title="Execute the script until the current position of the cursor."></A>
<A href="javascript:gotoBottom()"><IMG src="icons/bottom.png"
id="bottom" alt="Bottom" title="Execute the whole script."></A>
+ <INPUT type="BUTTON" value="New" id="showdialog" ONCLICK="newDialog()">
<INPUT type="BUTTON" value="Browse library" id="showdialog" ONCLICK="openDialog()">
<INPUT type="BUTTON" value="Save" id="savebutton" ONCLICK="saveFile()">
- <INPUT type="BUTTON" value="Save as" id="savebutton" ONCLICK="saveDialog()">
+ <INPUT type="BUTTON" value="Save as" id="saveasbutton" ONCLICK="saveDialog()">
<INPUT type="BUTTON" value="Commit" id="commitbutton" ONCLICK="commitAll()"></p>
<!-- <INPUT type="BUTTON" value="show sequent" id="showseq" ONCLICK="showSequent()">
<INPUT type="BUTTON" value="hide sequent" id="hideseq" ONCLICK="hideSequent()">
{
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");
}
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"); }