From d955c1f956d98dff3ad66d7a4a82e6a0af6cca64 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Thu, 24 Jun 2010 16:12:38 +0200 Subject: [PATCH] Add test of native JSON. Remove unused serialize() --- www/iphone/example_client.js | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/www/iphone/example_client.js b/www/iphone/example_client.js index 6eebbf6..b24561f 100644 --- a/www/iphone/example_client.js +++ b/www/iphone/example_client.js @@ -12,9 +12,12 @@ 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'; } +if (this.JSON ) + alert("Native JSON support"); + my_paz = new pz2( { "onshow": my_onshow, "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way "pazpar2path": pazpar2path, @@ -86,19 +89,18 @@ 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(); } function auth_check() { auth.check(loggedIn, login, true); + domReady(); } // @@ -246,27 +248,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); -- 1.7.10.4