]> matita.cs.unibo.it Git - helm.git/commitdiff
Matitaweb: New File functionality.
authorWilmer Ricciotti <ricciott@cs.unibo.it>
Thu, 8 Sep 2011 15:07:01 +0000 (15:07 +0000)
committerWilmer Ricciotti <ricciott@cs.unibo.it>
Thu, 8 Sep 2011 15:07:01 +0000 (15:07 +0000)
matitaB/matita/index.html
matitaB/matita/matitaweb.js

index e16fe6d15b4d4f42e9df0e01bc8d2b1733d6c8df..cdb2834773853d89c320df91d97bb07c56f3619d 100644 (file)
                                                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()">
index 48acfe13e223a0118b03b5d96ddc7b1a36250513..fc90080d255a16cd18ed359ef624a2f8e8e83046 100644 (file)
@@ -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"); }