text: S.SSCL.Games=Backbone.Collection.extend({model:S.SSMO.Game,initialize:function(){_.bindAll(this,"parse")},parse:function(e){return e.data}});S.SSCT.Game=Backbone.Controller.extend({initialize:function(){_.bindAll(this)},validate:function(e,s){this.validModel=S.SSCT.GetHandler("Model","ValidCode"),this.validModel.on("error",_.bind(function(e,a){s.error(a.msg||a),this.validModel.off("error")},this));var a=this.validModel.set({alphaCode:e});a&&this.validModel.validCode({alphaCode:e},{success:s.success,error:function(e,a){console.log("resp",a),s.error(a.msg)}})},getGameInfo:function(e){if(null==this.gameId){var s=S.sdkBase.request(S.sdkBase.servType.COMMON,S.sdkBase.actions.GET_GAME_INFO);s&&s.success?(this.gameId=s.data.gameId,this.gameInfo=s.data,e&&e.success&&e.success.apply(this,[s.data])):e&&e.error&&e.error.apply(this,[s])}else _.isUndefined(e)||_.isUndefined(e.success)||!_.isFunction(e.success)||e.success.apply(this,[this.gameInfo])},getOptnTestGameInfo:function(e){S.SSCT.GetHandler("Model","Game").getOptnTestGameInfo({success:function(s,a){e.success(a.data)},error:function(s,a){e.error(a.data)},quiet:!0})}});S.SSCT.GameLn=Backbone.Controller.extend({initialize:function(){_.bindAll(this)},validate:function(e,s){this.validModel=S.SSCT.GetHandler("Model","ValidCode"),this.validModel.on("error",_.bind(function(e,a){s.error(a.msg||a),this.validModel.off("error")},this));var a=this.validModel.set({alphaCode:e});a&&this.validModel.validCode({alphaCode:e},{success:s.success,error:function(e,a){console.log("resp",a),s.error(a.msg)}})},getGameInfo:function(e){if(null==this.gameId){var s=S.sdkBase.request(S.sdkBase.servType.COMMON,S.sdkBase.actions.GET_GAME_INFO);s&&s.success?(this.gameId=s.data.gameId,this.gameInfo=s.data,e&&e.success&&e.success.apply(this,[s.data])):e&&e.error&&e.error.apply(this,[s])}else _.isUndefined(e)||_.isUndefined(e.success)||!_.isFunction(e.success)||e.success.apply(this,[this.gameInfo])},getOptnTestGameInfo:function(e){S.SSCT.GetHandler("Model","GameLn").getOptnTestGameInfo({success:function(s,a){e.success(a.data)},error:function(s,a){e.error(a.data)},quiet:!0})}});S.SSMO.Game=Backbone.Model.extend({initialize:function(){_.bindAll(this)},getOptnTestGameInfo:function(e){this.url=S.sdkBase.servType.SDKSERVER+"/"+S.sdkBase.actions.CALL_SDK_SERVER+"/"+rConfig.apis.GET_OPENTEST_GAME_INFO,this.fetch(e)},parse:function(e){return e.data}});S.SSMO.GameLn=Backbone.Model.extend({initialize:function(){_.bindAll(this)},getOptnTestGameInfo:function(e){this.url=S.sdkBase.servType.SDKSERVER+"/"+S.sdkBase.actions.CALL_SDK_SERVER+"/"+rConfig.apis.GET_OPENTEST_GAME_INFO,this.fetch(e)},parse:function(e){return e.data}});S.SSMO.ValidCode=Backbone.Model.extend({initialize:function(){_.bindAll(this),this.url=S.sdkBase.servType.SDKSERVER+"/"+S.sdkBase.actions.CALL_SDK_SERVER+"/"+rConfig.apis.VALID_CODE},validate:function(e){if(!this.isRequest){if(_.isUndefined(e.alphaCode)&&_.isEmpty(e.alphaCode))return"激活码不能为空";if(6!=e.alphaCode.length||e.alphaCode.match(/[^a-z0-9A-Z]+/))return"请输入正确的激活码"}this.isRequest=!1},validCode:function(e,i){this.save(e,i)},parse:function(e){return this.isRequest=!0,e.data}});S.SSVW.Game=Backbone.View.extend({el:"#gameContainer",events:{"onclick #bbsLink":"linkToBBS","onclick #gameCenterLink":"linkToGameCenter","onclick #confirmValidCode":"doConfirm","onclick #exitValidCode":"doExit","onclick #clearCode":"flushInpt","onclick #clearValidCode":"clearValidCode","onclick #validCode":"_inputFocuse","focusout #validCode":"hideClrPass","onclick #toUserCenterLink":"gotoUserCenter","onclick #gotoValidCodeCenter":"gotoValidCodeCenter"},config:{VALID_CODE_ROUTE:"#!game/testWidthCode/[code]"},isRandom:null,initialize:function(){_.bindAll(this),this.gameController=S.SSCT.GetHandler("Controller","Game")},notOpen:function(){S.SCEV.Proxy.trigger(S.SCEV.EventType.PRE_ROUTE,{enterPage:sdk.Log.businesses.PAGE_GAME,enterBusiness:["notOpen"]});var e=this.$el.find("#gameNotOpenMsg"),n="openTestGameMsg",o="";this.gameController.getOptnTestGameInfo(this.gameController.callBackMix(function(i){"B"!=i.status||_.isUndefined(i.message)||_.isEmpty(i.message)?o=ucf.Cache.get(n,!0):(o=i.message,ucf.Cache.set(n,o,3600,!0)),_.isEmpty(o)||e.html(o),e.show()},function(){o=ucf.Cache.get(n,!0),_.isEmpty(o)||e.html(o),e.show()}))},validCode:function(e){S.SCEV.Proxy.trigger(S.SCEV.EventType.PRE_ROUTE,{enterPage:sdk.Log.businesses.PAGE_GAME,enterBusiness:["validateCode"]}),this.isRandom=_.isUndefined(e)||_.isEmpty(e)?"false":e,this.changeClrPass(),this.initLogoutBtn()},testWidthCode:function(e){_.isEmpty(e)||"[code]"===e||$("#validCode").val(e),this.validCode.call(this)},doConfirm:function(){var e=this,n=this.$el.find("#validCode").val(),o=S.SSCT.GetHandler("Controller","User"),i=this.$el.find("#confirmValidCode");i.attr("disabled","disabled"),i.attr("data-disabled","true").addClass("ui-disabled"),this.gameController.validate(n,this.gameController.callBackMix(function(e,n){o.notifyCp({code:n.code,msg:n.msg},o.callBackMix(o.sdkExit))},function(n){e._showErrorMsg(n,"#validCodeNoticeBox"),i.removeAttr("disabled"),i.attr("data-disabled","").removeClass("ui-disabled")}))},doExit:function(){S.Log.pageClose(),S.SSCT.GetHandler("Controller","User").sdkExit()},flushInpt:function(){_.isUndefined(this.noticeBar)||_.isEmpty(this.noticeBar)||sdk.common.ui.NoticeBox.hide(this.noticeBar,null,"slide"),this.$el.find("#validCode").val("")},clearValidCode:function(){this.$el.find("#validCode").val(""),this.changeClrPass()},changeClrPass:function(){_.isEmpty($("#validCode").val())?this.$el.find("#clearValidCode").hide():this.$el.find("#clearValidCode").show()},hideClrPass:function(){this.$el.find("#clearValidCode").hide()},initLogoutBtn:function(){S.SCEV.Proxy.trigger(S.SCEV.EventType.SDK_REMOVE_WIN_EVENT,{eventName:"bridgeTopBtnClicked"}),S.SCEV.Proxy.trigger(S.SCEV.EventType.SDK_WINDOW_EVENT,{eventName:"bridgeTopBtnClicked",handler:function(e){"logout"==e.action&&(S.sdkBase.request(S.sdkBase.servType.LOGIN,S.sdkBase.actions.LOGOUT),S.SSCT.GetHandler("Controller","User").sdkExit())}})},linkToBBS:function(){sdk.Log.pageEnter(sdk.Log.businesses.PAGE_GAME,["bbsClick"]),sdk.Log.pageClose(sdk.Log.businesses.PAGE_GAME,["bbsClick"]),sdk.PageCache.set("sdk_redirect_out",1),S.global.otherChannel?window.location.href=S.global.channelSetting.bbsLink:S.Url.redirect("../bbs/bbs.html")},linkToGameCenter:function(){sdk.Log.pageClose(sdk.Log.businesses.PAGE_GAME,["notOpen"]),sdk.Log.pageEnter(sdk.Log.businesses.PAGE_GAME,["gameCenter"]),S.Url.redirect(eConfig.gameCenter)},_inputFocuse:function(){this.changeClrPass()},_showErrorMsg:function(e,n,o){S.SSCT.GetHandler("Controller","General").sendClientMsg(e),o&&o.apply()},gotoUserCenter:function(){sdk.Log.click(sdk.Log.businesses.PAGE_USER,["h5_ValidCode_to_UserCenter_l"]),S.Url.redirect("../user/user.html#!user")},gotoValidCodeCenter:function(){function e(e,n,o,t,l,r){var a=[];a.push("from="+e),a.push("caller="+n),a.push("version="+o),a.push("gameId="+t),a.push("sid="+l),"Test"===i&&a.push("callback="+encodeURIComponent(window.location.href.replace(window.location.hash,"")+s.config.VALID_CODE_ROUTE)),S.Url.redirect(eConfig.validCodeCenterUrl+"?"+a.join("&")+r)}function n(e){S.SSCT.GetHandler("Controller","User").getCurUserInfo({success:e,error:o})}function o(e){e&&s._showErrorMsg(e.msg||e)}var i=this.$el.find("#gotoValidCodeCenter").data("source"),t=this.$el.find("#gotoValidCodeCenter").data("from");if(sdk.Log.click(sdk.Log.businesses.PAGE_USER,["h5_Code_p",i]),S.global.otherChannel)return this.gameController.getGameInfo({success:function(e){var n=e.gameId,o=e.channelId;window.location.href=S.global.channelSetting.codecenterLink+"?"+"gameid="+n+"&channelid="+o},error:function(e){s._showErrorMsg(e.msg)}}),void 0;var s=this,l=new RegExp("(^|\\?|&)from=([^&]*)(\\s|&|$)","i");if(l.test(location.href)){var r=unescape(RegExp.$2.replace(/\+/g," "));-1!=r.indexOf("#")&&(r=r.substr(0,r.indexOf("#"))),r.length>0&&(t=r)}this.gameController.getGameInfo({success:function(o){var s=o.gameId;n(function(n){var o=S.global.version;e(t,"sdk",o,s,n.sid,"#!codeCenter/"+i)})},error:function(e){s._showErrorMsg(e.msg)}})}});S.SSVW.GameLn=Backbone.View.extend({el:"#gameContainer",events:{"onclick #confirmValidCodeLn":"doConfirm","onclick #clearValidCodeLn":"clearValidCode","focusout #validCodeLn":"hideClrPass","onclick #toUserCenterLinkLn":"gotoUserCenterFromValidCode","onclick #enterUserCenterBtn":"gotoUserCenterFromNotOpen"},isRandom:null,initialize:function(){_.bindAll(this),this.gameController=S.SSCT.GetHandler("Controller","GameLn")},notOpen:function(){S.SCEV.Proxy.trigger(S.SCEV.EventType.PRE_ROUTE,{enterPage:sdk.Log.businesses.PAGE_GAME,enterBusiness:["notOpen"]});var e=this.$el.find("#gameNotOpenMsgLn"),n="openTestGameMsg",t="";this.gameController.getOptnTestGameInfo(this.gameController.callBackMix(function(i){"B"!=i.status||_.isUndefined(i.message)||_.isEmpty(i.message)?t=ucf.Cache.get(n,!0):(t=i.message,ucf.Cache.set(n,t,3600,!0)),_.isEmpty(t)||e.html(t),e.show()},function(){t=ucf.Cache.get(n,!0),_.isEmpty(t)||e.html(t),e.show()}))},validCode:function(e){S.SCEV.Proxy.trigger(S.SCEV.EventType.PRE_ROUTE,{enterPage:sdk.Log.businesses.PAGE_GAME,enterBusiness:["validateCode"]}),this.isRandom=_.isUndefined(e)||_.isEmpty(e)?"false":e,this.changeClrPass(),this.initLogoutBtn()},testWidthCode:function(e){_.isEmpty(e)||"[code]"===e||$("#validCode").val(e),this.validCode.call(this)},doConfirm:function(){var e=this,n=this.$el.find("#validCodeLn").val(),t=S.SSCT.GetHandler("Controller","UserLn"),i=this.$el.find("#confirmValidCodeLn");i.attr("disabled","disabled"),i.attr("data-disabled","true").addClass("ui-disabled"),this.gameController.validate(n,this.gameController.callBackMix(function(e,n){t.notifyCp({code:n.code,msg:n.msg},t.callBackMix(t.sdkExit))},function(n){e._showErrorMsg(n,"#validCodeNoticeBoxLn"),i.removeAttr("disabled"),i.attr("data-disabled","").removeClass("ui-disabled")}))},flushInpt:function(){_.isUndefined(this.noticeBar)||_.isEmpty(this.noticeBar)||sdk.common.ui.NoticeBox.hide(this.noticeBar,null,"slide"),this.$el.find("#validCodeLn").val("")},clearValidCode:function(){this.$el.find("#validCodeLn").val(""),this.changeClrPass()},changeClrPass:function(){_.isEmpty($("#validCodeLn").val())?$("#clearValidCodeLn").hide():$("#clearValidCodeLn").show()},hideClrPass:function(){$("#clearValidCodeLn").hide()},initLogoutBtn:function(){S.SCEV.Proxy.trigger(S.SCEV.EventType.SDK_REMOVE_WIN_EVENT,{eventName:"bridgeTopBtnClicked"}),S.SCEV.Proxy.trigger(S.SCEV.EventType.SDK_WINDOW_EVENT,{eventName:"bridgeTopBtnClicked",handler:function(e){"logout"==e.action&&(S.sdkBase.request(S.sdkBase.servType.LOGIN,S.sdkBase.actions.LOGOUT),S.SSCT.GetHandler("Controller","UserLn").sdkExit())}})},_showErrorMsg:function(e,n,t){S.SSCT.GetHandler("Controller","General").sendClientMsg(e),t&&t.apply()},gotoUserCenterFromValidCode:function(){sdk.Log.click(sdk.Log.businesses.PAGE_USER,["h5_ValidCode_to_UserCenter_l"]),S.Url.redirect("../user/user.html#!user")},gotoUserCenterFromNotOpen:function(){S.Url.redirect("../user/user.html#!user")}});