Handling of login/logout. Still missing iPhone layout on login page.
authorDennis Schafroth <dennis@indexdata.com>
Wed, 9 Jun 2010 15:18:00 +0000 (17:18 +0200)
committerDennis Schafroth <dennis@indexdata.com>
Wed, 9 Jun 2010 15:18:00 +0000 (17:18 +0200)
www/iphone/example_client.js
www/iphone/index.html

index a131b8a..d9b9fed 100644 (file)
@@ -40,9 +40,43 @@ var SubjectMax = 10;
 var AuthorMax = 10;
 var tab = "recordview"; 
 
+function loggedOut() {
+    var login = document.getElementById("login");
+    login.innerHTML = 'Login';
+}
+
+function loggingOutFailed() {
+    alert("Logging out failed");
+}
+
+function login() {
+    window.location = "login.html";
+}
+
+function logout() {
+    auth.logOut(loggedOut, loggingOutFailed, false);
+}
+
+function logInOrOut() {
+    var loginElement = document.getElementById("login");
+    if (loginElement.innerHTML == 'Login')
+       login();
+    else
+       logout();
+}
+function loggedIn() {
+    var login = document.getElementById("login");
+    login.innerHTML = 'Logout';
+    //    login.onclick = 'logout();';
+    domReady();
+}
+
+function auth_check() {
+    auth.check(loggedIn, login);
+}
 
 //
-// pz2.js event handlers:
+// Pz2.js event handlers:
 //
 function my_oninit() {
     my_paz.stat();
index b7837b8..3170ffd 100644 (file)
 <!-- 
   <meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
  -->  
+
        <script type="text/javascript" src="/mk2-ui-core/js/ui_bootstrap.js"></script>
        <script type="text/javascript" src="/mk2-ui-core/js/state.js"></script>
        <script type="text/javascript" src="/mk2-ui-core/js/recipe.js"></script>
        <script type="text/javascript" src="/mk2-ui-core/js/snippet.js"></script>
        <script type="text/javascript" src="/mk2-ui-core/js/auth.js"></script>        
-       <script type="text/javascript" src="/mk2-ui-core/js/torus.js"></script>
-<!-- 
-    <script type="text/javascript" src="/mk2-ui-core/js/client.js"></script>
+       <script type="text/javascript" src="/mk2-ui-core/js/torus.js"></script>
+<!--
+        <script type="text/javascript" src="/mk2-ui-core/js/client.js"></script>
 -->
+
     <script type="text/javascript" src="iphone.js" ></script>
     <script type="text/javascript" src="/pazpar2/js/pz2.js"></script>
     <script type="text/javascript" src="example_client.js"></script>
-
     <link rel="stylesheet" href="UiUIKit/stylesheets/iphone.css" />
     <link rel="apple-touch-icon" href="UiUIKit/stylesheets/images/apple-touch-icon.png" />
  </head>
  
- <body id="normal" onload="domReady();">
+ <body id="normal" onload="auth_check();">
     <div id="log" style="display: none;"></div>
   <div id="noscript">
     <noscript>
@@ -77,7 +79,7 @@
             <li><a href="javascript:showhide('xtargets')">Sources</a></li>
             <li><a href="javascript:showhide('subjects')">Subjects</a></li>
             <li><a href="javascript:showhide('authors')">Authors</a></li>
-            <li><a href="/login.html">Login</a></li>
+            <li><a href="#" onclick="logInOrOut(); return 0;" id="login">Login</a></li>
       </ul>
   </div>