diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Helpers.js b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Helpers.js index 1a5df4b..dd19e67 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Helpers.js +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Helpers.js @@ -32,4 +32,57 @@ } return url; }; + self.goToMenuOption = function(page) { + location.hash = page; + console.log("goToMenuOption: " + page); + }; + self.processRequestFailure = function(xmlHttpRequest, textStatus, errorThrown) { + if (xmlHttpRequest.readyState === 4) { + return { + errorCode: xmlHttpRequest.status, + errorMessage: xmlHttpRequest.statusText, + errorSource: "" + }; + } + else if (xmlHttpRequest.readyState === 0) { + return { + errorCode: xmlHttpRequest.status, + errorMessage: "Network Error - Is the server available?", + errorSource: "" + }; + } + else { + return { + errorCode: xmlHttpRequest.status, + errorMessage: "Unknown Error", + errorSource: "" + }; + } + } + /** + * Function to redirect to a page in the sammy.js eco system. + * Relies on "pagedestination" tag in the html. This is a button click handler. + * @param {Object} data - dunno? + * @param {Object} event - handle to the button that was clicked. + * @returns {nothing} - redirects to the url referenced by the pageDestination tag. + */ + self.getPageDestination = function(data, event) { + var target = null; + if (event.target) target = event.target; + else if (event.srcElement) target = event.srcElement; + var destination = ""; + if (target != null) { + for (var i = 0; i < target.attributes.length; i++) { + if (target.attributes[i].nodeName === "pagedestination") { + destination = target.attributes[i].value; + break; + } + } + if (destination !== "") { + return destination; + } + } else { + console.log("target is null, going nowhere"); + } + }; }; \ No newline at end of file