X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=www%2Fmobile%2Fmobile_client.js;h=f7a0076960ba50d046a5d771742e3f0542378613;hb=fb19bc317370b4f4b508088b034b4c2d19257042;hp=640b4066e7606976ff35c5d5b6f96deeefbd1dfa;hpb=71e0517c631e2a2b00eac64ad8291fc5c316b604;p=pazpar2-moved-to-github.git diff --git a/www/mobile/mobile_client.js b/www/mobile/mobile_client.js index 640b406..f7a0076 100644 --- a/www/mobile/mobile_client.js +++ b/www/mobile/mobile_client.js @@ -35,7 +35,7 @@ var tab = "recordview"; var triedPass = ""; var triedUser = ""; -var previousOrientation = 0; +var previousOrientation = window.orientation || 0; window.addEventListener("load",function() { @@ -47,27 +47,38 @@ window.addEventListener("load",function() { }); function calcRecPerPage() { - state.recPerPage = 5; state.width = window.innerWidth; state.height = window.innerHeight; - state.recPerPage = Math.max(Math.round((state.height - 88 - 40) / 60), 5) ; - + return Math.max(Math.round((state.height - 88 - 40) / 60), 5) ; } function checkOrientation() { - if(window.orientation && window.orientation !== previousOrientation){ - previousOrientation = window.orientation; - calcRecPerPage(); + if(state.height != window.innerHeight){ + var newPageSize = calcRecPerPage(); + //alert("orient change: Dimension " + state.width + " " + state.height + " Old Rec/page " + state.recPerPage + " New: " + newPageSize); + state.setRecPerPage(newPageSize); + my_paz.show(state.getStartWith(), state.getRecPerPage(), curSort); } }; -calcRecPerPage(); +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); window.addEventListener("orientationchange", checkOrientation, false); // (optional) Android doesn't always fire orientationChange on 180 degree turns -setInterval(checkOrientation, 2000); +//setInterval(checkOrientation, 2000); var imageHelper = new ImageHelper(); @@ -113,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 } } @@ -191,59 +202,21 @@ 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(); } function auth_check() { auth.check(loggedIn, login); - 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); + //domReady(); } - // // Pz2.js event handlers: // @@ -479,10 +452,17 @@ function my_onterm(data) { termlists.push('

Subjects

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

Authors

'); termlists.push(''); termlists.push(''); var termlist = document.getElementById("termlist"); @@ -894,7 +881,7 @@ function pagerPrev() { displayLoading(); state.curPage--; if (state.curPage <= 0) - throw "Zeo or negative current page"; + throw "Zero or negative current page"; } } @@ -946,7 +933,7 @@ function showDetails (prefixRecId) { } // request the record displayLoading() - my_paz.record_with_query(recId); + my_paz.record_with_query(recId, state.simpleQuery); } function replaceHtml(el, html) {