// Espacio de nombres de FX if (typeof FXPlanet!='object') FXPlanet = {}; FXPlanet.social_network = "fb"; FXPlanet.social_network_prefix = "fb"; FXPlanet.social_signed_request = ""; FXPlanet.social_getting_login_state = false; FXPlanet.social_getting_data = false; FXPlanet.social_checking = false; FXPlanet.social_check_permissions = true; FXPlanet.social_check_associate = true; FXPlanet.social_want_to_connect = false; FXPlanet.social_session_change = false; FXPlanet.social_canvas = false; FXPlanet.social_create_user_if_necessary = FXPlanet.social_canvas; FXPlanet.social_try_login = true; FXPlanet.social_create_user_just_failed = false; FXPlanet.social_user_logged = false; FXPlanet.social_user = ""; FXPlanet.social_name = ""; FXPlanet.social_signed_token = ""; FXPlanet.social_proxied_email = ""; FXPlanet.social_email = ""; FXPlanet.social_sex = ""; FXPlanet.social_fxuser_id = ""; // id de FB asociado al usuario plataforma FXPlanet.social_data = {}; FXPlanet.social_friends = {}; FXPlanet.Pixapi = function(call, params, callback) { PIX.apiCall(call, params, function(data) { DebugLog("PixapiResult:"+call); for (var i in data) DebugLog("Pixapi:"+call+"->"+i+"->"+data[i].toString()); if (data["error"]==undefined) callback(data); }); }; FXPlanet.MakeNick = function(first_name,last_name,cb) { // inventa un nick válido para la plataforma basándome en el nombre de Facebook/Pixonic if (FXPlanet.social_network!="pixonic" && last_name.length>2) last_name = last_name.slice(0,2); var result = first_name+last_name; result = result.toUpperCase(); var first_invalid; while ((first_invalid=strspn(result,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-_."))15) result = result.slice(0,15); FXPlanet.AjaxCallEx("ajax/generic.php", { call: "User.SuggestAlias", UserAlias: result }, function(reply) { if (reply._resultStr!="WU_OK") { reply._resultStr = "WU_OK"; if (result.length>11) result = result.slice(0,11); reply.Suggestions = new Array(result+Math.floor(Math.random()*10)+Math.floor(Math.random()*10)+Math.floor(Math.random()*10)+Math.floor(Math.random()*10)); } cb(reply); }); } // Obtiene la información (id, nombre...) del usuario actualmente logueado en facebook FXPlanet.GetSocialData = function(callback) { DebugLog("GetSocialData"); FXPlanet.social_getting_data = true; var arrParams = { product: game_id }; if (FXPlanet.social_signed_request!="") arrParams["signed_request"] = FXPlanet.social_signed_request; if (FXPlanet.social_network=="pixonic") { PIX.apiCall("profile.get", {}, function(data) { FXPlanet.social_getting_data = false; FXPlanet.social_user = FXPlanet.social_name = FXPlanet.social_proxied_email = FXPlanet.social_email = FXPlanet.social_sex = ""; if (data["error"]!=undefined) return; data = data["response"]["profile"]; FXPlanet.social_data = data; FXPlanet.social_user = data["id"]; FXPlanet.social_sex = data["gender"]=="M" ? "male" : "female"; FXPlanet.MakeNick(data["firstName"],data["lastName"],function(reply) { FXPlanet.social_name=reply.Suggestions[0]; if (typeof callback === 'function') callback(); }); }); } else FXPlanet.AjaxCallEx("ajax/fb_on_login.php", arrParams, function(reply) { FXPlanet.social_getting_data = false; FXPlanet.social_user = FXPlanet.social_name = FXPlanet.social_signed_token = FXPlanet.social_proxied_email = FXPlanet.social_email = FXPlanet.social_sex = ""; if (reply._resultStr!="WU_OK" || reply.user=="") return; FXPlanet.social_user = reply.user; FXPlanet.social_signed_token = reply.signed_token; FXPlanet.social_proxied_email = reply.proxied_email; FXPlanet.social_email = reply.email; FXPlanet.social_sex = reply.sex; FXPlanet.MakeNick(reply.first_name,reply.last_name,function(reply) { FXPlanet.social_name=reply.Suggestions[0]; if (typeof callback === 'function') callback(); }); }); }; // Hace login en la plataforma con el usuario actual de fb FXPlanet.SocialLogin = function(create_if_necessary,page) { if (page==null) page = ""; FXPlanet.doing_login = true; FXPlanet.AjaxCallEx("ajax/social_login.php", { social_id: FXPlanet.social_user, social_signed_token: FXPlanet.social_signed_token, social_network_prefix: FXPlanet.social_network_prefix }, function(reply) { FXPlanet.doing_login = false; // el usuario plataforma ya fue creado a partir de su id facebook if (reply._resultStr=="WU_OK") { user_hash_passw = ""; FXPlanet.social_user_logged = true; FXPlanet.User.uid = reply.UserId; FXPlanet.Event.trigger("login",reply.UserMail,reply.Alias,reply.Country,reply.CountryBirth,reply.UserId,page); report_bug_url = "http://juegos.fxinteractive.comapplication/report_bug.php?bug_key="+reply.bug_key+"&email="+reply.UserMail+"&alias="+reply.Alias; $('#report_bug > [name=clave]').val(reply.bug_key); $('#report_bug > [name=email]').val(reply.UserMail); $('#report_bug > [name=alias]').val(reply.Alias); FXPlanet.AjaxCallEx("ajax/register_game.php", {game_id: game_id, referer:FXPlanet.Referer, tag:FXPlanet.Tag }, function(reply) {}); FXPlanet.CallLauncherSafe("login_social?socialid="+FXPlanet.social_user+"&network="+"FB"+"&token="+FXPlanet.social_signed_token+"&no_reconnect=1"); FXPlanet.CallLauncherSafe("notify?data=pass_"+FXPlanet.social_signed_token); return; } if (!create_if_necessary) return; // el usuario plataforma no ha sido creado a partir de su id facebook; lo creamos ahora FXPlanet.doing_login = true; DebugLog("SocialLogin creando cuenta por "+reply._resultStr); FXPlanet.AjaxCallEx("ajax/is_mail_available.php", { mail: FXPlanet.social_email }, function(reply) { var func_create = function(nick_fb) { data = FXPlanet.CallLauncher("get_machine_id"); machine = data.Result && data.Result!="Error" ? data.Reply : ""; FXPlanet.AjaxCallEx("ajax/social_create_user.php", { social_id: FXPlanet.social_user, alias: nick_fb, email: FXPlanet.social_email, sex: FXPlanet.social_sex, language: FXPlanet.locale, validated: "yes", machine: machine, tag:FXPlanet.Tag, referer:FXPlanet.Referer }, function(reply) { FXPlanet.doing_login = false; if (reply._resultStr=="WU_OK") { FXPlanet.SocialLogin(false,page); FXPlanet.SendStat("has_ever_signedup","web_new_user_signedup",{ social:1 }); } else if (reply._resultStr=="WC_ERROR_USED_USERMAIL") { FXPlanet.social_create_user_just_failed = true; ShowMessage('Atención','Ya hay un usuario registrado con el Email de tu cuenta Facebook.

Haz clic aquí para entrar con tu Email y contraseña.',false); } else ShowMessage('Atención',reply._resultMsg); }); }; if (reply._resultStr!="WU_OK" && reply._resultStr=="WC_ERROR_USED_USERMAIL") func_create(""); // Email del user fb ya existe en plataforma; social_create_user.php los auto-asociara else OpenWindow('win_crear_cuenta_nm_fb.php',function() { FXPlanet.SendStat("has_ever_window_create","web_window_create_user_fb"); $("#fb_create_nick").val(FXPlanet.social_name); $("#fb_create_nick").focus(); $("[name=js_goto_login]").toggle(FXPlanet.social_network!="pixonic"); $("#btn_yes").mousedown(function() { if ($("[name$=js_accept_terms]").length>0 && $("[@name=js_accept_terms]:checked").val()==undefined) { ShowMessage('Atención','Debes aceptar las condiciones del servicio para continuar.'); return; } CloseWindow($(this)); func_create($("#fb_create_nick").val()); }); }); }); }); } FXPlanet.GetRankingUsers = function(callback) { if (FXPlanet.social_network=="fb") ajaxGet('/fx/application/get_ranking_users.php', {}, callback); else { var result = { "uid": FXPlanet.social_user, "friends": [], "friendsInApp": [] }; FXPlanet.Pixapi("friends.get", {}, function(data) { data = data["response"]["profiles"]; FXPlanet.social_friends = data; for (i=0; i'); obj.text = document.getElementById('applet_java_version').GetVersion(); } catch (err) {} } var dot = obj.text.indexOf("."); if (dot!=-1) { obj.version = parseInt(obj.text.substr(0,dot)); obj.subVersion = parseInt(obj.text.substr(dot+1,dot)); if (obj.version>0) FXPlanet.java_version = obj; } return obj; } FXPlanet.CompleteUrl = function(url) { var complete_url = $.trim(url); if (complete_url.indexOf("/fx/application/")!=0 && complete_url.indexOf("http://")==-1) complete_url = "/fx/application/"+url; return complete_url; } FXPlanet.next_call_sync = false; FXPlanet.AjaxCall = function(url,params,callback,cb_error,trace) { var cb = callback; complete_url = url; if (complete_url.indexOf("/fx/application/")!=0 && complete_url.indexOf("http://")==-1) complete_url = "/fx/application/"+url; // compatibilidad con arrays unidimensionales for (var i in params) if (typeof params[i]=='object') { //for (var j in params[i]) for (var j=0; j"+xml.replace(/\n/g, ' ')); if (user_logged && !FXPlanet.doing_login && GetXMLData(xml,"error")=="WC_ERROR_NO_SESSION") { DebugLog("reintentando login por WC_ERROR_NO_SESSION"); user_logged = false; if (!FXPlanet.social_user_logged) FXPlanet.Login(user_email,"",user_hash_passw,user_hold_logged); else FXPlanet.SocialLogin(false); } if (typeof cb === 'function') cb(xml); }, error: function(jqXHR, textStatus, errorThrown) { if (cb_error!=undefined) cb_error(); DebugLog(url+json_encode(params)+"-> error: "+textStatus+"-"+errorThrown); }, async: !FXPlanet.next_call_sync, dataType: "text" }); FXPlanet.next_call_sync = false; }; FXPlanet.AjaxCallEx = function(url,params,callback,cb_error,trace) { var cb_ex = function(reply) { var obj; try { obj = eval(reply); } catch(err) { obj = new Object; obj._resultStr = "ERROR_JSON"; }; if (typeof callback === 'function') callback(obj); }; FXPlanet.AjaxCall(url,params,cb_ex,cb_error,trace); }; FXPlanet.SendStat = function(cookie_name,stat_name,additional_params,callback) { if (SearchArray(FXPlanet.stats_sent,stat_name)!=-1) { if (typeof callback==='function') callback(); return; } FXPlanet.stats_sent.push(stat_name); if (cookie_name==undefined || cookie_name=="" || cookie_name==null || GetCookie(cookie_name)!="yes") { var arrParams = { Type: stat_name, Referer:FXPlanet.Referer, Tag:FXPlanet.Tag, UniqId: uniqid }; if (machine_id!='') arrParams['machine_id'] = machine_id; if (typeof additional_params=='object') for (var i in additional_params) arrParams[i] = additional_params[i]; FXPlanet.AjaxCallEx("ajax/send_stat.php",arrParams,callback); } else if (typeof callback==='function') callback(); if (cookie_name!=undefined && cookie_name!="" && cookie_name!=null) SetCookie(cookie_name,"yes"); }; function WindowCenter(overlay_name,animate) { var width = $("#"+overlay_name+"_content > div").css("width"); var height = $("#"+overlay_name+"_content > div").css("height"); if (isNaN(parseInt(width)) || parseInt(width)==0) width="650px"; // en opera y safari las líneas de arriba no son muy fiables if (isNaN(parseInt(height)) || parseInt(height)==0) height="500px"; var show_on_top = $("#"+overlay_name+"_box").hasClass("no_auto_center"); $("#"+overlay_name+"_box").attr("width",width); $("#"+overlay_name+"_box").attr("height",height); $("#"+overlay_name+"_content").attr("width",width); $("#"+overlay_name+"_content").attr("height",height); $("#"+overlay_name+"_box > .overlay_boxclose").css("left",parseInt(width)-52); var left = Math.max(0,(GetWindowWidth()-parseInt(width))/2); // +overlay_number*20 var top = show_on_top ? 0 : Math.max(13,(GetWindowHeight()-parseInt(height))/3); // +overlay_number*20 if (!animate) $("#"+overlay_name+"_box").stop(true,true).css("top",top+"px"); else $("#"+overlay_name+"_box").stop(true,true).animate({"top":top+"px"},500); $("#"+overlay_name+"_box").css("left",left+"px"); $("#"+overlay_name+"_box").css("right",left+"px"); } function GamePlayerSetDefaultSize() { if (!FXPlanet.gameplayer_variable_size) { $("#gameplayer_frame").css("width",FXPlanet.default_width+"px"); $("#gameplayer_frame").css("height",FXPlanet.default_height+"px"); } else { // en el abu, el tamano de la pantalla del juego es proporcional a la ventana del navegador var max_height = Math.max(384,window_height-45); var max_width = window_width-20; max_height = Math.min(max_height,max_width*3/4)|0; max_width = Math.min(max_width,max_height*16/9)|0; $("#gameplayer_frame").css("height",max_height+"px"); $("#gameplayer_frame").css("width",max_width+"px"); } } function CenterWindowsPeriodic() { if (window_width!=GetWindowWidth() || window_height!=GetWindowHeight()) { window_width = GetWindowWidth(); window_height = GetWindowHeight(); $(".overlay_box").each(function(index) { var name = $(this).attr("name"); if (name.indexOf("_box")==name.length-4) { name = name.slice(0,name.length-4); WindowCenter(name,false); } }); if (!FXInstallEntertainment.is_launched) GamePlayerSetDefaultSize(); //$("#Banner").toggleClass("Banner_Narrow",window_height<650 || FXPlanet.social_network=="pixonic"); //$("#Banner").toggleClass("Banner",window_height>=650 && FXPlanet.social_network!="pixonic"); } setTimeout(CenterWindowsPeriodic,1000); } function GetWindowClass(url) { var url_begin_length = url.indexOf("."); var window_class = url.slice(0,url_begin_length==-1?url.length:url_begin_length); window_class = window_class.replace(/\//g,'_'); return window_class; } FXPlanet.close_window_cbs = {}; FXPlanet.windows_urls = {}; function OpenWindow(url,callback,closable,show_on_top,no_repeat/*opcional*/,cb_close/*opcional*/,no_animate/*opcional*/) { // añade un div al DOM, sobre el que se cargará el html que haya en la url especificada url = $.trim(url); var overlay_name = "overlayframe"+overlay_next; var no_auto_center = show_on_top ? " no_auto_center" : ""; var no_animate = no_animate ? " no_animate" : ""; var window_class = GetWindowClass(url); var window_classes = "overlay_box "+window_class+no_auto_center+no_animate; FXPlanet.close_window_cbs[window_class] = (typeof cb_close==='function') ? cb_close : (function(){}); FXPlanet.windows_urls[window_class] = url; if ((no_repeat===null || no_repeat===true || no_repeat===undefined) && $("."+window_class).length>0 && !$("."+window_class).hasClass("closing")) return ''; // evita abrir varias veces la misma ventana $("body").prepend( ''); overlay_next = overlay_next+2; var cb_result = callback==null ? (function(){}) : callback; if (closable===null || closable===false || closable===undefined) $("a[name="+overlay_name+"_boxclose]").css("display","none"); window_just_closed = false; DebugLog("OpenWindow "+window_class); // carga el html de la url especificada, y muestra centrado el resultado $("#"+overlay_name+"_content").load(FXPlanet.CompleteUrl(url),function() { if (!FXPlanet.is_explorer || GetIEVersion()>6) { if ($("#overlay").length==0) { var overlayColor = FXPlanet.get_params.indexOf("from_fb=1")!=-1 ? "#FFF" : "#000"; $("body").prepend(''); } if (FXPlanet.is_explorer) $("#overlay").show(); else $("#overlay").fadeIn("fast",function() {}); // por algún motivo el fadeIn de jquery no funciona en internet explorer $("#"+overlay_name+"_box").css("position","fixed"); } WindowCenter(overlay_name,!no_animate); $("#"+overlay_name+"_box").show(); overlay_number++; if (true) { // Antes comprobaba overlay_number <=, pero a veces es incorrectamente mayor de lo normal FXPlanet.GameLaunchShowOrHide(); // para que no se pinten juego / flashes encima de ventanas jquery } cb_result(overlay_name); $("a[name$=_boxclose]").live("click",function(e) { window_just_closed = true; CloseWindow($(this)); }); FXInstallEntertainment.HideVideo(); }); return overlay_name; } function CloseWindow(jq_element) { jq_element.each(function(index) { element = this; while (element && !$(element).hasClass("overlay_box")) element = element.parentNode; if (element) { $(element).addClass("closing"); var anim_time = $(element).hasClass("no_animate") ? 0 : 500; $(element).stop(true,true).animate({"top":"-1000px"},anim_time,function() { DebugLog("CloseWindow"); for(var class_name in FXPlanet.close_window_cbs) { // llama al callback de cerrar if ($(this).hasClass(class_name)) { FXPlanet.close_window_cbs[class_name](); delete FXPlanet.close_window_cbs[class_name]; } } $(this).remove(); overlay_number = Math.max(0,overlay_number-1); // [TODO] Es posible que disminuya 2 veces, al cerrar misma ventana varias veces en animación if ($(".overlay_box").length==0) { if (!FXPlanet.is_explorer || GetIEVersion()>6) if (FXPlanet.is_explorer) $("#overlay").hide(); else $("#overlay").fadeOut("fast"); // por algún motivo el fadeIn de jquery no funciona en internet explorer FXPlanet.GameLaunchShowOrHide(); } }); } }); } function CloseAllWindows() { CloseWindow($(".overlay_box")); } function CloseWindows() { var jq_selector = ""; for (var i=0; i0) jq_selector = jq_selector+","; var window_class = GetWindowClass(CloseWindows.arguments[i]); jq_selector = jq_selector+"."+window_class; } CloseWindow($(jq_selector)); } FXPlanet.OpenWindow = OpenWindow; FXPlanet.CloseWindows = CloseWindows; function CloseLoginWindows() { CloseWindows("win_crear_cuenta_nm_plataforma.php","win_login_nm_plataforma.php","win_forgot_password.php","win_crear_cuenta_nm_fb.php", "win_instalacion_plugin_en_noexplorer_a_nv.php","win_instalacion_plugin_en_explorer_a_nv.php", "win_instalacion_plugin_en_explorer_b_nv.php","win_instalacion_plugin_en_explorer_c_nv.php","win_crear_cuenta_nm_fb_cuenta_previa_nm.php"); } function IsAnyLoginWindow() { var jq_selector = ".win_crear_cuenta_nm_plataforma,.win_login_nm_plataforma,.win_forgot_password,.win_crear_cuenta_nm_fb,"+ ".win_instalacion_plugin_en_noexplorer_a_nv,.win_instalacion_plugin_en_explorer_a_nv,.win_instalacion_plugin_en_explorer_b_nv,"+ ".win_instalacion_plugin_en_explorer_c_nv,.win_crear_cuenta_nm_fb_cuenta_previa_nm"; var num_login_windows = 0; $(jq_selector).each(function(index) { num_login_windows++; }); return num_login_windows>0; } function IsAnyWindow(url) { var num_windows = 0; $("."+GetWindowClass(url)).each(function(index) { num_windows++; }); return num_windows>0; } function ShowMessage(title,text,closable,show_cb,close_cb) { if (game_id!=20 && game_id!=21) // en web de edicion que no quieren estos mensajes return; if (closable===null || closable===undefined) closable = true; text = text.replace(/\n/g,'
'); overlay_name = OpenWindow('win_message.php?title='+bin2hex(utf8_encode(title))+'&text='+bin2hex(utf8_encode(text)),function() { size = Math.min(32,35-0.3*title.length)|0; $("#overlay_message_title").css('font-size',size+'px'); OnWindowBlur(); if (typeof show_cb==='function') show_cb(); $(".overlay_boxclose").click(function() { CloseWindow($(this)); if (typeof close_cb==='function') close_cb(); }); },closable,false,false); return overlay_name; } function ConfirmDialog(title,text,ok_cb,cancel_cb) { if (game_id!=20 && game_id!=21) // en web de edicion que no quieren estos mensajes return; overlay_name = OpenWindow('win_confirm.php?title='+bin2hex(utf8_encode(title))+'&text='+bin2hex(utf8_encode(text)),function() { size = Math.min(32,35-0.3*title.length)|0; $("#overlay_message_title").css('font-size',size+'px'); $("#btn_yes").click(function() { CloseWindow($(this)); if (typeof ok_cb === 'function') ok_cb(); }); $("#btn_no").click(function() { CloseWindow($(this)); if (typeof cancel_cb === 'function') cancel_cb(); }); $("#overlay_boxclose").click(function() { CloseWindow($(this)); if (typeof cancel_cb === 'function') cancel_cb(); }); }); } function ShowMessageValidateEmail(closable) { OpenWindow('win_validar_email.php',function() { if (closable===false) $("[name=js_validate_later]").hide(); ChangeText("js_validate_email",user_email); $("[name=js_validate_later]").click(function() { CloseWindow($(this)); }); $("[name=js_validate_resend]").click(function() { FXPlanet.AjaxCall("ajax/send_validation_email.php", {}, function(xml) { if (GetXMLData(xml,"result")!="ok") ShowMessage('Atención','Error al reenviar Email. Intentalo de nuevo mas adelante.'); else ShowMessage('Email reenviado','Hemos vuelto a enviar tu Email de validación.'); }); }); $("[name=js_validate_change_email]").click(function(e) { OpenWindow("win_editar_cuenta_email.php",function() { // validando mail del usuario: el usuario seguramente quiera cambiar email $("[name=js_edituser_email]").val(user_email); },true); }); }); } // Obtiene la información (id, nombre...) del usuario actualmente logueado en facebook; opcionalmente, hace login con este usuario function FBGetData(do_fx_login,create_if_necessary,page) { DebugLog("FBGetData "+create_if_necessary); FXPlanet.GetSocialData(function() { if (!do_fx_login) FBCheck(); else FXPlanet.SocialLogin(create_if_necessary,page); }); } function ConnectWithFacebookDialog(tip, login_cb) { ConfirmDialog('CONECTA CON FACEBOOK', ((typeof tip !== 'undefined' && tip) ? tip : 'Si conectas '+FXPlanet.game_name+' con Facebook dispondrás de nuevas opciones: ' + 'Ranking de tus amigos, publicar tus trofeos en el muro, retar a tus amigos a través de Facebook, etc') + '¿Quieres conectar '+FXPlanet.game_name+' con Facebook?', function() { FB.login(login_cb, {scope: 'email'}); }, function() { FXPlanet.User.setConnectedToFacebook(false); if (typeof login_cb === 'function') login_cb({}); }); } // asocia la cuenta facebook con la cuenta de la plataforma function FXSetUserFB() { FXPlanet.AjaxCall("ajax/fb_set_user_fb.php", { fb_id: FXPlanet.social_user }, function(xml) { if (GetXMLData(xml,"result")=="ok") { ShowMessage('Facebook',"La cuenta Facebook "+FXPlanet.social_email+" ha sido asociada a "+FXPlanet.game_name+"."); $("#accesos_fb_connect").hide(); $("#accesos_ranking").show(); FXPlanet.User.setConnectedToFacebook(true); } else if (GetXMLData(xml,"error")=='WC_ERROR_USED_ID') { alert("No se ha asociado la cuenta Facebook a "+FXPlanet.game_name+".\n\nLa cuenta Facebook ya está asociada a otra cuenta "+FXPlanet.game_name+"."); } else { alert("No se ha asociado la cuenta Facebook a "+FXPlanet.game_name+".\n\nInténtalo de nuevo más adelante."); } //FBAskPermissionsIfNeeded(); }); } // A llamar cuando cambie el usuario actualmente logueado en facebook/fx: comprueba asociación de cuentas, y que nos ha dado permisos function FBCheck() { DebugLog("FBCheck "+FXPlanet.social_user); if (!user_logged || FXPlanet.social_network!="fb") return; if (FXPlanet.social_user=="") { // web no tiene login fb, mostrar botón fb para hacer login $("#accesos_fb_connect").show(); $("#accesos_ranking").hide(); return; } FXPlanet.social_checking = true; FXPlanet.AjaxCallEx("ajax/fb_get_fb.php", {}, function(reply) { FXPlanet.social_checking = false; if (reply._resultStr=="WC_ERROR_NO_SESSION") return; FXPlanet.social_fxuser_id = reply.SocialId===undefined || reply.SocialId=="0" ? "" : reply.SocialId; // el usuario fx tiene login sin fb; web tiene fb; mostrar botón fb para asociarlos $("#accesos_fb_connect").toggle(FXPlanet.social_fxuser_id=="" || FXPlanet.social_fxuser_id!=FXPlanet.social_user); $("#accesos_ranking").toggle(FXPlanet.social_fxuser_id!="" && FXPlanet.social_fxuser_id==FXPlanet.social_user); if (FXPlanet.social_fxuser_id!="" && FXPlanet.social_fxuser_id==FXPlanet.social_user) FXPlanet.User.setConnectedToFacebook(true); else if (FXPlanet.social_fxuser_id=="" && FXPlanet.social_email==user_email) FXSetUserFB(); else if (FXPlanet.social_want_to_connect) OpenWindow('win_crear_cuenta_nm_plataforma_conexion_fb.php',function() { $("#btn_yes").mousedown(function() { CloseWindow($(this)); FXSetUserFB(); }); $("#btn_no").mousedown(function() { CloseWindow($(this)); }); }); // FBAskPermissionsIfNeeded(); }); } FXPlanet.IsPluginInstalled = function () { if (FXPlanet.is_plugin_installed) return true; if (FXPlanet.is_explorer) { FXPlanet.is_plugin_installed = IsPluginActiveXInstalled(); } else { navigator.plugins.refresh(); for (i=0; i0) { result = new Object; result.Result = "Error"; return result; } DebugLog("PluginCall activando plugin") $("body").prepend( ''+ ''+ ''); plugin = FXPlanet.is_explorer ? document.getElementById('fxplanet_object') : document.getElementById('fxplanet_embed'); } return PluginCallInner(command,params,plugin); }; function PluginCallInner(command,params,plugin) { if (params==null) params = ""; var result; try { resp = plugin.Process('{"Command":"'+command+'"'+params+'}'); result = jQuery.parseJSON(resp); if (result === null) DebugLog("ERROR en plugin.Process: "+resp); } catch(err) { result = new Object; result.Result = "Error"; } return result; }; FXPlanet.launcher_notifs_interval = 0; FXPlanet.launcher_notifs_cb = null; FXPlanet.SetLauncherNotificationsCallback = function(cb) { if (FXPlanet.launcher_notifs_interval) { clearInterval(FXPlanet.launcher_notifs_interval) FXPlanet.launcher_notifs_interval = 0; } if (typeof cb==='function') { FXPlanet.launcher_notifs_cb = cb; var cb_notifs = function() { var data = FXPlanet.CallLauncher("notifications"); if (data!=null && data.Result && data.Result!="Error") for (var i=0; i
Vuelve a intentarlo más tarde.

"); else FXPlanet.Pixapi("client.initiatePayment", { orderId:reply.Id, title:title }, function(data) {}); }); } else if (pay_method.indexOf("pay_sms")!=-1 && FXPlanet.get_params.indexOf('mobiadvance')!=-1) { FXPlanet.AjaxCallEx("ajax/mobiadvanced_get_form.php", { item:(item==''?'pfx':item) }, function(reply) { if (reply._resultStr!="WU_OK") ShowMessage('Servicio en mantenimiento',"Este servicio está en mantenimiento.

Vuelve a intentarlo más tarde.

"); else eval(reply.js); }); } else { // sacar ventana flotante con el mtodo de pago correspondiente, y esperar a que termine var url = pay_method.indexOf("pay_phone")!=-1 ? "win_pfx_phone.php" : pay_method.indexOf("pay_toditocard")!=-1 ? "win_pfx_todito.php" : "win_pfx_sms.php?country="+user_country+"&item="+item+"&package="+id_pfx; OpenWindow(url,function() {},true); } } FXPlanet.PfxWindowCallback = function(text) { if (text!=undefined) $("#credits_text1").html(text); $("[name=credits_country]").val("ESP"); if (user_email=="" && FXPlanet.social_user_logged) ChangeText("credits_email","tu Email vía Facebook"); else ChangeText("credits_email",user_email); SetCountry("credits_country",user_country,false); $("#credits_edituser,#tasks_login").click(function(e) { OpenEditUserWindow(false); }); var win_pfx_update = function() { if (!IsAnyWindow("win_pfx.php") && !IsAnyWindow("win_navy_item.php")) return; FXPlanet.AjaxCallEx("ajax/generic.php", { call: "Web.GetNotifications" }, function(reply) { if (reply._resultStr=="WU_OK") for (var i=1; i<99; i++) { if (typeof reply[i+'']=="undefined") break; // auto-cerrar ventana con mensaje, si la plataforma ha recibido el sms if (reply[i+''].indexOf("sms_transaction(")!=-1) { num_pfx = reply[i+''].slice(String('sms_transaction(').length,reply[i+''].length-1); CloseWindows("win_pfx_sms.php"); ShowMessage('Recarga de puntosFX',"SMS recibido. Ahora tienes "+num_pfx+" puntosFX"); } // else if (reply[i+''].indexOf("transaction")!=-1) { CloseWindows("win_pfx.php","win_pfx_code.php","win_navy_item.php"); FXPlanet.CallLauncher("notify?data=rejoin"); FXPlanet.CallLauncher("notify?data=update_shop"); } } setTimeout(win_pfx_update,2000); }); }; win_pfx_update(); }; FXPlanet.OpenPfxWindow = function(cb_close,text) { if (!user_logged) // GameExit(null,function() { OpenLoginWindow(); }); return; var network = FXPlanet.social_canvas ? FXPlanet.social_network_prefix : "fx"; OpenWindow("win_pfx.php?country="+user_country+"&network="+network+"&user="+FXPlanet.User.uid,function(){ FXPlanet.PfxWindowCallback(); },true,true,false,cb_close); onlogin_open_shop = false; } FXPlanet.OpenTrialPayWindow = function(cb_close,url_extra) { url_extra = typeof url_extra=="undefined" ? "" : url_extra; FXPlanet.AjaxCallEx("ajax/generic.php", { call: "Store.OpenTransaction", ArticleId: 7, Game: game_id, CallbackHex2Bin: url_extra }, function(reply) { if (reply._resultStr!="WU_OK") ShowMessage('Servicio en mantenimiento',"Este servicio está en mantenimiento.

Vuelve a intentarlo más tarde.

"); else { var url_trial_pay = 'http://www.trialpay.com/dispatch/ad90bb3b15ea5983fe01c81e9f575f06?'+"sid="+reply.Id; OpenWindow("win_frame_2.php?width=620&height=640&url="+bin2hex(url_trial_pay),null,false,false,cb_close); } }); } FXPlanet.OpenFacebookCredits = function(id,obj) { var url_extra = obj.url_extra==undefined ? "" : obj.url_extra; var item = obj.item==undefined ? "" : obj.item; var package = obj.package==undefined ? id : obj.package; ArrayAddIfNotExist(FXPlanet.game_avoid_show,"fb_credits"); FXPlanet.GameLaunchShowOrHide(); FXPlanet.AjaxCallEx("ajax/generic.php", { call: "Store.OpenTransaction", ArticleId: 7, Game: game_id, CallbackHex2Bin: url_extra }, function(reply) { if (reply._resultStr!="WU_OK") ShowMessage('Servicio en mantenimiento',"Este servicio está en mantenimiento.

Vuelve a intentarlo más tarde.

"); else { var order_info = package+"-"+reply.Id+"-"+item; FB.ui({ method: 'pay', order_info: order_info, purchase_type: 'item' }, function(data) { ArrayRemove(FXPlanet.game_avoid_show,"fb_credits"); FXPlanet.GameLaunchShowOrHide(); //alert(json_encode(data)); if (data['order_id']) return true; else //handle errors here return false; }); } }); } FXPlanet.GetTrophies = function(callback) { if (typeof FXPlanet.arrTrophies!="undefined" && typeof FXPlanet.arrCollections!="undefined") { callback(FXPlanet.arrTrophies,FXPlanet.arrCollections); return; } FXPlanet.arrTrophies = new Array(); FXPlanet.arrCollections = new Array(); var locale = FXPlanet.locale=="ru" ? "en" : FXPlanet.locale; FXPlanet.AjaxCallEx("ajax/generic.php", { call: "Trophies.GetCollections" }, function(reply) { if (reply._resultStr!='WU_OK') { callback(FXPlanet.arrTrophies,FXPlanet.arrCollections); return; } var arrCollectionIds = reply.Collections; var arrTrophiesCodes = new Array(); for (i=0; i=0 && contest.rank<12 && false) { html += '
Exclusivo para:
'; html += '
'; html += '
$rank
'; } else { html += '
Premio:
'; html += '
'; html += '
$show_trophy_uses usos
'; html += ''; } html += ''; html += ''; html += '
'; html += '
'; html += '
Clasificación
'; html += '
Premios
'; html += '
'; html += '
Trofeos
'; var arrContestTrophies = new Array(); var trophyToShow = ''; var trophyToShowUses = 0; if (typeof contest.prizes!="undefined") for (var iInterval=0; iInterval10) short_name = short_name.slice(0,7)+"..."; html = html.replace("$trophy_image",arrTrophies[iTrophy].Image); html = html.replace("$trophy",short_name); html = html.replace("$collection",collection.Name); html += '
'; html += '
'; for (var iColTrophy=0; iColTrophy0 && contest.rank<12 ? arrRankImages[0] : ""; html = html.replace("$rank_image","/fx/public/images/20/"+rankImage); html = html.replace("$rank",User.prototype.rankToString(contest.rank)); html = html.replace("$scene_id",contest.scene_id); html = html.replace("$scene_name",contest.scene); html = html.replace("$show_trophy_image",typeof arrTrophies[trophyToShow]=="undefined" ? "" : arrTrophies[trophyToShow].Image); html = html.replace("$show_trophy_uses",trophyToShowUses); return html; }; FXPlanet.ShowScrollArrows = function(jquery_selector) { $(jquery_selector).jScrollPane({"showArrows":true}); } FXPlanet.ShowVitrina = function(wu2_user,user_mail,news_id,tab_active,no_ranking,closable) { if (game_launch_statemaxId) unreaded++; if (unreaded>0) callback(unreaded); },null,false); }; function ShowPage(page) { if (page==current_page || page==undefined || page=="") return; // establecer la página actual (oculta todas menos gameplayer y muestra la elegida) current_page = page; $("#loading,#ranking_navy,#page_install_fxwebplayer,#page_vast").hide(); $("#"+page).show(); // inicializaciones varias if (page=="gameplayer") { FXPlanet.CallLauncher("notify?data=focus"); GamePlayerSetDefaultSize(); } else $("#gameplayer_frame").css('height','1px'); // no puede desaparecer, y no quiero hueco enorme en su lugar $("[name=gameplayer_foot]").toggle(page!="ranking_navy"); $("#accesos_jugar").toggle(page!="gameplayer"); $("#accesos_hd,#accesos_fullscreen").toggle(page=="gameplayer"); if (!FXPlanet.game_launched) FXPlanet.GameLaunchStop(); else if (page!="gameplayer") { FXPlanet.CallLauncher("notify?data=blur"); ArrayAddIfNotExist(FXPlanet.game_avoid_show,"not_gameplayer"); } else ArrayRemove(FXPlanet.game_avoid_show,"not_gameplayer"); FXPlanet.GameLaunchShowOrHide(); FXPlanet.CallLauncher("state"); } function ShowGameProgressText(text1) { var data = new Object; data.State = "unknown"; data.Progress = 0.0; data.BPS = 0.0; data.Time = 0; FXPlanet.game_launch_on_update_state(data,text1,""); } function ShowGameProgress(data,downloading_text,installing_text) { if (downloading_text==null) downloading_text = "Cargando"; if (installing_text==null) installing_text = "Actualizando"; var state_text = downloading_text; var progress_text = ""; if (data.State=="waiting") state_text=""+FXPlanet.game_name+" iniciando..."; else if (data.State=="listing") state_text=""+FXPlanet.game_name+" iniciando..."; else if (data.State=="checking") state_text=""+FXPlanet.game_name+" iniciando..."; else if (data.State=="downloading") state_text=downloading_text; else if (data.State=="paused") state_text="Descarga en pausa..."; else if (data.State=="downloaded") state_text="Descarga terminada..."; else if (data.State=="installing") state_text=installing_text; else if (data.State=="finished") { state_text=""+FXPlanet.game_name+" iniciando..."; } else if (data.State=="error") state_text="Error en la descarga..."; else if (data.State=="not_found") state_text="Iniciando..."; else state_text=data.State; if (data.Progress>0 && data.Progress<=1 && (data.State=="downloading" || data.State=="installing")) { // 18/193 es un ajuste para que la barra de progreso se salte los bordes izquierdo/derecho de su marco var progress = Math.round(data.Progress*1000)/10; progress_text = progress.toString(); progress_text += progress_text.length<3 ? ".0%" : "%"; } FXPlanet.game_launch_on_update_state(data,state_text,progress_text); } FXPlanet.ProcessNotifications = function() { // Recoger las notificaciones data = FXPlanet.CallLauncher("notifications"); if (!data || !data.Result || data.Result=="Error" || (typeof data.Notifications == 'undefined')) return; var obj; for (var i=0; i0.0) { DebugLog("gls_game_running finish_load"); game_launch_time = 1.0; // para que el principio de gls_game_running muestre el juego } } // abre la página de recargar puntosFX else if (data.Notifications[i].indexOf("goto credits")==0) { try { obj=eval("( "+data.Notifications[i].slice("goto credits".length)+" )"); } catch(err) { obj=new Object; }; if (obj.Reason===undefined || obj.Pfx===undefined) FXPlanet.OpenPfxWindow(); else FXPlanet.AjaxCallEx("ajax/get_credit.php", {}, function(reply) { if (reply._resultStr!="WU_OK") return; var text = obj.Reason=="1" ? "Para participar en esta partida necesitas $needed puntosFX." : obj.Reason=="2" ? "Para comprar los ítems seleccionados necesitas $needed puntosFX." : obj.Reason=="3" ? "Para realizar esta promoción necesitas $needed puntosFX." : "Para realizar esta acción necesitas $needed puntosFX."; text = text.replace("$needed",obj.Pfx).replace("$total",reply.Credit); FXPlanet.OpenPfxWindow(null,text); }); } // abre la página de recargar puntosFX con trialpay o superrewards else if (data.Notifications[i]=="goto trialpay" || data.Notifications[i]=="goto superrewards") { if (FXPlanet.get_params.indexOf("fb_sig_in_iframe=1")==-1) if (data.Notifications[i]=="goto trialpay") FXPlanet.OpenTrialPayWindow(); else FXPlanet.OpenSuperRewardsWindow(); else { if (navigator.userAgent.indexOf("Chrome")!=-1) FXInstallEntertainment.Show(); // para que el navy no se pinte encima de la ventana de completar ofertas en Chrome FB.ui({ method: 'pay', credits_purchase: true, dev_purchase_params: {"shortcut":"offer"} }, function() {}); } } // abre la página de comprar item de Navy directamente con dinero else if (data.Notifications[i].indexOf("goto navy_items")==0) { try { obj=eval("( "+data.Notifications[i].slice("goto navy_items".length)+" )"); } catch(err) { obj=new Object; }; if (obj.Item!=undefined) { var network = FXPlanet.social_canvas ? FXPlanet.social_network_prefix : "fx"; OpenWindow("win_pfx.php?country="+user_country+"&network="+network+"&user="+FXPlanet.User.uid+"&item="+obj.Item,function(){ FXPlanet.PfxWindowCallback(); },true,false,false); } } // vuelve al juego else if (data.Notifications[i]=="goto gameplayer") ShowPage("gameplayer"); // saca la pestana de alertas else if (data.Notifications[i].indexOf("goto alerts")==0) FXPlanet.ShowVitrina(FXPlanet.User.uid,user_email,"",4); // se puede / no se puede ir a pantalla completa else if (data.Notifications[i]=="full_screen_available yes") $("[name=btn_fullscreen]").show(); else if (data.Notifications[i]=="full_screen_available no") $("[name=btn_fullscreen]").hide(); // no hay que / hay que mostrar mensaje de confirmacion de "se va a interrumpir la partida" else if (data.Notifications[i]=="in_main_menu yes") { FXPlanet.SendStat("has_ever_mainmenu","web_new_user_main_menu",{ nick:user_alias }); FXPlanet.must_confirm_exit_game = false; } else if (data.Notifications[i]=="in_main_menu no") FXPlanet.must_confirm_exit_game = true; // mostrar la ventana de invitaciones else if (data.Notifications[i].indexOf("fb_invite")==0) { try { obj=eval("( "+data.Notifications[i].slice("fb_invite".length)+" )"); } catch(err) { obj=new Object; }; showInviteForm(obj.text==undefined?'':obj.text,obj.app_users_too!=undefined && obj.app_users_too); } // mostrar la ventana de premios de los premios else if (data.Notifications[i].search(/^sponsor/) != -1) { var extra = data.Notifications[i].slice("sponsor".length+1); OpenWindow(extra, null, true, true, false); } // mostrar la ventana del informe semanal else if (data.Notifications[i]=="show_report") FXPlanet.ShowVitrina(FXPlanet.User.uid,user_email,"",0); // mostrar la ventana de la lista de premios else if (data.Notifications[i]=="show_prizes") FXPlanet.ShowVitrina(FXPlanet.User.uid,user_email,"",2); // mostrar una ventana else if (data.Notifications[i].indexOf("open_window ")==0) OpenWindow(data.Notifications[i].slice("open_window ".length), null, true, false, false); // hace una llamada ajax else if (data.Notifications[i].indexOf("ajax_call ")==0) { var arrParams = ParamsToArray(data.Notifications[i].slice("ajax_call ".length)); FXPlanet.AjaxCallEx("ajax/generic.php", arrParams, function(reply) { for (var i in reply) { if (typeof reply[i]=='object') { for (var j in reply[i]) reply[i+'_'+j] = reply[i][j]; delete reply[i]; } } reply = json_encode(reply).replace(/\"/g,'\'').replace(/ *: */g,':').replace(/\n/g,' ').replace(/ *\'/g,'\''); FXPlanet.CallLauncherSafe("notify?data=ajax_call "+reply); }); } // notificar al servidor de los videos disponibles else if (data.Notifications[i].search(/^av_videos/) != -1) { if (user_logged) { var videolist = data.Notifications[i].slice("av_videos".length+1); FXPlanet.AjaxCall("ajax/set_available_videos.php", { Videos: videolist }); } } // ocultar el usuario facebook de la web si es distinto del asociado al usuario que esté jugando else if (data.Notifications[i].indexOf("fb_id ")==0) { var fb_got = data.Notifications[i].slice(6); if (FXPlanet.social_user!="" && fb_got!="0" && FXPlanet.social_user!=fb_got) { DebugLog("quitando fb: "+FXPlanet.social_user+"!="+data.Notifications[i].slice(6)); FXPlanet.User.setConnectedToFacebook(false); } } // Activar las acciones del login (a propósito no incluyo navy en el texto de la notificación, así es más genérico) else if (data.Notifications[i]=="login_completed") { if (game_id==20 && typeof FXPlanet.NavyOnLogin==='function') FXPlanet.NavyOnLogin(); } // Saca una ventana de "ya tienes que validar tu email para continuar" else if (data.Notifications[i].indexOf("check_email_validated ")==0 && !user_email_validated) { //FXPlanet.User.validateEmail(data.Notifications[i].slice(22)!="now"); FXPlanet.User.validateEmail(true); } // Comenzar el login con facebook else if (data.Notifications[i].search(/^execute facebook_login/) != -1) { var extra = data.Notifications[i].slice("execute facebook_login".length+1); if (extra && extra=='ask_publish_stream') { FXPlanet.social_session_change = false; ConnectWithFacebookDialog(null, function(response) { if (response.authResponse) AskFBPublishPermissionAndNotifyGame(); else FXPlanet.CallLauncherSafe("notify?data=publish_stream 0"); }); } else if (extra) ConnectWithFacebookDialog(extra); else ConnectWithFacebookDialog(); // Enviar un mensaje } else if (data.Notifications[i].search(/^execute publish/) != -1) { OpenWindow("win_publish.php?"+data.Notifications[i].slice("execute publish".length+1), null, true); } else if (data.Notifications[i]=="execute ask_publish_stream") AskFBPublishPermissionAndNotifyGame(); else if (data.Notifications[i]=="glow publicar") { BarraProgreso.setComponentActive('publicar', true); BarraProgreso.setComponentBlink('publicar', true); } else if (data.Notifications[i]=="unglow publicar") { BarraProgreso.setComponentBlink('publicar', false); BarraProgreso.paint(); } else if (data.Notifications[i]=="glow hd") { BarraProgreso.setComponentBlink('hd', true); } else if (data.Notifications[i]=="unglow hd") { BarraProgreso.setComponentBlink('hd', false); BarraProgreso.paint(); } // Estado de instalación de las texturas HD else if (data.Notifications[i] == "textures_hd yes") { BarraProgreso.setHD(); } else if (data.Notifications[i] == "textures_hd no") { BarraProgreso.setHD(0); } // Mostrar un mensaje else if (data.Notifications[i]=="minimum_requirements") { //var message = data.Notifications[i].slice("show_message ".length); ShowMessage("Requisitos mínimos","Tu ordenador no cumple los requisitos mínimos para jugar a "+FXPlanet.game_name+".
Es posible que "+FXPlanet.game_name+" funcione lentamente o no funcione correctamente."); } else if (data.Notifications[i]=="reload_test") { FXPlanet.CallLauncherSafe("notify?data=browser_out_float"); setTimeout(function() { top.location.reload(); },5000); } else if (data.Notifications[i].search(/^fb_dialog friends/) != -1) { FB.ui({method: 'friends',id: data.Notifications[i].slice("fb_dialog friends".length+1)}); } else if (data.Notifications[i].indexOf("hd_percent ")==0) { $("#barra_progreso_hd_percent").show(); ChangeText("barra_progreso_hd_percent",data.Notifications[i].slice(11)); } // El juego pide el nombre y foto de un usuario en la red social actual, a partir de su id else if (data.Notifications[i].indexOf("get_name_picture ")==0) { FXPlanet.GetNamePicture(data.Notifications[i].slice(17),function (social_id,name,picture) { FXPlanet.CallLauncherSafe("notify?data=name_picture_"+social_id+" name: "+name+" pic: "+picture); }); } // El juego pide mostrar la vitrina de trofeos de un usuario else if (data.Notifications[i].indexOf("vitrina")==0) { try { obj=eval("( "+data.Notifications[i].slice("vitrina".length)+" )"); } catch(err) { obj=new Object; }; if (obj.alias!=undefined && obj.wu2_user!=undefined && obj.social_user!=undefined) FXPlanet.ShowVitrina(obj.wu2_user,user_email,""); } // publicacion en red social else if (data.Notifications[i].indexOf("publish")==0) { try { obj=eval("( "+data.Notifications[i].slice("publish".length)+" )"); } catch(err) { obj=new Object; }; obj["method"] = "Social.ApplyTemplate"; obj["Language"] = FXPlanet.locale; obj["ALIAS"] = user_alias; ajaxPost("/fx/application/ranking_navy/wuapi.php", obj, function(reply) { try { reply = eval('(' + reply + ')'); } catch (err) { reply = new Object; } if (reply.msg!=undefined) FXPlanet.SocialPublish(reply.msg.title,reply.msg.text,"","",reply.msg.image,function(){ FXPlanet.CallLauncherSafe("notify?data=close_window_facebook_publish"); }); }); } // devolver nombre del siguiente video de publicidad con vast else if (data.Notifications[i]=="get_ad_name") FXPlanet.CallLauncherSafe("notify?data=get_ad_name:"+FXPlanet.VastGetAdName()); // mostrar video de publicidad vast else if (data.Notifications[i]=="play_ad") FXPlanet.VastPlayAd(); // notificar al juego else if (data.Notifications[i].indexOf("notify_game:")==0) FXPlanet.CallLauncherSafe("notify?data="+data.Notifications[i].slice("notify_game:".length)); // abrir el Ladder de clanes else if (data.Notifications[i].indexOf("clan_ladder")==0) { try { obj=eval("( "+data.Notifications[i].slice("clan_ladder".length)+" )"); } catch(err) { obj=new Object; }; var sextra = ''; if (obj['division']!=undefined && obj['group']!=undefined) sextra = '?division=' + obj['division'] + '&group=' + obj['group']; OpenWindow("win_clan_ladder.php"+sextra,null,false,false,true,null,true); } } } FXPlanet.GameLaunchStart = function(id_game,cb_on_step) { if (id_game!=null && id_game!=undefined) game_id = id_game; if (cb_on_step===null || cb_on_step===undefined) cb_on_step = function(step,param) { return true; } FXPlanet.game_launch_on_step_cb = cb_on_step; ShowPage("gameplayer"); var cb_launch = function() { game_launch_try++; game_launch_state = gls_start; GameLaunch(game_launch_try); }; // versión inglesa requiere password if (game_launch_init) cb_launch(); else { game_launch_init = true; CenterWindowsPeriodic(); // de vez en cuando, comprobar que la sesión de la web no ha expirado var func_refresh = function() { FXPlanet.AjaxCallEx("ajax/generic.php", { call: "Web.Refresh" }); }; window.setInterval(func_refresh,60*1000); //if (true) if (FXPlanet.locale=="es" || FXPlanet.social_network=="pixonic") cb_launch(); else if (!IsAnyWindow("win_english_pass.php")) OpenWindow("win_english_pass.php",function() { $("[name=english_password]").val(GetCookie("publisher_password")); // auto-cerrar ventana con mensaje, si la plataforma ha recibido el sms $("[name=js_english_ok]").live("click",function(e) { FXPlanet.AjaxCallEx("ajax/is_english_pass_valid.php", { pass: $("[name=english_password]").val() }, function(reply) { if (reply._resultStr=="WU_OK") { CloseWindows("win_english_pass.php"); cb_launch(); var remember_password = $("[name=english_password_hold]").attr("checked") ? $("[name=english_password]").val() : ""; SetCookie("publisher_password",remember_password); } else ShowMessage("Error","Password incorrect"); }); }); },false); } } FXPlanet.GameLaunchStop = function() { game_launch_try++; FXPlanet.CallLauncher("down_stop?id="+game_id+"&core=1&isw2i=1"); // detener la descarga del juego, si la hay ShowGameProgressText(""); } FXPlanet.GameLaunchShow = function() { FXPlanet.SendStat("has_ever_game_show","web_game_show"); DebugLog("GameLaunchShow"); $("#barra_progreso").show(); $("#game_foot").show(); $("#game_ready").hide(); $("#game_progress_container").hide(); if (FXPlanet.User.connectedToFacebook || FXPlanet.social_network=="pixonic") { //$("#btn_volver_ranking").show(); $("#ranking_stripe_div").show(); } CloseLoginWindows(); FXInstallEntertainment.Hide(); $("#gameplayer_frame").children("img").remove(); ArrayRemove(FXPlanet.game_avoid_show,"not_loaded"); FXPlanet.GameLaunchShowOrHide(); } // Oculta el juego (para evitar que se pinte a traves de ventanas emergentes) o lo muestra (segun si hay ventanas emergentes o no) FXPlanet.GameLaunchShowOrHide = function() { var anyOverlayInParent = false; try { if ($('.overlay_box',window.parent.document).length>0) anyOverlayInParent=true; } catch(err) {}; if (FXPlanet.game_avoid_show.length==0 && $(".overlay_box,#adk_interstitial_container").length==0 && !anyOverlayInParent) { $("#fxplanet_object").css("top",FXPlanet.game_launch_plugin_position); $("#gameplayer_frame").children("img").show(); FXPlanet.CallLauncher("notify?data=focus"); } else { $("#fxplanet_object").css("top","-2000px"); $("#gameplayer_frame").children("img").hide(); FXPlanet.CallLauncher("notify?data=blur"); } for (var i=0; inumPages) { FXInstallEntertainment.page[(FXInstallEntertainment.channel%2)+1] = 1; FXInstallEntertainment.ChangeChannel(); return; } page = page<1 ? 1 : page>numPages ? numPages : page; FXInstallEntertainment.page[FXInstallEntertainment.channel] = page; $("[name=comic_loading]").toggle(!$("#game_ready").is(":visible") && page==numPages); $("#comic_numpage").html(page); $("#comic_numpages").html(numPages); $("[name^=comic_channel_]").stop(true,true); $("[name=comic_channel_1]").animate({"top":(-514*(FXInstallEntertainment.channel-1))+"px","left":(-685*(FXInstallEntertainment.page[1]-1))+"px"},500); $("[name=comic_channel_2]").animate({"top":(-514*(FXInstallEntertainment.channel-1))+"px","left":(-685*(FXInstallEntertainment.page[2]-1))+"px"},500); if (FXInstallEntertainment.autoZapTimeout) { clearTimeout(FXInstallEntertainment.autoZapTimeout); FXInstallEntertainment.autoZapTimeout = null; } var funcAutoZap = function() { if (FXInstallEntertainment.is_launched) FXInstallEntertainment.ShowPage(FXInstallEntertainment.page[FXInstallEntertainment.channel]+1); }; FXInstallEntertainment.autoZapTimeout = setTimeout(funcAutoZap,FXInstallEntertainment.channel==1 ? 10000 : 5000); } FXInstallEntertainment.game_progress_dynamic_text_type = 0; FXInstallEntertainment.show_dynamic_text_interval = null; FXInstallEntertainment.ShowDynamicText = function() { if (FXPlanet.locale=="ru") return; var iMinutes = parseInt(FXPlanet.game_launch_remaining_time/60); var text = ""; if (FXInstallEntertainment.game_progress_dynamic_text_type==0) if (FXPlanet.game_launch_remaining_time==0.0 || iMinutes>3) FXInstallEntertainment.game_progress_dynamic_text_type = 1; else if (iMinutes<=1) text = "Queda menos de 1 minuto para que $game_name se inicie"; else text = "Quedan alrededor de $minutes minutos para que $game_name se inicie"; if (FXInstallEntertainment.game_progress_dynamic_text_type==1) if (FXInstallEntertainment.channel==1) text = "Pulsa VER SCREENSHOTS para ver imágenes de $game_name"; else text = "Pulsa VER CÓMIC para ver la historia de $game_name"; text = text.replace(/\$game_name/g,FXPlanet.game_name).replace(/\$minutes/g,iMinutes); $("[name=game_progress_dynamic_text_2]").html(text); FXInstallEntertainment.game_progress_dynamic_text_type = (FXInstallEntertainment.game_progress_dynamic_text_type+1)%2; $("[name^=game_progress_dynamic_text]").stop(true,true).css("left","-1000px"); $("[name^=game_progress_dynamic_text]").animate({left:"68px"},1000).delay(3000).animate({left:"1000px"},1000); } function onYouTubePlayerReady(playerId) { document.getElementById("youtube_comic").addEventListener("onStateChange", "ytStateChange"); } function ytStateChange(new_state) { if (new_state==0) // video terminado, lo sustituye por las imagenes (deja 5 segundos por si la gente hace clic en me gusta) FXInstallEntertainment.HideVideo(); // quito los 5 segs porque con el nuevo fondo y tamano ya no se ve el me gusta //setTimeout(FXInstallEntertainment.HideVideo,5000); } FXInstallEntertainment.HideVideo = function() { FXInstallEntertainment.channel = FXPlanet.locale=="ru" || game_launch_state0; } function SpectrumIsPlaying() // llamada por el flash { DebugLog("SpectrumIsPlaying"); //FXInstallEntertainment.is_busy = true; } function CheckLauncherTimeOut(data,timeout,launch_try,log) { if (data!=null && data.Result!="Error") return false; if ((new Date()).getTime()-launcher_last_time>timeout && !FXPlanet.game_launch_wait_for_install_folder) { DebugLog("CheckLauncherTimeOut "+log+" "+((new Date()).getTime()-launcher_last_time)); FXPlanet.GameLaunchStart(game_id,FXPlanet.game_launch_on_step_cb); } else setTimeout("GameLaunch("+launch_try+")",250); return true; } function ServerDown(log_error) { ShowMessage('Servidor en mantenimiento','El servidor de FX Interactive está en mantenimiento en estos momentos.

Por favor, disculpa las molestias y recarga la página en unos minutos.',false); $("#game_progress_container").hide(); if (typeof log_error!='undefined') DebugLog(log_error); GameExit("",function(){}); } function GetGameName(id) { return arrGameNames[id]==undefined ? ("Game_"+id) : arrGameNames[id]; } function SetGameName(name) { FXPlanet.game_name = name; if (game_id==20 || game_id==21) document.title = FXPlanet.game_name; FXPlanet.game_name_no_space = FXPlanet.game_name.replace(" ",""); } function GameLaunch(launch_try) { // cancelar el proceso si procede if (launch_try!=game_launch_try) return; var game_launch_state_previous = game_launch_state; time_out = 250; switch (game_launch_state) { case gls_start: // PASO 1: inicializar variables SetGameName(GetGameName(game_id)); if (FXPlanet.game_name=="Game" || FXPlanet.game_name=="Game_"+game_id) { FXPlanet.AjaxCallEx("ajax/generic.php", { call: "Game.List" }, function(reply) { for (i=0; i0.0) ShowGameProgressText("Conectando con Facebook..."); else if (FXPlanet.doing_login) ShowGameProgressText("Estableciendo usuario y contraseña..."); else if (user_logged) { // si web ya tiene login, pasamos al siguiente paso DebugLog("gls_web_login terminado"); ShowGameProgressText("Comprobando FX Web Player..."); game_launch_state = FXPlanet.IsPluginInstalled() ? gls_launcher_update : gls_plugin; game_launch_time = 0.0; } else if (!IsAnyLoginWindow()) { if (FXPlanet.social_user!="" && FXPlanet.social_try_login) { // si web tiene fb, hago login con fb y luego se lo paso al launcher ShowGameProgressText("Conectando con Facebook..."); FXPlanet.social_try_login = false; DebugLog("gls_web_login login fb"); FXPlanet.SocialLogin(FXPlanet.social_create_user_if_necessary); } else if (!FXPlanet.game_launch_on_step_cb("unlogged","")) { ShowGameProgressText(""); return; } else { ShowGameProgressText("Esperando usuario y contraseña..."); DebugLog("gls_web_login sin login"); if (GetCookie("has_ever_logged")=="yes") OpenLoginWindow(); else OpenCreateUserWindow(); } } break; case gls_plugin: // PASO 3: que el usuario instale el plugin si no lo está if (FXPlanet.IsPluginInstalled()) { // el navegador nos va a recargar DebugLog("gls_plugin: detectado"); FXPlanet.GameLaunchStop(); window.location.reload(); break; } var is_showing = true; // evita envio estadistica boton plugin mientras se esta cargando en background desde la home try { is_showing = parseInt($('#frame_game',window.parent.document).css('top'))>0; } catch(err) {}; if (is_showing) FXPlanet.SendStat("has_ever_window_plugin","web_window_plugin_java_manual"); if (overlay_number!=0 || onlogin_open_edituser || onlogin_open_shop || $(".overlay_box").length>0 || (typeof FXPlanet.select_hd)!="undefined") break; FXPlanet.select_hd = true; FXPlanet.GetJavaVersion(); // esta función puede que no devuelva la versión de java a la primera llamada (debido al retraso al cargar el applet en ie) $("#game_progress_container").hide(); if (true) //FXPlanet.locale=="ru" || game_id!=20) ShowPage("page_install_fxwebplayer"); else OpenWindow("win_hd_o_online.php",function() { $("#js_install_hd").click(function(e) { CloseWindow($(this)); setTimeout(function() { ShowMessage('Descargando la versión HD de Navy Moves','Es la primera vez que juegas a Navy Moves en este ordenador.\n\nUna vez descargado, ejecutalo y se instalará la versión HD de Navy Moves.',false); },1000); setTimeout(function() { window.location="http://juegos.fxinteractive.com/" },10000); }); $("#js_install_online").click(function(e) { CloseWindow($(this)); ShowPage("page_install_fxwebplayer"); }); }); break; case gls_launcher_update: // PASO 4: esperar a que el plugin esté en marcha y respondiendo, y que el launcher esté instalado y actualizado por el plugin var plugin_state = PluginCall("State",',"LauncherParams":"/public"'); // si el plugin está instalado... if (plugin_state.Result!="Ok") break; // mostrar progreso de la instalación del launcher, si es lo que hace el plugin ShowGameProgress(plugin_state,"Descargando FX Web Player","Instalando FX Web Player"); // quitar mensajes de instrucciones para instalar el plugin: el plugin ya está instalado CloseWindows("win_instalacion_plugin_en_noexplorer_a_nv.php"); if (check_launcher_environment) { environment = FXPlanet.CallLauncher("environment"); if (environment && environment.Result!="Error") { DebugLog("gls_launcher_environment "+environment.Environment+"/public"); if ("/public"=='/'+environment.Environment) check_launcher_environment = false; else { FXPlanet.CallLauncherIPCCom("close",""); game_launch_state_previous = game_launch_state = gls_start; } } break; } data = FXPlanet.CallLauncher("state"); if (!data.Result || data.Result=="Error" || data.Game_State=="preupdate") break; FXPlanet.net_slow = data.NetSlow; //alert("Recarga fxp.dll: "+PluginCall("ReloadFxpDll").Result); if (data.Connection=="no_connection") { game_launch_time -= 0.25; if (game_launch_time<=-15.0 && !FXPlanet.firewall_error) { // llevamos 15 segundos esperando que se conecte FXPlanet.firewall_error = true; ShowMessage('Conectando','Parece que hay un problema de conexión.

Si tienes un firewall, asegúrate de que esté permitiendo al FX Web Player el acceso a Internet.'); FXPlanet.SendStat("has_ever_plugin_connected","web_plugin_no_connection"); } } else if (data.Updating && data.Game_Id==0) { data = FXPlanet.CallLauncher("download_ex?id=0&core=1&isw2i=0"); if (data.Result && data.Result!="Error") ShowGameProgress(data,"Descargando actualización de FX Web Player","Actualizando FX Web Player"); } else { FXPlanet.SendStat("has_ever_plugin_connected","web_plugin_connection"); //alert("Forzando reinstalación"); PluginCall("ReinstallLauncher"); data_version = PluginCall("Version"); if (!FXPlanet.is_explorer && (data_version.Result!="Ok" || data_version.Version
Por favor, cierra tu navegador completamente (todas las ventanas y pestañas) y vuelve a abrirlo para que la aplicación tenga efecto.',false); GameExit("",function(){}); } else { $("#debug_version").html("9-"+PluginCall("Version").Version+"-"+PluginCall("VersionFXP").Version+"-"+FXPlanet.CallLauncher("version").Version); if (data.Game_State=="playing" && data.Game_Id==game_id && FXPlanet.game_launch_survive_if_possible) { DebugLog("gls_launcher_update terminado - launcher jugando - pasando a gls_install"); game_launch_state = gls_install; } else { DebugLog("gls_launcher_update terminado"); game_launch_state = gls_launcher_login; game_launch_time = 30.0; launcher_connecting_fb = FXPlanet.social_user!="" && FXPlanet.social_signed_token!="" && user_hash_passw==""; if (launcher_connecting_fb) FXPlanet.CallLauncherSafe("login_social?socialid="+FXPlanet.social_user+"&network="+FXPlanet.social_network_prefix+"&token="+FXPlanet.social_signed_token+"&uniqid="+uniqid); else if (user_email!="") FXPlanet.CallLauncherSafe("login?user="+user_email+"&password="+user_hash_passw+"&rememberMe=0&uniqid="+uniqid); else FXPlanet.CallLauncherSafe("login?user="+GetCookie("user_email")+"&password="+user_hash_passw+"&rememberMe=0&uniqid="+uniqid); FXPlanet.SendStat("has_ever_launcher_login","web_launcher_login"); } } } data = FXPlanet.CallLauncher("get_machine_id"); if (data.Result && data.Result!="Error") machine_id = data.Reply; FXPlanet.SendStat("has_ever_plugin","web_install_plugin"); break; case gls_launcher_login: // PASO 5: esperar a que el launcher se loguee con nuestro email/pass game_launch_time -= 0.25; if (game_launch_time<=0.0) { DebugLog("gls_launcher_login 1"); game_launch_state = gls_start; } data = FXPlanet.CallLauncher("state"); if (CheckLauncherTimeOut(data,5000,launch_try,"gls_launcher_login")) return; if (data.Result && data.Connection=="logged") { DebugLog("gls_launcher_login "+data.Connection); game_launch_state = gls_install; } else if (data.Result && data.Connection=="wrong_user") { DebugLog("gls_launcher_login "+data.Connection); if (launcher_connecting_fb) FBGetData(true,true); else Logout(); game_launch_state = gls_start; FXPlanet.SendStat("has_ever_wrong_user","web_wrong_user"); } break; case gls_install: // PASO 6: lograr que el juego esté instalado game_launch_time = 30.0; FXPlanet.SetLauncherNotificationsCallback(); data = FXPlanet.CallLauncher("check_game?id="+game_id); if (CheckLauncherTimeOut(data,5000,launch_try,"gls_install-checkgame")) return; if (data.Result) { DebugLog("gls_install ya instalado"); install_state = 4; FXPlanet.SendStat("has_ever_download_w2i","web_yet_installed"); } else { // el juego no está instalado, instalarlo DebugLog("gls_install instalando juego"); if (install_state==0 && !FXPlanet.game_launch_on_step_cb("uninstalled","")) { ShowGameProgressText(""); return; } install_state = 1; data = FXPlanet.CallLauncher("download_w2i?id="+game_id); if (CheckLauncherTimeOut(data,5000,launch_try,"gls_install-download_w2i")) return; FXPlanet.SendStat("has_ever_download_w2i","web_download_w2i"); DebugLog("gls_install download_w2i "+(data.Result?"ok":"cancel")); install_state = 2; if (!FXPlanet.net_slow || FXPlanet.locale=="ru") FXInstallEntertainment.Show(); else OpenWindow("win_descarga_lenta.php",null,null,false,true,function() { FXInstallEntertainment.Show(); }); } game_launch_state = gls_game_installing; CloseLoginWindows(); break; case gls_game_installing: // PASO 7: el juego se esta instalando game_launch_time -= 0.25; // si el juego se está descargando, mostrar progreso y mirar si ha terminado if (install_state==2) { data = FXPlanet.CallLauncher("download_ex?id="+game_id+"&core=1&isw2i=1"); if (CheckLauncherTimeOut(data,5000,launch_try,"gls_game_installing-download_ex")) return; if (data.Result) { ShowGameProgress(data, String("$game_name cargando...").replace("$game_name",FXPlanet.game_name)); if (data.State=="error") { /// DEPURANDO RAUL DebugLog("gls_game_installing2 "+data.State); FXPlanet.GameLaunchStop(); ShowMessage('No hay conexión','No hay conexión con el servidor.

Por favor, disculpa las molestias y recarga la página en unos minutos.',false); $("#game_progress_container").hide(); FXPlanet.game_launch_on_step_cb("error",""); return; } if (data.State=="finished" && (!FXPlanet.game_launch_wait_for_install_folder || FXPlanet.game_launch_install_folder!="")) { var data = new Object; data.State = "installing"; data.Progress = 0.0; data.BPS = 0.0; data.Time = 0; FXPlanet.game_launch_on_update_state(data,"",""); //FXPlanet.game_launch_on_step_cb("downloaded",""); if (!FXPlanet.game_launch_on_step_cb("downloaded","")) { ShowGameProgressText(""); return; } CloseWindows("win_descarga_lenta.php"); var call = "install_w2i?id="+game_id; if (FXPlanet.game_launch_install_folder!="") call = call+'&dest="'+FXPlanet.game_launch_install_folder+'"'; data = FXPlanet.CallLauncher(call); if (CheckLauncherTimeOut(data,5000,launch_try,"gls_game_installing-install_w2i")) return; DebugLog("gls_game_installing3 "+call+" devuelve "+(data.Result?"ok":"error")); if (data.Result) install_state = 3; FXPlanet.SendStat("has_ever_download_finished","web_download_finished"); } else { if (data.Progress>=0.99) FXPlanet.SendStat("has_ever_download_progress_99","web_download_progress_99"); else if (data.Progress>=0.75) FXPlanet.SendStat("has_ever_download_progress_75","web_download_progress_75"); else if (data.Progress>=0.50) FXPlanet.SendStat("has_ever_download_progress_50","web_download_progress_50"); else if (data.Progress>=0.25) FXPlanet.SendStat("has_ever_download_progress_25","web_download_progress_25"); else if (data.Progress>=0.01) FXPlanet.SendStat("has_ever_download_progress_1","web_download_progress_1"); } } } // la siguiente llamada, ademas de procesar peticiones de abrir tienda, etc., mira si la instalacion ha terminado FXPlanet.ProcessNotifications(); // pasa a jugar de una vez si el juego está instalado, el launcher logueado, y no le estamos preguntando nada al usuario if (install_state==4 && overlay_number==0 && (game_launch_time<=0.0 || !FXPlanet.social_checking)) { if (!FXPlanet.game_launch_on_step_cb("installed","")) { ShowGameProgressText(""); return; } DebugLog("gls_game_installing go!"); //FXPlanet.AjaxCall("ajax/register_game.php", {game_id: game_id, referer:FXPlanet.Referer, tag:FXPlanet.Tag }, function(r) { //console.log("Registrando juego "+game_id); FXPlanet.game_registered = true; //}); game_launch_state = gls_game_register; game_launch_time = 30.0; ShowGameProgressText("Registrando "+FXPlanet.game_name+"..."); // activa el "instalado" de la barra de progreso if (typeof BarraProgreso != 'undefined') { BarraProgreso.setInstalled(); BarraProgreso.update(); } } //else // DebugLog("-"+install_state+"-"+overlay_number+"-"+game_launch_time+"-"+FXPlanet.social_checking+"-"+user_logged+"-"+FXPlanet.social_user); break; case gls_game_register: // PASO 8: antes de lanzar, esperar a que el juego esté registrado game_launch_time -= 0.25; if (FXPlanet.game_registered) { DebugLog("gls_game_register registered"); game_launch_state = gls_game_launch; } else if (game_launch_time<=0.0) { DebugLog("gls_game_register timeout, restarting"); game_launch_state = gls_start; } break; case gls_game_launch: // PASO 9: lanzar el juego en sí (hay que esperar a que esté registrado) ShowGameProgressText(String("$game_name cargando...").replace("$game_name",FXPlanet.game_name)); // pasa como parámetro la ventana del plugin, para que el juego se pinte en ella var plugin_result = PluginCall("Window"); if (plugin_result.Result!="Ok") { ShowMessage('Atención','No se ha podido lanzar el juego.

'); return; } FXPlanet.game_launch_window = plugin_result.Window; game_launch_time = 10.0; // 30.0; // ahora el juego se muestra poco despus de empezar a cargarse game_launch_errors = 0; // si el juego ya esta lanzado, lo reutiliza if (FXPlanet.game_launch_survive_if_possible) { data = FXPlanet.CallLauncher("state"); if (CheckLauncherTimeOut(data,30000,launch_try,"gls_game_launch-state")) return; if (data.Result) { FXPlanet.game_launch_survive_if_possible = data.Game_State=="playing" && data.Game_Id==game_id; if (FXPlanet.game_launch_survive_if_possible) { data = FXPlanet.CallLauncher("notify?data=hwnd_"+FXPlanet.game_launch_window); send_notifications = true; if (CheckLauncherTimeOut(data,30000,launch_try,"gls_game_launch-notify")) return; if (data.Result) { DebugLog("gls_game_launch notify "+FXPlanet.game_launch_window+" OK"); game_launch_time = 1.0; // para que el principio de gls_game_running muestre el juego game_launch_state = gls_game_update; FXPlanet.CallLauncherIPCCom("setvardic","plugin_window,"+FXPlanet.game_launch_window); // sirve para detectar plugin en otra ventana } } } } else {// lanza el juego command_line = '&cmd=/HWND '+FXPlanet.game_launch_window+game_launch_params; if (FXPlanet.get_params.indexOf("reload_test")!=-1) command_line = command_line+"/reload_test"; DebugLog("gls_game_launch launch"); data = FXPlanet.CallLauncher("launch?id="+game_id+command_line); if (CheckLauncherTimeOut(data,30000,launch_try,"gls_game_launch-launch")) return; if (data.Result) { FXPlanet.SendStat("has_ever_game_launched","web_new_game_launched"); ShowGameProgressText(String("$game_name cargando...").replace("$game_name",FXPlanet.game_name)); DebugLog("lanzado"); game_launch_state = gls_game_update; FXPlanet.CallLauncherIPCCom("setvardic","plugin_window,"+FXPlanet.game_launch_window); // sirve para detectar plugin en otra ventana //FXPlanet.AjaxCall("ajax/set_user_info.php", { Language: FXPlanet.locale }); // antes informaba del idioma de la sesioon al servidor navy } } break; case gls_game_update: // PASO 10: esperar a que el juego este actualizado data = FXPlanet.CallLauncher("state"); if (!data.Result || data.Result=="Error") break; if (data.Game_State=="playing") { game_launch_state = gls_game_running; // estadística de gente nueva que juega FXPlanet.SendStat("has_ever_played","web_new_user_played"); FXPlanet.game_launched_playing = true; FXPlanet.game_launched_playing_last_time = 0; $("#debug_version").html("9-"+PluginCall("Version").Version+"-"+PluginCall("VersionFXP").Version+"-"+ FXPlanet.CallLauncher("version").Version+"-"+FXPlanet.CallLauncherIPCCom("game_version","").Reply); if (!FXInstallEntertainment.is_busy) // si no está en marcha el entretenimiento, mostrar el juego ya FXPlanet.GameLaunchShow(); } else if (data.Game_State=="updating") { data = FXPlanet.CallLauncher("download_ex?id="+game_id+"&core=1&isw2i=0"); if (data.Result && data.Result!="Error") { ShowGameProgress(data,"Descargando actualización de "+FXPlanet.game_name+"","Actualizando "+FXPlanet.game_name+""); // si no está en marcha el entretenimiento, ponerlo en marcha (para entretener al usuario) if ((data.State=="downloading" || data.State=="installing") && !FXInstallEntertainment.IsLaunched()) FXInstallEntertainment.Show(); } } else if (data.Game_State=="none" || data.Game_State=="main") { game_launch_errors++; if (game_launch_errors>=20) { DebugLog("gls_game_update relanzando juego: "+json_encode(data).replace(/\n/g,' ')); game_launch_state = gls_start; } } FXPlanet.ProcessNotifications(); break; case gls_game_running: // PASO 11: mostrar juego y responder a sus notificaciones time_out = 1000; game_launch_time -= 1.0; if (game_launch_time>-0.5 && game_launch_time<0.5) { DebugLog("gls_game_running juego cargado "); $("#game_progress_container").hide(); FXPlanet.GameLaunchShow(); } else if (game_launch_time>0) { if ($("#fxplanet_object").css("top")==FXPlanet.game_launch_plugin_position) $("#game_progress_container").hide(); else ShowGameProgressText(String("$game_name cargando...").replace("$game_name",FXPlanet.game_name)); } // verificar que el juego sigue en marcha, reiniciandolo si peta if (FXPlanet.game_auto_relaunch) { data = FXPlanet.CallLauncher("state"); if (data.Result && data.Result!="Error" && (data.Game_State=="playing" || data.Game_State=="setting" || data.Game_State=="updating")) FXPlanet.game_launched_playing_last_time = 0; else if (++FXPlanet.game_launched_playing_last_time>=5) { DebugLog("gls_game_running relanzando juego: "+json_encode(data).replace(/\n/g,' ')); game_launch_state = gls_start; } } // verificar que el juego no se ha abierto en otra ventana/pestaña data = FXPlanet.CallLauncherIPCCom("getvardic","plugin_window"); if (data.Result=="Ok" && data.Reply!="" && data.Reply!=FXPlanet.game_launch_window) { ShowMessage('Juego en otra ventana',FXPlanet.game_name+' se ha abierto en otra ventana o pestaña del navegador.

Para seguir jugando, utiliza esa ventana o pestaña.',false); GameExit("",function(){}); } // Enviar notificaciones pendientes if (send_notifications) FXPlanet.Notification.flush(); FXPlanet.ProcessNotifications(); break; } if (game_launch_state_previous!=game_launch_state) time_out = 0; setTimeout("GameLaunch("+launch_try+")",time_out); } function GameExit(confirm_text,callback) { if (!FXPlanet.game_launched) { callback(); return; } var cb_exit = function() { FXPlanet.game_launched = false; FXPlanet.game_launched_playing = false; ArrayAddIfNotExist(FXPlanet.game_avoid_show,"not_loaded"); FXPlanet.GameLaunchStop(); $("#install_entertainment").empty(); $("#install_entertainment").hide(); $("#fxplanet_object").remove(); callback(); }; if (confirm_text===null || confirm_text===undefined) confirm_text = "Para realizar esta acción es necesario abandonar la partida. ¿Estás seguro?"; if (confirm_text!="" && FXPlanet.must_confirm_exit_game) ConfirmDialog("Abandonar la partida",confirm_text,cb_exit); else cb_exit(); } function BeforeUnload() { return "Al cerrar la página saldrás del juego. ¿Estás seguro?"; } function WaitForReplyChallenge(challenge,callback) { var cb = callback; var tries = 30; var _challenge = challenge; var func_wait = function() { try { if ((--tries)<=0) { DebugLog("https no responde"); cb("","HTTPS_NO_CONNECTION","No hay conexión con el servidor.\n\nPor favor, vuelve a intentarlo en unos minutos"); return; } frame_content = $("#https")[0].contentWindow.document.body.innerHTML; reply_challenge = GetXMLData(frame_content,"reply_challenge"); hash_passw = GetXMLData(frame_content,"user_hash_passw"); if (reply_challenge=="" || GetXMLData(frame_content,"challenge")!=_challenge) throw "continue"; else if (reply_challenge=="error" || hash_passw=="") { SetCookie("user_pass_known",""); cb("","WRONG_PASS","La contraseña no es correcta"); } else { SetCookie("user_pass_known","true"); SetCookie("user_hash_passw",hash_passw); DebugLog("reply_challenge->"+reply_challenge+";hash_passw->"+hash_passw); user_hash_passw = hash_passw; cb(reply_challenge,"",""); } } catch(err) { setTimeout(func_wait,500); } }; func_wait(); } function WaitForFrameContent(element_id,search_content,callback) { var cb = callback; var func_wait = function() { try { element = document.getElementById(element_id); if (element==null) { cb(""); return; } frame_content = element.contentWindow.document.body.innerHTML; if (frame_content.indexOf(search_content)!=-1) { cb(frame_content); return; } throw "continue"; } catch(err) { setTimeout(func_wait,500); } }; func_wait(); } FXPlanet.LoginWithPass = function(email,user_pass,user_hold_logged,cb_ok,cb_ko) { FXPlanet.Login(email,"",hashPassword(user_pass,email),user_hold_logged,cb_ok,cb_ko); } FXPlanet.Login = function(email,user_id,user_hash,user_hold_logged,cb_ok,cb_ko) { user_hash_passw = user_hash; var arrParams; FXPlanet.doing_login = true; $("#js_loading").show(); FXPlanet.AjaxCallEx("ajax/login_get_challenge.php", { mail: email }, function(reply) { if (reply._resultStr!="WU_OK") { FXPlanet.doing_login = false; FXPlanet.Event.trigger("login_ko",reply); if (typeof cb_ko==='function') cb_ko(reply); return; } login_url = "http://juegos.fxinteractive.com/fx/application/wu2_login.php?email="+bin2hex(email)+"&challenge="+bin2hex(reply.Challenge); if (user_hash_passw!="") login_url += "&hash_passw="+bin2hex(user_hash_passw); DebugLog("login_url->"+login_url+"<-"); DebugLog("challenge->"+reply.Challenge); if ($("#https").length==0) $("body").prepend(''); $("#https").attr("src",login_url); WaitForReplyChallenge(reply.Challenge,function(reply_challenge,error,error_message) { if (reply_challenge=="") { FXPlanet.doing_login = false; var obj = new Object; obj._resultStr = error; obj._resultMsg = error_message; FXPlanet.Event.trigger("login_ko",obj); if (typeof cb_ko==='function') cb_ko(obj); return; } if (user_id!="") arrParams = { userid: user_id, hash: reply_challenge, navy: navy_session }; else arrParams = { mail: email, hash: reply_challenge, navy: navy_session }; FXPlanet.AjaxCallEx("ajax/login.php", arrParams, function(reply) { $("#js_loading").hide(); if (reply._resultStr!="WU_OK") { FXPlanet.doing_login = false; FXPlanet.Event.trigger("login_ko",reply); if (typeof cb_ko==='function') cb_ko(reply); return; } var emailLogged = reply.UserMail!="" ? reply.UserMail : email; FXPlanet.social_user_logged = false; FXPlanet.User.uid = reply.UserId; FXPlanet.Event.trigger("login",emailLogged,reply.Alias,reply.Country,reply.CountryBirth,reply.UserId,"",user_hold_logged); if (typeof cb_ok==='function') cb_ok(reply); }); }); }); } FXPlanet.LoginWithCookies = function(cb_ok,cb_ko) { if (user_logged) { if (typeof cb_ok==='function') cb_ok(); return; } if (typeof cb_ok==='function') FXPlanet.Event.subscribe('login', cb_ok); if (typeof cb_ko==='function') FXPlanet.Event.subscribe('login_ko', cb_ko); if (!FXPlanet.doing_login) { FXPlanet.doing_login = true; FXPlanet.AjaxCallEx("ajax/login_with_session.php", {}, function(reply) { FXPlanet.doing_login = false; if (reply._resultStr=="WU_OK") { FXPlanet.social_user_logged = false; FXPlanet.User.uid = reply.UserId; FXPlanet.Event.trigger("login",reply.UserMail,reply.Alias,reply.Country,reply.CountryBirth,reply.UserId); user_hash_passw = GetCookie("user_hash_passw"); } else if (GetCookie("user_email")!="" && GetCookie("user_pass_known")=="true") { DebugLog("FXPlanet.LoginWithCookies"); FXPlanet.Login(GetCookie("user_email"),"","",true); } else if (FXPlanet.social_network=="fb") { FXPlanet.GetSocialData(function() { FXPlanet.SocialLogin(false,null); },cb_ko); } else if (typeof cb_ko==='function') cb_ko(); }); } } function OnLogin(mail,alias,country,country_birth,session,page,user_hold_logged) { DebugLog("OnLogin "+mail); FXPlanet.doing_login = false; user_logged = true; user_email = mail; user_alias = alias; user_country = country; user_country_birth = country_birth; SetCookie("user_email",(user_hold_logged!==false)?user_email:""); $("input[name=alias]").val(user_alias); ShowPage(page); if (typeof BarraProgreso=='undefined' || FXPlanet.social_user!="") user_email_validated = true; else // activa el texto "email" de la barra de progreso FXPlanet.AjaxCall("ajax/is_validated.php", {}, function(xml) { user_email_validated = GetXMLData(xml,'result')=='ok'; if (user_email_validated) BarraProgreso.setEmail(); }); // estadística de gente nueva que hace login FXPlanet.SendStat("has_ever_logged","web_new_user_logged"); // comprobacion de usuario baneado FXPlanet.AjaxCallEx("ajax/generic.php", { call: "User.CheckBan", Game: game_id }, function(reply) { if (reply._resultStr=="WC_ERROR_BANNED") { var message = 'Tu cuenta ha sido desactivada hasta el $date.

Razón: $reason'; message = message.replace('$date',reply.BanEndDate).replace('$reason',reply.BanReason); ShowMessage('Cuenta desactivada',message,false); GameExit("",function(){}); } }); if (onlogin_open_edituser) OpenEditUserWindow(true,FXPlanet.IsPluginInstalled()); if (onlogin_open_shop) FXPlanet.OpenPfxWindow(); FBCheck(); } FXPlanet.Event.subscribe('login', OnLogin); function Logout(cb_ok) { user_logged = FXPlanet.social_user_logged = user_email_validated = false; user_email = ''; FXPlanet.AjaxCall("ajax/logout.php", {}, function(xml) { SetCookie("user_email",""); SetCookie("user_pass_known","false"); if (typeof cb_ok==='function') cb_ok(); }); } //Redirige al juego los eventos de pérdida y adquisición de foco de la web, para pausarlo si pierde el foco var active_element; function SetFocusEvents() { // [ALFON] document.activeElement produce error de js no previsible en IE //active_element = document.activeElement; if (FXPlanet.is_explorer) { document.onfocusout = function() { OnWindowBlur(); }; document.onfocusin = function() { OnWindowFocus(); }; } else { window.onblur = function() { OnWindowBlur(); }; window.onfocus = function() { OnWindowFocus(); }; } } function OnWindowFocus() { if (FXPlanet.game_avoid_show.length==0 && $(".overlay_box").length==0) FXPlanet.CallLauncher("notify?data=focus"); } function OnWindowBlur() { // [ALFON] document.activeElement produce error de js no previsible en IE //if (active_element != document.activeElement) { // active_element = document.activeElement; // return; //} //FXPlanet.CallLauncher("notify?data=blur"); } function SendTraces() { var obj_traces = document.getElementById("debug_log"); if (obj_traces!=null) FXPlanet.AjaxCallEx("ajax/trace_error.php", { trace: uniqid+": "+obj_traces.innerHTML }, function(reply) { }); setTimeout(SendTraces,5000); } function InitTraces() { // envio de trazas periodicamente if (FXPlanet.get_params.indexOf("trace_errors")!=-1) SendTraces(); DebugLog("userAgent: "+navigator.userAgent); DebugLog("appVersion: "+navigator.appVersion); DebugLog("get_params: "+FXPlanet.get_params); } setTimeout(InitTraces,5000); FXPlanet.VastSet = function(xml,cb_ok) { FXPlanet.vast_videos = $('VAST > Ad > InLine',xml); if (FXPlanet.vast_videos.length==0) { var wrapperUrl = $.trim($('VAST > Ad > Wrapper > VASTAdTagURI',xml).text()); if (wrapperUrl!='') { FXPlanet.VastInitTrack(FXPlanet.vast_tracking_initial,xml); FXPlanet.VastSetUrl(wrapperUrl,cb_ok); } else FXPlanet.CallLauncher("notify?data=play_ad_ko"); } else if (typeof cb_ok==='function') cb_ok(); } FXPlanet.VastSetUrl = function(url) { FXPlanet.vast_url = url; } FXPlanet.VastGetAdName = function() { if (FXPlanet.vast_videos.length==0 || typeof jwplayer=='undefined') return ''; else return $('AdTitle',FXPlanet.vast_videos[0]).text(); } FXPlanet.VastInitTrack = function(track,xmlData) { var AddTrack = function(track,name,selector,xmlData) { $(selector,xmlData).each(function(index) { var url = $.trim($(this).text()); if (typeof track[name]=='undefined') track[name] = []; if (url!='') track[name].push(url); }); }; AddTrack(track,'impression','Impression',xmlData); AddTrack(track,'start','Tracking[event="start"]',xmlData); AddTrack(track,'midpoint','Tracking[event="midpoint"]',xmlData); AddTrack(track,'complete','Tracking[event="complete"]',xmlData); AddTrack(track,'mute','Tracking[event="mute"]',xmlData); AddTrack(track,'pause','Tracking[event="pause"]',xmlData); AddTrack(track,'fullscreen','Tracking[event="fullscreen"]',xmlData); AddTrack(track,'firstQuartile','Tracking[event="firstQuartile"]',xmlData); AddTrack(track,'midpoint','Tracking[event="midpoint"]',xmlData); AddTrack(track,'thirdQuartile','Tracking[event="thirdQuartile"]',xmlData); AddTrack(track,'click','ClickTracking',xmlData); } FXPlanet.VastTrack = function(arrTracks) { for (var i=0; i error: "+textStatus+"-"+errorThrown); FXPlanet.CallLauncher("notify?data=play_ad_ko"); }, success: function(xml) { FXPlanet.VastSet(xml,function() { DebugLog('VastPlayAd leidos '+FXPlanet.vast_videos.length+' videos de '+FXPlanet.vast_url); if (FXPlanet.vast_videos.length==0 || typeof jwplayer=='undefined') { FXPlanet.CallLauncher("notify?data=play_ad_ko"); return; } var video_data = FXPlanet.vast_videos[0]; FXPlanet.vast_tracking = CloneObject(FXPlanet.vast_tracking_initial); FXPlanet.VastInitTrack(FXPlanet.vast_tracking,video_data); FXPlanet.vast_position = 0.0; var urlFile = $.trim($('MediaFile[delivery="progressive"]:first',video_data).text()); var bestDist = 1000000; $('MediaFile[delivery="progressive"]',video_data).each(function(index) { var dist = Math.abs(parseInt($(this).attr('bitrate'))-600); if (dist0.75 && FXPlanet.vast_position<=0.75) FXPlanet.VastTrack(FXPlanet.vast_tracking['thirdQuartile']); if (position>0.50 && FXPlanet.vast_position<=0.50) FXPlanet.VastTrack(FXPlanet.vast_tracking['midpoint']); if (position>0.25 && FXPlanet.vast_position<=0.25) FXPlanet.VastTrack(FXPlanet.vast_tracking['firstQuartile']); FXPlanet.vast_position = position; } } }); jwplayer().play(); ShowPage('page_vast'); }); } }); }