Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/pazpar2
[pazpar2-moved-to-github.git] / www / iphone / example_client.js
index 6eebbf6..9761e83 100644 (file)
@@ -12,9 +12,10 @@ var querys = {'su': '', 'au': '', 'xt': ''};
 if (document.location.hash == '#useproxy' || document.location.search.match("useproxy=true")) {
     usesessions = false;
     pazpar2path = '/service-proxy/';
-    showResponseType = 'xml';
+    showResponseType = 'json';
 }
 
+
 my_paz = new pz2( { "onshow": my_onshow,
                     "showtime": 500,            //each timer (show, stat, term, bytarget) can be specified this way
                     "pazpar2path": pazpar2path,
@@ -86,19 +87,19 @@ function logout() {
 function logInOrOut() {
     var loginElement = document.getElementById("login");
     if (loginElement.innerHTML == 'Login')
-       login();
+       login();
     else
-       logout();
+       logout();
 }
 function loggedIn() {
     var login = document.getElementById("login");
-    login.innerHTML = 'Logout';
-    //    login.onclick = 'logout();';
-    domReady();
+    login.innerHTML = 'Logout(' + auth.displayName + ')';
+    document.getElementById("log").innerHTML = login.innerHTML;
 }
 
 function auth_check() {
     auth.check(loggedIn, login, true);
+    domReady();
 }
 
 //
@@ -246,27 +247,6 @@ function my_onterm(data) {
     showhide();
 }
 
-function serialize(array) {
-       var t = typeof (obj);
-       if (t != "object" || obj === null) {
-               // simple data type
-               return String(obj);
-       } else {
-               // recurse array or object
-               var n, v, json = [], arr = (obj && obj.constructor == Array);
-               for (n in obj) {
-                       v = obj[n];
-                       t = typeof (v);
-                       if (t == "string")
-                               v = '"' + v + '"';
-                       else if (t == "object" && v !== null)
-                               v = JSON.stringify(v);
-                       json.push((arr ? "" : '"' + n + '":') + String(v));
-               }
-               return (arr ? "" : "") + String(json) + (arr ? "]" : "}");
-       }
-}
-
 var termlist = {};
 function my_onterm_iphone(data) {
     my_onterm(data);
@@ -287,7 +267,6 @@ function my_onterm_iphone(data) {
         authors = authors + "au" + "|" + data.author[i].name + "|" + data.author[i].freq + "\n";
     }
     termlist["authors"] = authors;
-    //document.getElementById("log").innerHTML = targets + "\n" + subjects + "\n" + authors;
     callback.send("termlist", "refresh");
 }
 
@@ -641,7 +620,8 @@ function renderDetails_iphone(data, marker)
 {
        //return renderDetails(data,marker);
 
-
+    if (!data) 
+       return ""; 
     var details = '<div class="details" id="det_'+data.recid+'" >'
 /*
     details = '<div id="header" id="det_'+data.recid+'">'