]> matita.cs.unibo.it Git - helm.git/commitdiff
File uploading
authormatitaweb <claudio.sacerdoticoen@unibo.it>
Fri, 16 Sep 2011 13:18:56 +0000 (13:18 +0000)
committermatitaweb <claudio.sacerdoticoen@unibo.it>
Fri, 16 Sep 2011 13:18:56 +0000 (13:18 +0000)
matitaB/matita/index.html
matitaB/matita/matitaweb.css
matitaB/matita/matitaweb.js

index e665bede62fd371ad0471f30a1560e2b4c2e2df6..14027f7f2670ba5ff1eae7b58a1c9ad8bad18eb0 100644 (file)
 </head>
 
 <body onLoad="initialize();">
+<textarea id="unescape" style="display:none;"></textarea>
 <div id="sandbox" style="visibility:hidden;"></div>
 
 <div class="matitaapparea">
 
 <div class="toparea">
-<div class="toolbar">
-       <textarea id="unescape" style="display:none;"></textarea>
-       <p><A href="javascript:advanceForm1()"><IMG src="icons/advance.png" 
+<div class="navibar">
+           <A href="javascript:advanceForm1()"><IMG class="topimg" src="icons/advance.png" 
                                                     id="advance" alt="Advance" 
                                                     title="Execute one step of the script."></A>
-          <A href="javascript:retract()"><IMG src="icons/retract.png" 
+          <A href="javascript:retract()"><IMG class="topimg" src="icons/retract.png" 
                                               id="retract" alt="Retract"
                                                title="Undo execution of one step of the script."></A>
-          <A href="javascript:gotoPos()"><IMG src="icons/position.png" 
+          <A href="javascript:gotoPos()"><IMG class="topimg" src="icons/position.png" 
                                                id="cursor" alt="Play"
                                                title="Execute the script until the current position of the cursor."></A>
-          <A href="javascript:gotoBottom()"><IMG src="icons/bottom.png" 
+          <A href="javascript:gotoBottom()"><IMG class="topimg" 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()">
+</div>
+<div class="toolbar">
+          <INPUT type="BUTTON" value="New" id="newbutton" ONCLICK="newDialog()">
+          <INPUT type="BUTTON" value="Open" id="showdialog" ONCLICK="openDialog()">
           <INPUT type="BUTTON" value="Save" id="savebutton" ONCLICK="saveFile()">
           <INPUT type="BUTTON" value="Save as" id="saveasbutton" ONCLICK="saveDialog()">
-          <INPUT type="BUTTON" value="Commit" id="commitbutton" ONCLICK="commitAll()"></p>
+          <INPUT type="BUTTON" value="Upload" id="uploadbutton" ONCLICK="uploadDialog()">
+           <INPUT type="BUTTON" value="Commit" id="commitbutton" ONCLICK="commitAll()">
 <!--      <INPUT type="BUTTON" value="show sequent" id="showseq" ONCLICK="showSequent()">
           <INPUT type="BUTTON" value="hide sequent" id="hideseq" ONCLICK="hideSequent()">
           <INPUT type="BUTTON" value="selection test" id="hideseq" ONCLICK="test()"> -->
 
 </div>
-<div class="caption"><img src="icons/matita-text.png"></div>
+<div class="caption"><p><img align="bottom" class="topimg" src="icons/matita-text.png"></p></div>
 </div>
 
 <div class="workarea" id="workarea">
@@ -59,6 +62,7 @@
   <pre id="goalview"></pre>
   </div>
 </div>
+</div>
 
 <div class="bottomarea">
        <textarea id="logarea" style="width:100%; height:100%"></textarea>
 
 <div class="dialog" id="dialogBox" style="display: none;">
   <div class="diaTitle" id="dialogTitle"></div>
+  <div class="diaClose" id="dialogClose"><H2><A id="butClose" href="javascript:abortDialog()">X</A></H2></div>
   <div class="scroll" id="dialogContent"></div>
   <INPUT class="diaFile" type="text" id="dialogFilename">
   <INPUT type="button" id="dialogSelect" value="OK" ONCLICK="dialogOK()" style="width:70px">
 </div>
+
+<div class="upload" id="uploadBox" style="display: none;">
+  <div class="dialogTitle" id="uploadTitle"></div>
+  <div class="diaClose" id="uploadClose"><H2><A id="but1Close" href="javascript:abortUpload()">X</A></H2></div>
+  <INPUT class="diaFile" type="file" id="uploadFilename">
+  <INPUT type="button" id="uploadSelect" value="OK" ONCLICK="uploadOK()" style="width:70px">
+</div>
+
  </body>
  </html> 
index e11f7a967921e7493bd6b5f38eb7467ce0b826b7..b75aaf301cd9f7f514d54d0d54484b91d7a35c1e 100644 (file)
@@ -1,9 +1,23 @@
+div.upload {
+       position:absolute;
+       top: 50%;
+       left: 50%;
+       width:450px;
+       height:50px;
+       margin-top: -250px; /*set to a negative number 1/2 of your height*/
+       margin-left: -225px; /*set to a negative number 1/2 of your width*/
+       border: 1px solid #ccc;
+       padding: 3px;
+       background-color: #f3f3f3;
+}
+
+
 div.dialog {
        position:absolute;
        top: 50%;
        left: 50%;
        width:450px;
-       height:i500px;
+       height:500px;
        margin-top: -250px; /*set to a negative number 1/2 of your height*/
        margin-left: -225px; /*set to a negative number 1/2 of your width*/
        border: 1px solid #ccc;
@@ -13,11 +27,30 @@ div.dialog {
 
 div.diaTitle {
        display: block;
-       margin-left: auto;
+       margin-left: 3px;
        margin-right: auto;
-       width: 444px;
+       width: 414px;
        background-color: #007fff;
        color: white;
+        float: left;
+        line-height: 32px;
+}
+
+div.diaClose {
+       display: block;
+       margin-left: auto;
+       margin-right: 3px;
+        background-color: red;
+       width: 30px;
+       color: white;
+        float: right;
+        text-align: center;
+        vertical-align: middle;
+        line-height: 32px
+}
+
+a#butClose {
+  color: inherit;
 }
 
 input.diaFile {
@@ -42,7 +75,7 @@ div.matitaapparea {
        display: block;
        margin-left: auto;
        margin-right: auto;
-       height:100%; 
+       height:100%;
        width:100%; 
        background-color: white;
        color:black;
@@ -52,8 +85,10 @@ div.toparea {
        display: block;
        margin-left: auto;
        margin-right: auto;
-       height:15%
+       height:64px
        width:100%; 
+        line-height:64px;
+/*        float:left;*/
 }
 
 div.bottomarea {
@@ -72,37 +107,56 @@ div.workarea {
        width:100%; 
 }
 
+div.navibar {
+       display: inline-block;
+       margin-left: auto;
+       margin-right: auto;
+       height:100%; 
+       width:33%; 
+       float:left; 
+}
+
 div.toolbar {
-       display: inline;
+       display: inline-block;
        margin-left: auto;
        margin-right: auto;
        height:100%; 
-       width:67%; 
+       width:33%;
+        float:left; 
 }
 
 div.caption {
-       display: inline;
+       display: inline-block;
        margin-left: auto;
        margin-right: auto;
        height:100%; 
-       width:33%; 
+       width:34%; 
        text-align: center;
+        float:right; 
+}
+
+img.topimg {
+       bottom:0px;
 }
 
 div.scriptarea {
-       display: inline;
+       display: inline-block;
        margin-left: auto;
        margin-right: auto;
        height:100%; 
-       width:67%; 
+       width:100%;
+        min-width:67%;
+        float:left;
 }
 
 div.goalarea {
-       display: inline;
+       display: inline-block;
        margin-left: auto;
        margin-right: auto;
        height:100%; 
-       width:33%; 
+       width:33%;
+        min-width:33%; 
+        float:right;
 }
 
 
index ec19562b248e819a0ab1bb3fb25e35aa59c318d1..837c687cb9385dc22af1948d924a041deb6b997e 100644 (file)
@@ -685,6 +685,36 @@ function showLibrary(title,callback)
   
 }
 
+function uploadDialog()
+{  
+        uploadBox.style.display = "block";
+}
+
+function uploadOK()
+{   
+   var file = document.getElementById("uploadFilename").files[0];
+   if (file) { 
+       var filecontent = file.getAsText("UTF-8");
+       locked.innerHTML = lockedbackup;
+       unlocked.innerHTML = filecontent;
+       uploadBox.style.display = "none";
+   }
+//   if (file) { 
+//      var reader = new FileReader();
+//      reader.readAsText(file, "UTF-8");
+//       reader.onloadend = function (evt) {
+//        lockedbackup = "";
+//           locked.innerHTML = lockedbackup
+//           unlocked.innerHTML = evt.target.result;
+//           uploadBox.style.display = "none";
+//       }
+//       reader.onerror = function (evt) {
+//        debug("file open failed");
+//           uploadBox.style.display = "none";
+//      }
+//   }
+}
+
 function openDialog()
 {  
        callback = function (fname) { retrieveFile(fname); };
@@ -707,15 +737,15 @@ function newDialog()
 {
        callback = function (fname) { 
          dialogBox.style.display = "none";
-         saveFile(fname,"","",false,newDialog);
-          retrieveFile(fname);
+         saveFile(fname,"","",false,newDialog,true);
        };
        showLibrary("Create new file", callback);
 }
 
 
-function saveFile(fname,lockedtxt,unlockedtxt,force,reloadDialog)
+function saveFile(fname,lockedtxt,unlockedtxt,force,reloadDialog,reloadFile)
 {
+        if (!is_defined(reloadFile)) { reloadFile = true };
         if (!is_defined(fname)) {
             fname = current_fname;
            lockedtxt = (locked.innerHTML.html_to_matita()).sescape();
@@ -727,13 +757,14 @@ function saveFile(fname,lockedtxt,unlockedtxt,force,reloadDialog)
                if (is_defined(xml)) {
                  if (xml.childNodes[0].textContent != "ok") {
                     if (confirm("File already exists. All existing data will be lost.\nDo you want to proceed anyway?")) {
-                       saveFile(fname,lockedtxt,unlockedtxt,true);
+                       saveFile(fname,lockedtxt,unlockedtxt,true,reloadDialog,reloadFile);
                    } else {
                       reloadDialog();
                    }
                  } else {
                    current_fname = fname;
                    debug("file saved!");
+                    if (reloadFile) { retrieveFile(fname); }
                  }
                } else {
                        debug("save file failed");
@@ -767,20 +798,32 @@ function commitAll()
 var goalcell;
 
 function hideSequent() {
-  goalcell.parentNode.removeChild(goalcell);
-  scriptcell.setAttribute("colspan","2");
+  goalcell.style.display = "none";
+  scriptcell.style.width = "100%";
+  scriptcell.style.minWidth = "100%";
+  scriptcell.style.maxWidth = "100%";
 }
 
 function showSequent() {
-  scriptcell.setAttribute("colspan","1");
-  workarea.appendChild(goalcell);
+  scriptcell.style.width = "67%";
+  scriptcell.style.minWidth = "67%";
+  scriptcell.style.maxWidth = "67%";
+  goalcell.style.display = "inline-block";
 }
 
 function showDialog(title,content,callback) {
   dialogTitle.innerHTML = title;
   dialogContent.innerHTML = content;
-  dialogBox.style.display = "block";
   dialogBox.callback = callback;
+  dialogBox.style.display = "block";
+}
+
+function abortDialog() {
+  dialogBox.style.display = "none";
+}
+
+function abortUpload() {
+  uploadBox.style.display = "none";
 }
 
 function removeElement(id) {