From d8977eb0750590cb54b69b99afdce5c2cd8d2ae6 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Fri, 23 Dec 2011 10:52:01 +0100 Subject: [PATCH] Re-commit: move search to after successful login. Only alert on unhandled errors --- www/mobile/mobile_client.js | 91 ++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 53 deletions(-) diff --git a/www/mobile/mobile_client.js b/www/mobile/mobile_client.js index d024082..f7a0076 100644 --- a/www/mobile/mobile_client.js +++ b/www/mobile/mobile_client.js @@ -61,6 +61,17 @@ function checkOrientation() { } }; +function setQS (encodedParams) { + if ("onhashchange" in window) { + window.location.hash = '#' + encodedParams; + } else { + var url = document.location.href; + var i = url.indexOf("?"); + if (i > -1) url = url.substr(0, i); + document.location.href = url + "?" + encodedParams; + } +} + state.setRecPerPage(calcRecPerPage()); window.addEventListener("resize", checkOrientation, false); @@ -95,7 +106,6 @@ my_paz = new pz2( { "onshow": my_onshow, // pz2.js event handlers: // function my_onerror(error) { - alert("Unhandled error: " + error.code); switch(error.code) { // No targets! case "8": alert("No resources were selected for the search"); break; @@ -114,8 +124,8 @@ function my_onerror(error) { auth.check(loggedIn, login); break; default: - alert("Unhandled error: " + error.code); - throw error; // display error in JavaScript console + alert("Unhandled error: " + error.code); + throw error; // display error in JavaScript console } } @@ -192,11 +202,14 @@ function logInOrOut() { else logout(); } -function loggedIn() { +function loggedIn(context) { + + if (context.ipAuth != true) { var login = document.getElementById("login"); login.innerHTML = 'Logout'; document.getElementById("log").innerHTML = login.innerHTML; - domReady(); + } + domReady(); } function auth_check() { @@ -204,48 +217,6 @@ function auth_check() { //domReady(); } - -function auth_check_item(methods) { - auth.check(itemMain, function () { window.location = "login.html" + window.location.search + "&page="+window.location.pathname;}, methods ); -} - -//when page loads -function itemMain() { - mk_showPage(); - if (auth.styleCss && document.getElementById("stylesheet")) { - document.getElementById("stylesheet").href = auth.styleCss; - } - - // parse HTTP GET params (!!!) - window.location.parameters = parseQueryString(window.location.search); - var params = window.location.parameters; - // query params used by optional record_facets.js - if (window.RecordFacets != undefined) { - this.recordFacets = new RecordFacets(); - this.recordFacets.setRequestParams(params); - } - prefixRecId = params["prefixrecid"]; - query_state = params["query_state"]; - recQuery = params["recordquery"]; - // load templating components -/* - loadComponents(); - renderComponent("authLogoComp", auth); - renderComponent("authInfoComp", auth); - renderComponent("infoComp",null); - renderComponent("backToSearchComp",query_state); -*/ - my_paz = new pz2( {"pazpar2path": auth.servicePath, - "usesessions" : usesessions, - "errorhandler" : my_onerror, - "onrecord" : my_onrecord - }); - - // http params have highest priority - showDetails(prefixRecId,recQuery); -} - - // // Pz2.js event handlers: // @@ -481,10 +452,17 @@ function my_onterm(data) { termlists.push('

Subjects

'); termlists.push(''); termlists.push(''); @@ -492,13 +470,20 @@ function my_onterm(data) { termlists.push('

Authors

'); termlists.push(''); termlists.push(''); var termlist = document.getElementById("termlist"); @@ -896,7 +881,7 @@ function pagerPrev() { displayLoading(); state.curPage--; if (state.curPage <= 0) - throw "Zeo or negative current page"; + throw "Zero or negative current page"; } } -- 1.7.10.4