function GlobalScope() { this.performers = null; this.blockedWords = []; this.bangkokVideosInstance = null; this.nextGirlOnlineDate = null; this.creditOptions = []; this.serverClientData = null; this.numberDigits = null; this.sId = ""; this.countryCode = ""; this.creditsPerPrivateMessage = 0; this.currencyName = ""; this.providerId = null; this.getPerformerUrl = window.globalConstant.getPerformerUrl; this.getPerformerListUrl = window.globalConstant.getPerformerListUrl; this.reportErrorUrl = window.globalConstant.reportErrorUrl; this.rteServer = window.globalConstant.rteServer; this.imageServer = window.globalConstant.imageServer; this.originApp = window.globalConstant.originApp; this.streamHost = window.globalConstant.streamHost; this.clubUrl = window.globalConstant.clubUrl; this.redirectToPerformer = window.globalConstant.redirectToPerformer; this.language = window.globalConstant.language; this.termsUrl = window.globalConstant.termsUrl; this.cancelUrl = window.globalConstant.cancelUrl; this.canUseCredits = window.globalConstant.canUseCredits; this.getBangkokVideoInstance = function () { if (this.bangkokVideosInstance == null) { this.bangkokVideosInstance = new BangkokVideos({ debugMode: true }); } return this.bangkokVideosInstance; } this.setModel = function (model) { this.performers = model.Performers; this.blockedWords = model.BlockedWords; this.nextGirlOnlineDate = model.NextOnlineGirlDate; this.creditOptions = model.CreditOptions; this.clientId = model.ClientId; this.serverClientData = model.ClientData || {}; this.sendEmail = model.Provider.SendEmail; this.numberDigits = model.Provider.PhoneNumberDigits; this.sId = model.SenderId; this.countryCode = model.Provider.CountryCode; this.creditsPerPrivateMessage = model.Provider.CreditsPerPrivateMessage; this.currencyName = model.Provider.CurrencyName; this.providerId = model.Provider.ID; this.language = model.Provider.Language; this.canUseCredits = model.Provider.CanBuyCredits; if (window.location.href.indexOf("feelingLucky") > 0 && this.performers.length > 0) { for (var i = 0; i < this.performers.length; i++) { if (this.performers[i].IsOnline) { this.redirectToPerformer = this.performers[i].StageName; return; } } this.redirectToPerformer = this.performers[Math.floor((Math.random() * this.performers.length))].StageName; } } this.getPerformers = function () { return this.performers; } this.findPerformerLocal = function (performerName) { try { for (var i = 0; i < this.performers.length; i++) { if (this.performers[i].StageName == performerName) { return this.performers[i]; } } } catch (err) { throw new Error(err.message + " at GlobalScope > findPerformerLocal"); } return null; } this.clearVideos = function () { if (this.bangkokVideosInstance != null) { try { for (var i = 0; i < this.bangkokVideosInstance.videos.length; i++) { if (this.bangkokVideosInstance.videos[i].jpgStreamerObject != null) { this.bangkokVideosInstance.videos[i].jpgStreamerObject.close(); } this.bangkokVideosInstance.videos.splice(i, 1); } } catch (err) { throw new Error(err.message + " at GlobalScope > clearVideos"); } } } this.reportError = function (message, cause) { $.ajax({ url: globalScope.reportErrorUrl + '?message=' + message + "&cause=" + cause, type: 'POST' }).fail(function (data) { console.log("fail: " + data); }); } this.AnalyticsEvents = { qualitySet: function (quality) { ga('send', { 'hitType': 'event', 'eventCategory': 'qualitySet', 'eventAction': 'click', 'eventLabel': quality, 'eventValue': 1 }); }, pageViewed: function (path) { ga('send', 'pageview', { page: path }); } } this.hideKeyboard = function () { setTimeout(function () { var field = document.createElement('input'); field.setAttribute('type', 'text'); field.setAttribute('style', 'position:absolute; top: 0px; opacity: 0; -webkit-user-modify: read-write-plaintext-only; left:0px;'); document.body.appendChild(field); field.onfocus = function () { setTimeout(function () { field.setAttribute('style', 'display:none;'); setTimeout(function () { document.body.removeChild(field); document.body.focus(); }, 14); }, 200); }; field.focus(); }, 50); } this.generateGuid = function () { var d = new Date().getTime(); var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); return uuid; }; } var globalScope = new GlobalScope();