}\r
}\r
\r
-// Listens for browser initiated changes to 'window.location.hash' and sends the\r
-// hash\r
-// changes to the back-end (to have the back-end pull up a previous Pazpar2\r
-// state)\r
+// Listens for browser initiated changes to 'window.location.hash' and sends \r
+// the hash key changes to the back-end, to have the back-end pull up a previous \r
+// Pazpar2 state.\r
+// \r
+// See also: The field in pz2watch.xhtml, the StateListener function below,\r
+// the method Pz2Bean.handleQueryStateChanges(), and the classes \r
+// Pazpar2State and StateManager for a complete picture of browser history \r
+// handling.\r
function windowlocationhashListener() {\r
if (trackHistory) {\r
- // console.log("browser hash update detected");\r
+ \r
var stateKey = document.getElementById("pz2watch:windowlocationhash");\r
- if (window.location.hash != stateKey.value) {\r
- // console.log("updating stateKey with new browser hash: " +\r
- // window.location.hash);\r
- stateKey.value = window.location.hash;\r
- if (!stateKey.value)\r
- window.location.hash = '#1';\r
- stateKey.onchange();\r
+ // console.log("browser hash update response detected.");\r
+ // console.log("pz2watch:windowlocationhash: [" + stateKey.value + "]");\r
+ // console.log("window.location.hash: [" + window.location.hash + "]");\r
+ if (window.location.hash != stateKey.value) { \r
+ if (window.location.hash) {\r
+ //console.log("updating pz2watch:windowlocationhash with new window.location.hash [" + window.location.hash + "]");\r
+ stateKey.value = window.location.hash;\r
+ //console.log("firing pz2watch:windowlocationhash onChange");\r
+ stateKey.onchange();\r
+ } else if (stateKey.value) {\r
+ //console.log("updating window.location.hash with pz2watch:windowlocationhash [" + stateKey.value + "]");\r
+ window.location.hash = stateKey.value;\r
+ //console.log("firing pz2watch:windowlocationhash onChange");\r
+ stateKey.onchange();\r
+ } \r
} else {\r
- // console.log("State hash already has the value of the new browser hash -\r
- // not updating state hash");\r
+ //console.log("State hash already has the value of the new browser hash - not updating state hash");\r
}\r
}\r
}\r
if (data.source.name === "pz2watch:activeclientsField") {\r
alert("This occurred when polling: ["\r
+ data.description\r
- + "]. The page could be in an inconsistent state after this. We apologize for the inconvenience.");\r
+ + "].");\r
} else {\r
var pattern = /viewId.*could not be restored./;\r
if (pattern.test(data.description)) {\r
// ignore - caught by view expiration listener\r
} else {\r
alert("An error ["\r
- + data.description\r
+ + data.errorName + ": " +data.description\r
+ "] was triggered by ["\r
+ data.source.name\r
- + "]. The page could be in an inconsistent state after this. We apologize for the inconvenience.");\r
+ + "].");\r
}\r
}\r
}\r
this.invoke = function(field) {\r
var stateKeyDoc = StringtoXML(field.textContent || field.text);\r
var stateKeyValue = stateKeyDoc.childNodes[0].getAttribute("value");\r
- // console.log('Application hash update detected. New value: ' +\r
- // stateKeyValue);\r
+ // console.log('Received state key update from the back-end: ' + stateKeyValue);\r
if (stateKeyValue !== window.location.hash) {\r
window.location.hash = stateKeyValue;\r
- // console.log("Browsers hash updated accordingly.");\r
+ // console.log("Browsers hash (window.location.hash) updated with [" + stateKeyValue + "]");\r
} else {\r
- // console.log("Browsers hash already has the value of the state hash. Not\r
- // updating browser hash.");\r
+ // console.log("Browsers hash (window.location.hash) already has the value [" + stateKeyValue + "]");\r
}\r
};\r
};\r
this.invoke = function(field) {\r
var updateDoc = StringtoXML(field.textContent || field.text);\r
var activeClientsRecordValue = (updateDoc.childNodes[0].textContent || updateDoc.childNodes[0].text);\r
- console.log('Activeclients response for record detected: '\r
- + activeClientsRecordValue);\r
+ // console.log('Activeclients response for record detected: ' + activeClientsRecordValue);\r
clearTimeout(renderOnRecordTargetsReqVar);\r
if (activeClientsRecordValue > '0') {\r
renderOnRecordTargets(true);\r
} else {\r
- console.log('Active clients is 0, final rendering');\r
+ // console.log('Active clients is 0, final rendering');\r
renderOnRecordTargets(false);\r
}\r
};\r