var BASEURL='https://C.environment.playbridgedoctor.com/';////////////////////////////////////////////////////////////////////////////////
// Globals
////////////////////////////////////////////////////////////////////////////////
var ZERO = 0;
var ONE = 1;
var NOVALUE = -1;
// Variables for managing live game users display
var showLivePlayerAlerts = window.localStorage.getItem('showLivePlayerAlerts') === '1';
var lobbyUserList = [], waitingUserList = [], playingUserList = [];
var prevTotalLobby = [], prevTotalWaiting = [];
////////////////////////////////////////////////
//// multi-play vars
////////////////////////////////////////////////
var bHasMenu = true;
var iUserID = NOVALUE;
var userid; //this is used in the game, need to move it
var cookies = {
EmailAddress: "",
Pass: "",
Token: "",
Existing: ""
};
var myclient = NOVALUE;
var sPlayerName = "";
var sRole = "";
var role = 'royal'; //needed for game
var sBidSys = null;
var existing = !!PagesGetCookie('Existing') || null;
var sSlectedPage = "Main"; //
var sSelectedPage = "Main";
var mydomain = getUrlVars()["site"];
if (mydomain == undefined) {
mydomain = 'bridgedoctor';
}
if (typeof domain !== "undefined") {
if (domain == '_60secondbridge') {
mydomain = '_60secondbridge';
}
}
var sixtysecUser;
var sixtysecBidSys;
if (mydomain == '_60secondbridge') {
sixtysecUser = username;
sixtysecBidSys = getUrlVars()["bidsys"];
sixtysecGame = getUrlVars()["game"];
sixtysecVal = getUrlVars()["val"];
sixtysecType = getUrlVars()["type"];
}
// Load the firebase scripts and configure
// Using this custom method rather than $.getScript because it caches the file, making subsequent requests a lot faster
jQuery.cachedScript = function( url, options) {
// Allow user to set any option except for dataType, cache, and url
options = $.extend( options || {}, {
dataType: "script",
cache: true,
url: url
});
// Use $.ajax() since it is more flexible than $.getScript
// Return the jqXHR object so we can chain callbacks
return jQuery.ajax( options );
};
loadFirebase();
loadSweetAlert();
loadToastr();
// get variables from the url
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
vars[key] = value;
});
return vars;
}
////////////////////////////////////////////////////////////////////////////////
// onload
////////////////////////////////////////////////////////////////////////////////
jQuery(document).ready(function() {
function CheckBrowser() {
var ua = navigator.userAgent,
tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return {
name: 'IE',
version: (tem[1] || '')
};
}
if (M[1] === 'Chrome') {
tem = ua.match(/\bOPR\/(\d+)/)
if (tem != null) {
return {
name: 'Opera',
version: tem[1]
};
}
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) {
M.splice(1, 1, tem[1]);
}
return {
name: M[0],
version: M[1]
};
}
var b = CheckBrowser();
if (mydomain == '_60secondbridge') {
sPlayerName = sixtysecUser;
iUserID = 1;
sBidSys = sixtysecBidSys;
sRole = 'ok';
userid = iUserID; //bad, but need this for now in the game
if (sRole == 'ok') {
role = 'royal';
} else {
role = sRole;
}
var sPage = "
Please wait a moment...
...
.
";
if (sixtysecGame == 'hands') {
$('#stage').html(sPage);
goToGame({
"myclient": 0,
"uname": sPlayerName,
"BidSys": sBidSys,
"Game": "hands",
"Val": 0
});
} else if (sixtysecGame == 'set') {
GoMainMenu();
} else {
var game, val, hand, type;
game = sixtysecGame;
val = sixtysecVal;
hand = '1';
type = 'any';
if (sixtysecType != undefined) {
type = sixtysecType;
}
if (game == 'learn') {
game = 'coffee';
}
$('#stage').html(sPage);
goToGame({
"myclient": 0,
"uname": sPlayerName,
"BidSys": sBidSys,
"Game": game,
"Val": val,
"Bn": hand,
"Type": type
});
}
} else {
if (b.name == 'MSIE' && b.version < 10) {
var sPage = '
\
Oh, no!
\
It looks like you are using an old version of Internet Explorer. Because of vulnerabilities in the browser, certain older versions of IE are no longer supported by our website. To read why, click here
\
We recommend that you use a more robust and secure web browser like the Google Chrome web browser.
";
sPage += generateLiveGameUsersHtml();
$('#stage').html(sPage);
mode = 'compete'
goToGame({
"myclient": 0,
"uname": sPlayerName,
"BidSys": sBidSys,
"Game": "set",
"Val": 1
});
break;
case "Learn":
//Forum({type:'post',linkid:1});
Forum({
type: 'postlist',
linkid: 'questions'
});
break;
case "Ask":
Forum({
type: 'post',
linkid: 37
});
break;
case "Videos":
Forum({
type: 'post',
linkid: 1226
});
break;
case "Results":
Results();
break;
case "Live":
Forum({
type: 'post',
linkid: 1
});
break;
case "Profile":
ProfilePage(sRole);
break;
case "Main":
GoMainMenu();
break;
default:
GoMainMenu();
break;
}
}
////////////////////////////////////////////////////////////////////////////////
// Pages
////////////////////////////////////////////////////////////////////////////////
function GoMainMenu() {
// Only log if the user has aleady logged in and is therefore returning to the page
// if (sPlayerName) {
// logEvents.visitPage(sPlayerName, 'MainGrid',sRole);
// }
var sPage;
var logintext;
// just for display //
if (sPlayerName != '') {
//already logged in otherwise no sPlayerName
logintext = 'Welcome back, ' + sPlayerName + ' (Log out)';
} else if (PagesGetCookie('EmailAddress') != "" && PagesGetCookie('Pass') != '') {
//not logged in yet but has cookie
logintext = 'Welcome back, ' + PagesGetCookie('EmailAddress') + ' (Log out)';
} else {
//not logged in, no cookie
logintext = 'Login / Register';
}
// If this user is an admin, then add a Imitate User link
if (PagesGetCookie('EmailAddress') === 'admin') {
logintext += 'Imitate'
}
//////////////////////
if (mydomain == 'bridgedoctor') {
sPage = '