var triedPass = "";
var triedUser = "";
-var previousOrientation = 0;
+var previousOrientation = window.orientation || 0;
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();
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
}
}
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:
//
termlists.push('<h4>Subjects</h4>');
termlists.push('<ul class="termlist">');
termlists.push('<li><a href="#" target_id="reset_su" onclick="limitOrResetQuery(\'reset_su\',\'All\');return false;">All</a></li>');
- for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) {
- termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'su\', \'' + data.subject[i].name + '\');return false;">'
- + data.subject[i].name + ' (' + data.subject[i].freq + ')</a></li>');
+ if (data.subject) {
+ for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) {
+ termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'su\', \'' + data.subject[i].name + '\');return false;">'
+ + data.subject[i].name + ' (' + data.subject[i].freq + ')</a></li>');
+ }
}
+ else {
+ throw "Missing subject termlist: " + data;
+ return;
+ }
+
termlists.push('</ul>');
termlists.push('</div>');
termlists.push('<h4 class="termtitle">Authors</h4>');
termlists.push('<ul class="termlist">');
termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'reset_au\',\'All\');return false;">All</a></li>');
- for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) {
- termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'au\', \'' + data.author[i].name +'\');return false;">'
+ if (data.author) {
+ for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) {
+ termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'au\', \'' + data.author[i].name +'\');return false;">'
+ data.author[i].name
+ ' ('
+ data.author[i].freq
+ ')</a></li>');
+ }
}
+ else {
+ throw "Missing author termlist: " + data;
+ return;
+ }
+
termlists.push('</ul>');
termlists.push('</div>');
var termlist = document.getElementById("termlist");
displayLoading();
state.curPage--;
if (state.curPage <= 0)
- throw "Zeo or negative current page";
+ throw "Zero or negative current page";
}
}
}
// request the record
displayLoading()
- my_paz.record_with_query(recId);
+ my_paz.record_with_query(recId, state.simpleQuery);
}
function replaceHtml(el, html) {