]> matita.cs.unibo.it Git - helm.git/blobdiff - matitaB/matita/matitaweb.js
Multi-user Matita (and Matitaweb): added user authentication (currently only
[helm.git] / matitaB / matita / matitaweb.js
index 8f77fe4f8d2eec714805d2afc63067b99a77c76e..0c661623bc148fe1f8614b3bb8c63b0401ae6059 100644 (file)
@@ -15,22 +15,26 @@ 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)
@@ -499,3 +503,14 @@ 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;
+}