$host='http://client.pc.letv.com';
if(typeof Base=='undefined'){window.Base={}}
(function(){var topics={},caches={},observer,cache;observer=function(id){var callbacks,topic=id&&topics[id];if(!topic){callbacks=$.Callbacks();topic={publish:callbacks.fire,subscribe:callbacks.add,unsubscribe:callbacks.remove};if(id){topics[id]=topic}}return topic};cache=function(id){var cacheObj=id&&caches[id];if(!cacheObj){var os=Base.observer(id);var _value=null;cacheObj={set:function(value){_value=value;os.publish(value)},get:function(){return _value},subscribe:os.subscribe,unsubscribe:os.unsubscribe};if(id){caches[id]=cacheObj}}return cacheObj};Base.observer=observer;Base.cache=cache})();
(function(){window.pcEvent=function(type,param){if(!type)return;Base.observer('pcEvent-'+type).publish(param)};var isPc=false;try{window.external.jsToPc('js:checkIsPc');isPc=true}catch(e){isPc=false}Base.CustomEvent={resize:function(handle){if(isPc){Base.observer('pcEvent-resize').subscribe(handle)}else{$(window).resize(handle)}},wndModeSwitch:function(handle){Base.observer('pcEvent-wndModeSwitch').subscribe(handle)},minimize:function(handle){Base.observer('pcEvent-minimize').subscribe(handle)},unbind:function(type,handle){switch(type){case'resize':if(isPc){Base.observer('pcEvent-resize').unsubscribe(handle)}else{$(window).unbind('resize',handle)}break;case'minimize':Base.observer('pcEvent-minimize').unsubscribe(handle)}}}})();
(function(){Base.CustomEvent.resize(dyCss)})();
(function(){var Json={toStr:function(obj){switch(typeof(obj)){case'string':return'"'+obj.replace(/(["\\])/g,'\\$1')+'"';case'array':return'['+obj.map(arguments.callee).join(',')+']';case'object':if(obj instanceof Array){var strArr=[];var len=obj.length;for(var i=0;i<len;i++){strArr.push(arguments.callee(obj[i]))}return'['+strArr.join(',')+']'}else if(obj==null){return'null'}else{var string=[];for(var property in obj)string.push(arguments.callee(property)+':'+arguments.callee(obj[property]));return'{'+string.join(',')+'}'}case'number':return obj;case false:return obj;case undefined:return''}},toJson:function(str){return eval('('+str+')')}};Base.Json=Json})();
(function(){var handles={};window.pcToJs=function(){var param=Base.Json.toJson(arguments[1]);var handle=handles[param.to];if(!handle)return;for(var i=0,len=handle.length;i<len;i++){handle[i](param)}};window.addPcListener=function(type,handle){if(typeof handle!='function')return;if(!handles[type]){handles[type]=[]}handles[type].push(handle)};var pcInterface=function(type,setting){type=type||'';setting=setting||{};var param;switch(type){case'playVideo':param={to:'player',cmd:'play',vsource:'letv',url:$host+'/play/'+setting.vid+(setting.htime?'?htime='+setting.htime:''),follow:''};break;case'saveHistory':param={to:'webHistory',cmd:'save',url:location.href,type:$config.$product};break;case'fullPreview':param={to:'fullPreview',cmd:'action',url:location.href};break;case'wndModeContrller':param={to:'wndModeContrller',cmd:''};break;default:param={}}try{$.extend(param,setting);param=Base.Json.toStr(param);window.external.jsToPc(param);try{console.log('jsToPc: '+Base.Json.toStr(param))}catch(e){}}catch(e){if($.browser.msie&&$.browser.version==6)return;try{console.log('pc客户端接口jsToPc异常：'+Base.Json.toStr(param))}catch(e){}}};var pcSynInterface={getMacId:function(){try{var macidStr=window.external.getMacId().split(',');return{macid_md5:macidStr[0],macid:macidStr[1]}}catch(e){return{macid_md5:'error',macid:'error'}}},getClientLc:function(){try{return window.external.getLc()}catch(e){return'error'}},isPlaying:function(){try{return window.external.isPlaying()}catch(e){return'1'}},getLog:function(size){try{size=(size||10)*1024;return window.external.getLog(size)}catch(e){return'error'}},selectFolder:function(){try{return window.external.selectFolder()}catch(e){return'error'}},openUrl:function(tabName,url){if(!url)return;try{switch(tabName){case'userCenter':window.external.openUserCenterTab(url);break;case'playRecorder':window.external.openPlayRecorderTab(url);break;case'player':window.external.openPlayerWebTab(url);break;case'home':default:window.external.openHomeTab(url)}}catch(e){window.open(url,'_blank')}},openPage:function(type){try{window.external.openPage(type)}catch(e){}},openFolder:function(path){try{window.external.openFolder(path)}catch(e){}}};Base.pcInterface=pcInterface;Base.pcSynInterface=pcSynInterface})();
(function(){Base.pcInterface('saveHistory')})();
if(typeof Model=='undefined'){window.Model={}}
(function(){var Request={getInfo:function(){var param={"to":"updater","from":"updateui","cmd":"getInfo"};Base.pcInterface('',param)},start:function(){var param={"to":"updater","from":"updateui","cmd":"start"};Base.pcInterface('',param)}};var Response={_handles:{},addListener:function(type,handle){if(!this._handles[type]){this._handles[type]=[]}if(typeof handle!='function')return;this._handles[type].push(handle)}};window.addPcListener('updateui',function(param){if(param.cmd){var fns=Response._handles[param.cmd]||[];for(var i=0,len=fns.length;i<len;i++){fns[i](param)}}});Model.UpdateVersion={Request:Request,Response:Response}})();
(function(){function addEvent(){$('#setting-page').click(function(){Base.pcSynInterface.openPage('setting')});$('#version').click(function(){var targetNode=$(this).closest('p'),now=targetNode.attr('now'),newer=targetNode.attr('newer');location.href=$host+'/version?nowver='+now+'&newver='+newer})}function checkVersion(){Model.UpdateVersion.Response.addListener('getInfo',function(param){var data=param.data,targetNode=$('#version').closest('p');targetNode.attr({now:data.nowVersion,newer:data.newVersion});if(data.nowVersion!=data.newVersion){targetNode.addClass('active')}});Model.UpdateVersion.Request.getInfo()}function main(){addEvent();checkVersion()}main()})();
$(document).ready(function(){$(document).bind('contextmenu',function(){return false})});
(function(){var nodes={left:$('div.menu'),right:$('div.ice-body')};Base.CustomEvent.resize(resizeFn);function resizeFn(){var wh=$(window).height();nodes.left.height(wh);nodes.right.height(wh-20)}resizeFn();nodes.left.find('div.ice').show()})();
(function(){var Request={get:function(){var param={"to":"settinger","from":"settingui","cmd":"get"};Base.pcInterface('',param)},set:function(data){var param={"to":"settinger","from":"settingui","cmd":"set","data":data};Base.pcInterface('',param)},setDefault:function(){var param={"to":"settinger","from":"settingui","cmd":"setDefault"};Base.pcInterface('',param)}};var Response={_handles:{},addListener:function(type,handle){if(!this._handles[type]){this._handles[type]=[]}if(typeof handle!='function')return;this._handles[type].push(handle)}};window.addPcListener('settingui',function(param){var fns=Response._handles[param.cmd]||[];for(var i=0,len=fns.length;i<len;i++){fns[i](param)}});Model.Setting={Request:Request,Response:Response}})();
if(typeof Widget=='undefined'){window.Widget={}}
(function(){var Dialog=function(model,param){this.dialogNode=model.slice(0,1)=='#'?$(model):$(model).appendTo('body');this.width=param.width||this.dialogNode.outerWidth();this.height=param.height||this.dialogNode.outerHeight();if(param.hasShadow){this.shadow=$('<div class="white-body" style="display: none;"></div>').appendTo('body')}if(param.isOverFlash){this.overFlashFrame=$('<iframe style="position: absolute;visibility: hidden;overflow: hidden;width:'+this.width+'px;height:'+this.height+'px;background-color:#333"></iframe>').appendTo('body')}this.shadowEvent=typeof param.shadowEvent=='undefined'?true:param.shadowEvent;this.hiddenFn=param.hiddenFn;this.addEvent();this.resize()};Dialog.prototype={show:function(){this.dialogNode.css('visibility','visible');this.overFlashFrame&&this.overFlashFrame.css('visibility','visible');this.shadow&&this.shadow.show()},hide:function(){this.dialogNode.css('visibility','hidden');this.overFlashFrame&&this.overFlashFrame.css('visibility','hidden');this.shadow&&this.shadow.hide();this.hiddenFn&&this.hiddenFn()},setCenter:function(){var ww=$(window).width(),wh=$(window).height();this.dialogNode.css('top',(wh-this.height)/2);this.shadow&&this.shadow.css({width:ww,height:wh})},resize:function(){if(this.overFlashFrame){this.overFlashFrame.css({width:this.dialogNode.outerWidth(),height:this.dialogNode.outerHeight(),left:this.dialogNode.offset().left,top:this.dialogNode.offset().top})}},addEvent:function(){var self=this;if(this.shadow&&this.shadowEvent){this.shadow.click(function(){self.hide()})}Base.CustomEvent.resize($.proxy(this.resize,this))}};Widget.Dialog=Dialog})();
(function(){var _dialogs=[];var isShowing=false;function showDialog(){if(!isShowing&&_dialogs.length){isShowing=true;var obj=_dialogs.shift();switch(obj.type){case'info':infoDialog.show(obj.msg,obj.time);break;case'info2':info2Dialog.show(obj.msg,obj.subMsg,obj.time);break;case'alert':alertDialog.show(obj.msg,obj.submsg,obj.cb);break;case'confirm':confirmDialog.show(obj.msg,obj.cb);break}}}function info(msg,time){_dialogs.push({type:'info',msg:msg,time:time});showDialog()}function info2(msg,subMsg,time){_dialogs.push({type:'info2',msg:msg,subMsg:subMsg,time:time});showDialog()}function alert(msg,submsg,cb){_dialogs.push({type:'alert',msg:msg,submsg:submsg,cb:cb});showDialog()}function confirm(msg,cb){_dialogs.push({type:'confirm',msg:msg,cb:cb});showDialog()}var infoDialog={dialog:null,_model:['<div class="hint ht-250">','<table width="100%" cellspacing="0" cellpadding="0" border="0">','<tbody><tr>','<td class="t-l">&nbsp;</td>','<td class="t-c">&nbsp;</td>','<td class="t-r">&nbsp;</td>','</tr>','<tr>','<td class="c-l">&nbsp;</td>','<td class="c-c"><p id="advise-info-msg" class="p-c">成功追剧到播放单</p></td>','<td class="c-r">&nbsp;</td>','</tr>','<tr>','<td class="b-l">&nbsp;</td>','<td class="b-c">&nbsp;</td>','<td class="b-r">&nbsp;</td>','</tr></tbody>','</table>','</div>'].join(''),initDialog:function(){this.dialog=new Widget.Dialog(this._model,{isOverFlash:true,hiddenFn:function(){isShowing=false;showDialog()}})},show:function(msg,time){if(!this.dialog){this.initDialog()}$('#advise-info-msg').html(msg);this.dialog.show();var self=this;setTimeout(function(){self.dialog.hide()},time||1500)}};var info2Dialog={dialog:null,_model:['<div class="hint ht-400 ht-commen">','<h2 id="advise-info2-msg" class="ht-commen-title"></h2>','<p id="advise-info2-submsg" class="ht-commen-con"></p>','</div>'].join(''),initDialog:function(){this.dialog=new Widget.Dialog(this._model,{isOverFlash:true,hiddenFn:function(){isShowing=false;showDialog()}})},show:function(msg,subMsg,time){if(!this.dialog){this.initDialog()}$('#advise-info2-msg').html(msg||'');$('#advise-info2-submsg').html(subMsg||'');this.dialog.show();var self=this;setTimeout(function(){self.dialog.hide()},time||1500)}};var alertDialog={dialog:null,_model:['<div class="hint ht-400">','<table width="100%" cellspacing="0" cellpadding="0" border="0">','<tbody><tr>','<td class="t-l">&nbsp;</td>','<td class="t-c">&nbsp;</td>','<td class="t-r">&nbsp;</td>','</tr>','<tr>','<td class="c-l">&nbsp;</td>','<td class="c-c"><ul class="ht-file">','<li id="advise-alert-msg" class="li01">无法找到视频文件</li>','<li id="advise-alert-submsg" class="li02">请确认视频文件是否被移动或删除</li>','<li class="li03"><a id="advise-alert-btn" class="btn" title="" href="#">确定</a></li>','</ul></td>','<td class="c-r">&nbsp;</td>','</tr>','<tr>','<td class="b-l">&nbsp;</td>','<td class="b-c">&nbsp;</td>','<td class="b-r">&nbsp;</td>','</tr></tbody>','</table>','</div>'].join(''),initDialog:function(){var self=this;this.dialog=new Widget.Dialog(this._model,{hasShadow:true,hiddenFn:function(){isShowing=false;showDialog()}})},show:function(msg,submsg,cb){var self=this;if(!this.dialog){this.initDialog()}$('#advise-alert-msg').html(msg||'');$('#advise-alert-submsg').html(submsg||'');$('#advise-alert-btn').unbind('click').bind('click',function(){self.dialog.hide();cb&&cb()});this.dialog.show()}};var confirmDialog={dialog:null,_model:['<div class="hint ht-400">','<table width="100%" cellspacing="0" cellpadding="0" border="0">','<tbody><tr>','<td class="t-l">&nbsp;</td>','<td class="t-c">&nbsp;</td>','<td class="t-r">&nbsp;</td>','</tr>','<tr>','<td class="c-l">&nbsp;</td>','<td class="c-c"><dl class="clear-play">','<dt id="advise-confirm-msg">您确定清空播放记录？</dt>','<dd><a id="advise-confirm-submit" class="btn" href="#">确定</a><a id="advise-confirm-cancel" class="btn" href="#">取消</a></dd>','</dl></td>','<td class="c-r">&nbsp;</td>','</tr>','<tr>','<td class="b-l">&nbsp;</td>','<td class="b-c">&nbsp;</td>','<td class="b-r">&nbsp;</td>','</tr></tbody>','</table>','</div>'].join(''),initDialog:function(){var self=this;this.dialog=new Widget.Dialog(this._model,{hasShadow:true,hiddenFn:function(){isShowing=false;showDialog()}});$('#advise-confirm-cancel').click(function(){self.dialog.hide()})},show:function(msg,cb){var self=this;if(!this.dialog){this.initDialog()}$('#advise-confirm-msg').html(msg);$('#advise-confirm-submit').unbind('click').bind('click',function(){self.dialog.hide();cb&&cb()});this.dialog.show()}};Widget.advise={info:info,info2:info2,alert:alert,confirm:confirm}})();
(function(){var nodes={setDefault:$('#set-default'),startWithComputer:$('#start-with-computer'),autoDownload:$('#auto-download'),smallApp:$('#small-app'),closeApp:$('#close-app'),closePopWindow:$('#close-pop-windows'),downloadLimit:$('#download-limit'),downloadLimitNum:$('#download-limit a'),downloadLimitList:$('#download-limit-list'),downloadFolder:$('#download-folder'),downloadFolderSelect:$('#download-folder-select'),openFolder:$('#open-download-folder')};function main(){addEvent();Model.Setting.Request.get()}function init(result){var data=result.data;data.startWithComputer=='1'?nodes.startWithComputer.addClass('active'):nodes.startWithComputer.removeClass('active');data.autoDownload=='1'?nodes.autoDownload.addClass('active'):nodes.autoDownload.removeClass('active');nodes.smallApp.removeClass('active');nodes.closeApp.removeClass('active');data.closeType=='small'?nodes.smallApp.addClass('active'):nodes.closeApp.addClass('active');data.closePopWindows=='1'?nodes.closePopWindow.addClass('active'):nodes.closePopWindow.removeClass('active');nodes.downloadLimitNum.html(data.downloadLimit);nodes.downloadFolder.html(data.downloadFolder).attr('title',data.downloadFolder)}function addEvent(){Model.Setting.Response.addListener('get',init);Model.Setting.Response.addListener('setDefault',init);nodes.setDefault.click(function(){Model.Setting.Request.setDefault();showTip(this)});nodes.startWithComputer.click(function(){$(this).toggleClass('active');Model.Setting.Request.set({startWithComputer:$(this).hasClass('active')?1:0});showTip(this)});nodes.autoDownload.click(function(){$(this).toggleClass('active');Model.Setting.Request.set({autoDownload:$(this).hasClass('active')?1:0});showTip(this)});nodes.smallApp.click(function(){$(this).addClass('active');nodes.closeApp.removeClass('active');Model.Setting.Request.set({closeType:'small'});showTip(this)});nodes.closeApp.click(function(){$(this).addClass('active');nodes.smallApp.removeClass('active');Model.Setting.Request.set({closeType:'close'});showTip(this)});nodes.closePopWindow.click(function(){$(this).toggleClass('active');Model.Setting.Request.set({closePopWindows:$(this).hasClass('active')?1:0});showTip(this)});nodes.downloadLimit.click(function(evt){evt.stopPropagation();nodes.downloadLimitList.fadeIn('fast')});nodes.downloadLimitList.delegate('li','click',function(){nodes.downloadLimitList.hide();var num=$(this).find('a').html();nodes.downloadLimitNum.html(num);Model.Setting.Request.set({downloadLimit:num});showTip(this)});$(document).click(function(){nodes.downloadLimitList.hide()});nodes.downloadFolderSelect.click(function(){var folder=Base.pcSynInterface.selectFolder();if(folder=='error'){Widget.advise.alert('请设置下载路径到非系统盘');return}if(folder){nodes.downloadFolder.html(folder).attr('title',folder);Model.Setting.Request.set({downloadFolder:folder});showTip(this)}});nodes.openFolder.click(function(){var path=$.trim(nodes.downloadFolder.html());Base.pcSynInterface.openFolder(path)})}function showTip(node){var tipNode=$(node).closest('dd,dt').find('em.ico-yes').stop().show();clearTimeout(tipNode[0].autoTime);tipNode[0].autoTime=setTimeout(function(){tipNode.fadeOut('fast')},600)}main()})();
