function SupProposeGame() { this.pwd = undefined; this.errorElementId = false; this.setErrorElementId = function(val) { this.errorElementId = val; }; this.getProposedGame = function(url) { var B = Prototype.Browser; var tmp = new Dialog.Box('sg_prop_game', B.IE); //show overaly only if not IE //if ($('sg_msg_login') !== undefined) $('sg_msg_login').hide(); if ($('sg_prop_content') !== undefined) $('sg_prop_content').hide(); if ($('sg_prop_game') !== undefined) $('sg_prop_game').show(); if ($('sg_loader') !== undefined) $('sg_loader').show(); //make ajax request for open game var myAjax = new Ajax.Request(url, {method: "get", onComplete: this.sg_c}); try { pageTracker._trackPageview("/join_game_funnel/show_playnow.html"); } catch(err) {} }; this.sg_c = function(res) { $('sg_loader').hide(); $('sg_loader_symbol').hide(); $('sg_prop_content').update(res.responseText).show(); }; this.respondToClick = function(event) { var e = document.getElementById('sg_playnow_link_100'); if (e === undefined || e === null || e.value === undefined || e.value.length < 1) { return false; } else { eval(e.value); } }; this.getRegScreen= function(url) { $('sg_prop_content').hide(); $('sg_loader_symbol').show(); $('sg_loader').show(); url = url + '&type=100'; try { var s = window.location.search.substring(1).split('&'); for(var i = 0; i < s.length; i++) { var parts = s[i].split('='); if (parts[0] == 'uid') { url = url + "&uid=" + parts[1]; break; } } } catch(e) {} var myAajx = new Ajax.Request(url, {method: 'get', onComplete: this.sg_show}); }; this.sg_show= function(res) { //$('debug').update(res.responseText); evalScript(res.responseText); $('sg_loader').hide(); $('sg_loader_symbol').hide(); //$('sg_msg_login').show(); $('sg_prop_content').update(res.responseText).show(); }; this.closePopup= function() { $('sg_prop_game').hide(); //$('sg_msg_login').hide(); }; /** * Leere Dialogbox */ this.showEmpty = function() { new Dialog.Box('sg_prop_game'); //$('sg_msg_login').hide(); $('sg_prop_content').hide(); $('sg_prop_game').show(); }; this.setMode = function(mode_p) { this.mode = mode_p; }; this.setPwd = function(pwd_p) { this.pwd = pwd_p; }; /** * Ajax call to check if join game works, previously this was only pwd check * Adds password if the field exists */ this.checkJoin = function (id, langLiteral) { var langString = ''; if (langLiteral) { langString = 'L=' + langLiteral + '&'; } var url = 'index.php'; var command = 'eID=create&a=join&' + langString; if ($('game_password_'+id)) { var pw = $('game_password_'+id).value; prop.setPwd(pw); command += '&pw='+pw; } command += '&id='+id; var myAjax = new Ajax.Request(url, {method: 'get', parameters: command, onComplete: this.pwC, asynchronous: false}); }; /** * Callback for the joiner checkJoin function * JSON string with * error --> display the returned error * register --> correct password, user not logged in -> display registration screen * success --> logged in user, submit game registration data */ this.pwC = function (res) { //$('debug').update(res.responseText); //return; var r = eval('(' + res.responseText + ')'); if (r.error !== undefined) { $('sg_error_'+r.gameID).update(r.error).appear({duration: 0.2}).highlight({ endcolor: '#d3cdbf' }); prop.setPwd(undefined); } else if (r.register !== undefined){ //not logged in, nu aber quick registeren / einloggen prop.showEmpty(); prop.getRegScreen(r.register); } else if (r.success) { location.href = r.success; } else { //ignore error } }; /** * format a landing page message as valid * @param {string} id * @param {string} typepostfix * @param {string} text */ this.formatAsValid = function (id, typepostfix, text) { var wrapper = $('sg_'+id+'_wrapper'+typepostfix); if (!wrapper) { return; // do nothing on LPs without this element } if (wrapper.classList) { // no ie9 wrapper.classList.add('valid'); } wrapper.show(); if (this.errorElementId) { $(this.errorElementId).update(text); } else { $('sg_' + id + typepostfix).update(text); } var left = $('sg_'+id+'_left'+typepostfix); var middle = $('sg_'+id+'_middle'+typepostfix); var right = $('sg_'+id+'_right'+typepostfix); left.removeClassName('lp_sg_check_left'); middle.removeClassName('lp_sg_check_middle'); right.removeClassName('lp_sg_check_right'); left.addClassName('lp_sg_check_left_valid'); if (text.length == 0) { middle.addClassName('lp_sg_check_middle_valid'); } else { //display text in success checkmark middle.addClassName('lp_sg_check_middle_valid_with_text'); } right.addClassName('lp_sg_check_right_valid'); }; /** * format a landing page message as error * @param {string} id * @param {string} typepostfix * @param {string} text */ this.formatAsError = function (id, typepostfix, text) { var wrapper = $('sg_'+id+'_wrapper'+typepostfix); if (!wrapper) { return; // do nothing on LPs without this element } wrapper.show(); if (wrapper.classList) { // no ie9 wrapper.classList.remove('valid'); } if (this.errorElementId) { var errorDiv = new Element('div', {id: this.errorElementId + '_div'}); errorDiv.update(text); $(this.errorElementId).update(errorDiv); } else { $('sg_' + id + '' + typepostfix).update(text); } var left = $('sg_'+id+'_left'+typepostfix); var middle = $('sg_'+id+'_middle'+typepostfix); var right = $('sg_'+id+'_right'+typepostfix); left.removeClassName('lp_sg_check_left_valid'); middle.removeClassName('lp_sg_check_middle_valid'); right.removeClassName('lp_sg_check_right_valid'); left.addClassName('lp_sg_check_left'); middle.addClassName('lp_sg_check_middle'); right.addClassName('lp_sg_check_right'); }; /** * hide format wrapper * @param {string} id * @param {string} typepostfix */ this.hideWrapper = function (id, typepostfix) { var wrapper = $('sg_' + id + '_wrapper' + typepostfix); if (!wrapper) { return; // do nothing on LPs without this element } wrapper.hide(); }; this.clearDefaultInputs = function() { var elems = ['username', 'password', 'email']; for(var i = 0; i < elems.length; i++) { var el = document.getElementById(elems[i]); if (el) { try { clearMobileDefaultInputLabel(el); } catch(err) {} } } }; this.hideAllChecks = function() { var elems = ['namecheck', 'passwordcheck', 'emailcheck', 'termscheck', 'captchacheck', 'forgotpwdresponse', 'ageverificationcheck']; for (var i = 0; i < elems.length; ++i) { this.hideCheck(elems[i]); } }; this.hideCheck = function(elem) { var element = $('sg_'+elem+'_wrapper'); if(element) { element.hide(); } }; } /** * CJC * All that is included in the parameter "scripts" is going to be executed. * We use this function for the namechecker. We send in the parameter the declaration of * SupAjaxFactory callback and request objects so we can use them later. * to check the user name. * @param scripts * @return */ function evalScript(scripts) { try { if(scripts != '') { var script = ""; scripts = scripts.replace(/]*>([\s\S]*?)<\/script>/gi, function(){ if (scripts !== null) script += arguments[1] + '\n'; return '';}); if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0); } return false; } catch(e) { } } function isReturnKey(e) { var val; if(e && e.which){ // netscape val = e.which; } else { val = e.keyCode; // IE specific code } return val == 13; }