/****************************************************************************************** * * bzw2h.js * * Karthick Balasundaram * * BlueZone Software * ****************************************************************************************** * * This file contains various JavaScript functions needed to enhance BlueZone Web-to-Host. * ****************************************************************************************** * * April 2016 * */ function getBrowserType() { var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("chrome") > 0) { return "chrome"; } else if (ua.indexOf("firefox") > 0) { return "firefox"; } else { return "ie"; } } function checkOSType() { sPlatform = navigator.appVersion.toUpperCase(); sPlatform = ( sPlatform.indexOf("WIN") >= 0 ) ? "WIN" : ( sPlatform.indexOf("MAC") >= 0 ) ? "MAC" : "OTHER"; if ( sPlatform == "OTHER" || sPlatform == "MAC") { $("#main_container").hide(); $("#non_windows_os").show(); } else { $("#main_container").show(); $("#non_windows_os").hide(); } } function autoCloseBrowser() { // this JavaScript works for IE, Safari and Chrome, but not FireFox. window.open('','_self',''); window.close(); } function getFileAsString(url, callback) { //var jqxhr = $.get(url, callback).fail(callback) var jqxhr = $.ajax(url) .done(callback) .fail(callback) .always(console.log("Bz.getFileAsString.url="+url)); } function stripUrlToLastSlash(url) { var idx = url.lastIndexOf("/"); if (idx==-1) return url; return url.substring(0,idx); } function getUrlParameter(href_url, parameterName){ /* var results = new RegExp('[\?&]' + parameterName + '=([^]*)').exec(href_url); if (results==null) { return null; } else { return results[1] || 0; } */ var results = false; var vars = {}; if (href_url.indexOf(parameterName) > -1) { var parts = href_url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); results = vars[parameterName]; } return results; } function checkIfSessionExpired(data) { var isSessionExpired; if ((typeof data == 'object') || (typeof data == 'undefined')) { //alert(data.status + ', ' + data.statusText); //if(data.statusText != '') alert(data.statusText); isSessionExpired = true; } else if (typeof data == 'string') { isSessionExpired = (data.indexOf("SiteMinder") > 0) && (data.indexOf("Login") > 0); // Looks for the SiteMinder LoginScreen } else { isSessionExpired = false; } return isSessionExpired; } function parseHostUrl() { var url = window.location.href; var host = window.location.hostname; var idxHost = url.indexOf(host); if (idxHost==-1) return null; var idxHostEnd = idxHost + host.length; var idxHostSlash = url.indexOf("/", idxHostEnd); if (idxHostSlash==-1) return null; if (url.length>idxHostSlash) { var hostUrl = url.substring(0,idxHostSlash); return hostUrl; } else { return url; } }