]> matita.cs.unibo.it Git - helm.git/blobdiff - matitaB/matita/matitaweb.js
Remove the daemon :-)
[helm.git] / matitaB / matita / matitaweb.js
index d4dbe63e80c6f07616177aa3e046c4969452fb29..423eda674bbd1ed06c54d379dd65e56b5fb78f24 100644 (file)
@@ -15,27 +15,32 @@ var metasenv = "";
 
 function initialize()
 {
-  locked = document.getElementById("locked");
-  unlocked = document.getElementById("unlocked");
-  workarea = document.getElementById("workarea");
-  scriptcell = document.getElementById("scriptcell");
-  goalcell = document.getElementById("goalcell");
-  goals = document.getElementById("goals");
-  goalview = document.getElementById("goalview");
-  filename = document.getElementById("filename");
-  logarea = document.getElementById("logarea");
-  advanceButton = document.getElementById("advance");
-  retractButton = document.getElementById("retract");
-  cursorButton = document.getElementById("cursor");
-  bottomButton = document.getElementById("bottom");
-
-  // hide sequent view at start
-  hideSequent();
+  if (readCookie("session") == null) {
+    window.location = "/login.html"
+  } else {
+    locked = document.getElementById("locked");
+    unlocked = document.getElementById("unlocked");
+    workarea = document.getElementById("workarea");
+    scriptcell = document.getElementById("scriptcell");
+    goalcell = document.getElementById("goalcell");
+    goals = document.getElementById("goals");
+    goalview = document.getElementById("goalview");
+    filename = document.getElementById("filename");
+    logarea = document.getElementById("logarea");
+    advanceButton = document.getElementById("advance");
+    retractButton = document.getElementById("retract");
+    cursorButton = document.getElementById("cursor");
+    bottomButton = document.getElementById("bottom");
+  
+    // hide sequent view at start
+    hideSequent();
+  }
 }
 
 function debug(txt)
 {
-        logarea.innerHTML = txt + "\n" + logarea.innerHTML;
+        // internet explorer (v.9) doesn't work with innerHTML
+        logarea.innerText = txt + "\n" + logarea.innerText;
 }
 
 function listhd(l)
@@ -498,3 +503,26 @@ function findNode(list, node, acc) {
 function test () {
   debug("cursor test: " + unlocked.innerHTML.substr(0,getCursorPos()));
 }
+
+function readCookie(name) {
+       var nameEQ = name + "=";
+       var ca = document.cookie.split(';');
+       for(var i=0;i < ca.length;i++) {
+               var c = ca[i];
+               while (c.charAt(0)==' ') c = c.substring(1,c.length);
+               if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
+       }
+       return null;
+}
+
+function delete_cookie ( cookie_name )
+{
+  var cookie_date = new Date();  // current date & time
+  cookie_date.setTime ( cookie_date.getTime() - 1 );
+  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
+}
+
+function delete_session()
+{
+       delete_cookie("session");
+}