/** * Created by kelvintam on 22/11/2016. */ // Helper Library (function(helper) { // This is now a utility function to "Get the Document Hash" helper.getDocumentHash = function (urlString) { var hashValue = ""; if (urlString.indexOf('?') != -1) { hashValue = urlString.substring(parseInt(urlString.indexOf('?')) + 1); } return hashValue; }; })(this.helper = this.helper || {}); function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } function isFacebookApp() { var ua = navigator.userAgent || navigator.vendor || window.opera; return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1); } function isAndroid(){ var ua = navigator.userAgent.toLowerCase(); var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); if(isAndroid) { return true; } return false; } function isChrome(){ var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); return isChrome; } function isFireFox(){ var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; return is_firefox; } function isAndroidNativeBrowser(){ var navU = navigator.userAgent; // Android Mobile var isAndroidMobile = navU.indexOf('Android') > -1 && navU.indexOf('Mozilla/5.0') > -1 && navU.indexOf('AppleWebKit') > -1; // Apple webkit var regExAppleWebKit = new RegExp(/AppleWebKit\/([\d.]+)/); var resultAppleWebKitRegEx = regExAppleWebKit.exec(navU); var appleWebKitVersion = (resultAppleWebKitRegEx === null ? null : parseFloat(regExAppleWebKit.exec(navU)[1])); // Chrome var regExChrome = new RegExp(/Chrome\/([\d.]+)/); var resultChromeRegEx = regExChrome.exec(navU); var chromeVersion = (resultChromeRegEx === null ? null : parseFloat(regExChrome.exec(navU)[1])); // Native Android Browser var isAndroidBrowser = isAndroidMobile && !isFireFox() && (appleWebKitVersion !== null && appleWebKitVersion < 537) || (chromeVersion !== null && chromeVersion < 38.1); return isAndroidBrowser; } var iOS = parseFloat( ('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1]) .replace('undefined', '3_2').replace('_', '.').replace('_', '') ) || false;