forked from immosmart/smartbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smartbox.min.js
2 lines (2 loc) · 47.6 KB
/
smartbox.min.js
1
2
!function(){function a(a){return-1!==f.indexOf(a)}var b,c,d=!1,e=[],f=navigator.userAgent.toLowerCase(),g=function(){d=!0;for(var a=0,b=e.length;b>a;a++)"function"==typeof e[a]&&e[a].call(this);e=null},h=function(){b.setPlugins(),b.getDUID(),setTimeout(function(){g(),g=null},10)};b=function(a,c){"string"==typeof a?b.readyForPlatform(a,c):"function"==typeof a&&b.ready(a)},c={version:.1,platformName:"",userAgent:f,createPlatform:function(b,c){var d=c.detect&&c.detect();(d||a(c.platformUserAgent))&&(this.platformName=b,_.extend(this,c),"function"==typeof c.onDetect&&this.onDetect())},ready:function(a){d?a.call(this):e.push(a)},readyForPlatform:function(a,b){var c=this;this.ready(function(){a==c.platformName&&b.call(c)})},utils:{error:function(a){$$log(a,"error")},log:{log:$.noop,state:$.noop,show:$.noop,hide:$.noop,startProfile:$.noop,stopProfile:$.noop},addExternalJS:function(a,b){function c(){g++,g===h&&b&&b.call()}var d,e,f,g=0,h=a.length;if(a.length){d=document.createDocumentFragment(),e=document.createElement("script"),e.type="text/javascript",e.onload=c;for(var i=0;h>i;i++)f=e.cloneNode(),f.src=a[i],d.appendChild(f);document.body.appendChild(d)}else b&&b.call(this)},addExternalCss:function(a){var b;a.length&&(b=document.createDocumentFragment(),_.each(a,function(a){var c=document.createElement("link");c.rel="stylesheet",c.href=a,b.appendChild(c)}),document.body.appendChild(b))},addExternalFiles:function(a){this.externalJs.length&&this.addExternalJS(this.externalJs,a),this.externalCss.length&&this.addExternalCss(this.externalCss)}}},b.config={DUID:"real"},_.extend(b,c),window.SB=b,window.onload=function(){h(),h=null}}(),!function(){var a={externalCss:[],externalJs:[],keys:{},DUID:"",platformUserAgent:"not found",getDUID:function(){switch(SB.config.DUID){case"real":this.DUID=this.getNativeDUID();break;case"mac":this.DUID=this.getMac();break;case"random":this.DUID=this.getRandomDUID();break;default:this.DUID=Config.DUIDSettings}return this.DUID},getSDI:function(){return""},getRandomDUID:function(){return(new Date).getTime().toString(16)+Math.floor(Math.random()*parseInt("10000",16)).toString(16)},getMac:function(){return""},getNativeDUID:function(){return""},setPlugins:$.noop,volumeUp:$.noop,volumeDown:$.noop,getVolume:$.noop,exit:$.noop,sendReturn:$.noop,setData:function(a,b){localStorage.setItem(a,JSON.stringify(b))},getData:function(a){var b;try{b=JSON.parse(localStorage.getItem(a))}catch(c){}return b},removeData:function(a){localStorage.removeItem(a)}};_.extend(SB,a)}(this),function(a,b,c){function d(b){var d=a(c.createElement("div"));return d.html(b.template),d.find("."+b.elClass)}function e(){h=a(c.createElement("div")).attr("id","keyboard_overlay"),i=a(c.createElement("div")).attr({id:"keyboard_popup","class":"keyboard_popup_wrapper"}),h.append(i),a(c.body).append(h)}function f(b,c){this.$input=a(b),this.initialise(c),this.stopBlink(),this.setText(b.value)}var g,h,i,j,k="SBInput",l={keyboard:{type:"fulltext_ru",firstLayout:"ru"},formatText:null,bindKeyboard:null,input:{template:'<div class="smart_input-container"><div class="smart_input-wrap"><span class="smart_input-text"></span><span class="smart_input-cursor"></span></div></div>',elClass:"smart_input-container",wrapperClass:"smart_input-wrap",cursorClass:"smart_input-cursor",textClass:"smart_input-text"},directKeyboardInput:!1,directNumInput:!1,max:0,next:null};g={isInited:!1,_generatedKeyboard:!1,isKeyboardActive:!1,text:"",initialise:function(b){var c;return this.isInited?this:(b=a.extend({},l,b),b.next=this.$input.attr("data-next")||b.next,b.max=this.$input.attr("data-max")||b.max||0,this.options=b,this.$input.attr({"data-value":"","data-max":b.max}),c=d(b.input),c.addClass(this.$input[0].className),this.$input.hide().after(c),this.$el=c,this.$text=c.find("."+b.input.textClass),this.$cursor=c.find("."+b.input.cursorClass),this.$wrapper=c.find("."+b.input.wrapperClass),b.directKeyboardInput&&this.addDirectKeyboardEvents(),this.addEvents(),this.isInited=!0,this)},startBlink:function(){var a=this,b=this.options.input.cursorClass+"_hidden";j&&clearInterval(j),j=setInterval(function(){a.$cursor.toggleClass(b)},500)},stopBlink:function(){var a=this.options.input.cursorClass+"_hidden";j&&clearInterval(j),this.$cursor.addClass(a)},addEvents:function(){var a=this.$wrapper,b=this.options,c=this;this.$input.on({nav_focus:function(){$$nav.current(c.$el)},startBlink:function(){c.startBlink()},stopBlink:function(){c.stopBlink()},hideKeyboard:function(){a.hasClass("smart-input-active")&&c.hideKeyboard()},showKeyboard:function(){c.showKeyboard()}}),this.$el.on({nav_focus:function(){c.$input.addClass("focus")},nav_blur:function(){c.$input.removeClass("focus")}}),b.directNumInput&&!b.directKeyboardInput&&this.$el.off("nav_key:num nav_key:red").on("nav_key:num nav_key:red",function(a){c.typeNum(a)}),a.off("nav_focus nav_blur click"),b.bindKeyboard&&(b.keyboard=!1,b.bindKeyboard.off("type backspace delall").on("type",function(a){c.type(a.letter)}).on("backspace",function(){c.type("backspace")}).on("delall",function(){c.type("delall")})),b.keyboard&&this.$el.on("click",function(){c.startBlink(),c.showKeyboard()})},addDirectKeyboardEvents:function(){var b=this;this.$el.on({nav_focus:function(){b.startBlink(),a(c.body).on("keypress.SBInput",function(a){if(a.charCode)a.preventDefault(),b.type(String.fromCharCode(a.charCode));else switch(a.keyCode){case 8:a.preventDefault(),b.type("backspace")}})},nav_blur:function(){b.stopBlink(),a(c.body).off("keypress.SBInput")}})},setText:function(a){var b,c,d=this.options,e=d.max;a=a||"",a.length>e&&0!=e&&(a=a.substr(0,e)),b=d.formatText?d.formatText(a):a,this.$input.val(a).attr("data-value",a),this.text=a,this.$text.html(b),a.length>1?(c=this.$text.width()>this.$wrapper.width()?"add":"remove",this.$wrapper[c+"Class"]("."+d.input.wrapperClass+"_right")):this.$wrapper.removeClass("."+d.input.wrapperClass+"_right"),this.$input.trigger("text_change")},type:function(a){var b=this.text||"",c=this.options;switch(a){case"backspace":b=b.substr(0,b.length-1);break;case"delall":b="";break;default:b+=a}this.setText(b),b.length===c.max&&c.next&&0!=c.max&&(this.hideKeyboard(),$$nav.current(c.next),$$nav.current().click())},typeNum:function(a){switch(a.keyName){case"red":this.type("backspace");break;default:this.type(a.num)}a.stopPropagation()},changeKeyboard:function(a){var b=this.options.keyboard;this.options.keyboard=_.extend({},b,a),i&&i.SBKeyboard(this.options.keyboard)},hideKeyboard:function(a){var b=this.$wrapper;b.removeClass("smart-input-active"),this.$input.trigger("keyboard_hide"),h&&h.hide(),$$nav.restore(),$$voice.restore(),this.isKeyboardActive=!1,a?this.$input.trigger("keyboard_complete"):this.$input.trigger("keyboard_cancel"),i&&i.trigger("keyboard_hide")},showKeyboard:function(){var a=this.$wrapper,b=this.options.keyboard,c=this;this.isKeyboardActive=!0,a.addClass("smart-input-active");var d=this.$el.outerHeight(),f=this.$el.offset(),g=f.top+d;h||e(),this._generatedKeyboard||(i.SBKeyboard(b),this._generatedKeyboard=!0),i.SBKeyboard("changeKeyboard",b.type).css({left:f.left,top:g}).off("type backspace delall complete cancel").on("type",function(a){c.type(a.letter)}).on("backspace",function(){c.type("backspace")}).on("delall",function(){c.type("delall")}).on("complete cancel",function(a){var b=!1;"complete"===a.type&&(b=!0),c.stopBlink(),c.hideKeyboard(b)}),h.show();var j=i.height(),k=i.width();g+j>680&&i.css({top:g-j-d}),f.left+k>1280&&i.css({left:1280-k-20}),$$voice.save(),$$nav.save(),$$nav.on("#keyboard_popup"),i.SBKeyboard("refreshVoice").voiceLink(),this.$el.addClass($$nav.higlight_class),this.$input.trigger("keyboard_show"),this.startBlink()}},a.extend(f.prototype,g),g=null,a.fn.SBInput=function(){var b=Array.prototype.slice.call(arguments),c="string"==typeof b[0]&&b[0],d="object"==typeof b[0]&&b[0],e=b.slice(1);return this.each(function(){var b=a.data(this,"plugin_"+k);b?"function"==typeof b[c]&&b[c].apply(b,e):a.data(this,"plugin_"+k,new f(this,d))})}}(jQuery,window,document),function(a,b,c){function d(a,b){this.type=a.type,this.currentLayout="",this.previousLayout="",this.$el=b,this.$layouts={},this.presets=[],this.initialize(a)}function e(b,c){this.$el=a(b),this.keyboards={},c=a.extend({},h,c),this.addKeyboard(c),this.$el.addClass("keyboard_popup_wrapper")}var f="SBKeyboard",g=/([^{]+){{([^}]*)}}/,h={type:"en",firstLayout:null},i={},j={},k={};j={isShiftActive:!1,isNumsShown:!1,currentPresetType:"",initialize:function(b){var d,e,f=_.result(this,"type"),g="",h=!1;if(d=SB.keyboardPresets[f],!d)throw new Error("Preset "+f+" doesn't exist");this.currentPresetType=f,this.$wrap=a(c.createElement("div")).addClass("kb-wrap"),"function"==typeof d?(this.presets.push(f),g=this.generateBoard(f)):d.length&&(this.presets=d,h=-1!==d.indexOf("fullnum"),h&&(this.presets=_.without(this.presets,"fullnum")),g=this.generateFull(this.presets,h)),this.$wrap.append(g).addClass("kekekey_"+f),this.$el.append(this.$wrap),this.setEvents();for(var i=0;i<this.presets.length;i++)e=this.presets[i],this.$layouts[e]=this.$wrap.find(".keyboard_generated_"+e);h&&(this.$layouts.fullnum=this.$wrap.find(".keyboard_generated_fullnum")),-1!==this.presets.indexOf(b.firstLayout)?this.changeLayout(b.firstLayout):this.changeLayout(this.presets[0])},generateFull:function(a,b){var c="",d="";a.length>1&&this.$wrap.addClass("kb-multilang");for(var e=0;e<a.length;e++)d=a[e],c+=this.generateBoard(d);return b&&(this.$wrap.addClass("kb-havenums"),c+=this.generateBoard("fullnum")),c},generateBoard:function(a){var b,c,d=SB.keyboardPresets[a],e="",f="",h={};if(k[a])return k[a].board;d=d(),e='<div class="kb-c keyboard_generated_'+a+'">';for(var i=0;i<d.length;i++){b=d[i],f='<div class="kb-row" data-nav_type="hbox">';for(var j=0;j<b.length;j++){if(c=b[j],1==c.length||"&"===c)h={text:c,type:"",letter:c};else{var l=g.exec(c);h.text=l[2]||"",h.type=l[1],h.letter=""}f+='<div class="kbtn nav-item '+h.type+'" data-letter="'+_.escape(h.letter)+'"',h.type&&(f+=' data-keytype="'+h.type+'"'),f+=">"+h.text+"</div>"}e+=f+"</div>"}return e+="</div>",k[a]={board:e},e},onKeyNum:function(b){switch(b.keyName){case"red":this.$el.trigger("backspace");break;default:var c=a.Event({type:"type"});c.letter=""+b.num,this.$el.trigger(c)}b.stopPropagation()},defaultOnKey:function(a){a.stopPropagation()},onKeyDown:function(b){var c,d=a(b.currentTarget),e=d.attr("data-keytype"),f=d.attr("data-letter");if(c=a.Event({type:"type"}),e)switch(e){case"backspace":c="backspace";break;case"delall":c="delall";break;case"complete":c="complete";break;case"space":c.letter=" ";break;case"shift":return this.triggerShiftLetters(),void 0;case"lang":return this.changeKeyboardLang(),void 0;case"nums":return this.triggerNumKeyboard(),void 0}else c.letter=this.isShiftActive?f.toUpperCase():f;c&&this.$el.trigger(c),b.stopPropagation()},triggerShiftLetters:function(){this.isShiftActive?(this.isShiftActive=!1,this.$el.removeClass("shift_active")):(this.isShiftActive=!0,this.$el.addClass("shift_active"))},triggerNumKeyboard:function(){this.isNumsShown?(this.isNumsShown=!1,this.changeLayout(this.previousLayout),this.$el.trigger("hide_num")):(this.isNumsShown=!0,this.changeLayout("fullnum"),this.$el.trigger("show_num")),$$nav.current(this.$layouts[this.currentLayout].find(".nums"))},changeKeyboardLang:function(){var a,b=this.presets.indexOf(this.currentLayout);a=(b+1)%this.presets.length,this.changeLayout(this.presets[a]),$$nav.current(this.$layouts[this.currentLayout].find(".lang"))},changeLayout:function(a){var b,c=this.$layouts[a];this.currentLayout&&(b=this.$layouts[this.currentLayout],b&&b.hide(),this.$el.removeClass("keyboard_"+this.currentLayout),this.previousLayout=this.currentLayout),c&&(this.currentLayout=a,this.$el.addClass("keyboard_"+a),c.show())},setEvents:function(){var a=this;this.$wrap.on("nav_key:yellow nav_key:blue",this.defaultOnKey),this.$wrap.on("nav_key:num nav_key:red",_.bind(this.onKeyNum,this)),this.$wrap.on("click",".kbtn",_.bind(this.onKeyDown,this)),this.$wrap.on("nav_key:green",function(b){a.$el.trigger("complete"),b.stopPropagation()}).on("nav_key:return",function(b){a.$el.trigger("cancel"),b.stopPropagation()})},show:function(){return this.$wrap.show(),this.$el.addClass(_.result(this,"type")+"_wrap").addClass("keyboard_"+this.currentLayout),this},hide:function(){this.$wrap.hide(),this.$el.removeClass(_.result(this,"type")+"_wrap").removeClass("keyboard_"+this.currentLayout)}},a.extend(d.prototype,j),j=null,i={addKeyboard:function(b){var c=a.extend({},h,b),e=_.isFunction(b.type)?_.result(b,"type"):b.type;this.keyboards[e]||(this.keyboards[e]=new d(c,this.$el)),this.changeKeyboard(e)},changeKeyboard:function(a){var b,c,d=this.currentKeyboard;a=_.isFunction(a)?a():a,b=this.keyboards[a],c=d&&d.currentPresetType===a,b&&!c?(d&&d.hide(),this.currentKeyboard=b.show()):b||this.addKeyboard({type:a})}},a.extend(e.prototype,i),i=null,a.fn.SBKeyboard=function(){var b=Array.prototype.slice.call(arguments),c="string"==typeof b[0]&&b[0],d="object"==typeof b[0]&&b[0],g=b.slice(1);return this.each(function(){var b=a.data(this,"plugin_"+f);b?c?b[c]&&b[c].apply(b,g):d&&b.addKeyboard(d):a.data(this,"plugin_"+f,new e(this,d))})}}(jQuery,window,document),window.SB=window.SB||{},window.SB.keyboardPresets={en:function(){return["qwertyuiop".split(""),"asdfghjkl".split("").concat(['backspace{{<i class="backspace_icon"></i>}}']),['shift{{<i class="shift_icon"></i>Shift}}'].concat("zxcvbnm".split("")).concat(["delall{{<span>Del<br/>all</span>}}"]),["lang{{en}}","nums{{123}}","space{{}}","complete{{Complete}}"]]},ru:function(){return["йцукенгшщзхъ".split(""),"фывапролджэ".split("").concat(['backspace{{<i class="backspace_icon"></i>}}']),['shift{{<i class="shift_icon"></i>Shift}}'].concat("ячсмитьбю".split("")).concat(["delall{{<span>Del<br/>all</span>}}"]),["lang{{ru}}","nums{{123}}","space{{}}","complete{{Готово}}"]]},email:function(){return["1234567890@".split(""),"qwertyuiop".split("").concat(['backspace{{<i class="backspace_icon"></i>}}']),"asdfghjkl_".split("").concat(["delall{{<span>Del<br/>all</span>}}"]),"zxcvbnm-.".split("").concat("complete{{OK}}")]},num:function(){return["123".split(""),"456".split(""),"789".split(""),['backspace{{<i class="backspace_icon"></i>}}',"0","complete{{OK}}"]]},fullnum:function(){return["1234567890".split(""),'-/:;()$"'.split("").concat(["&",'backspace{{<i class="backspace_icon"></i>}}']),["nums{{ABC}}"].concat("@.,?!'+".split("")),["space{{}}","complete{{OK}}"]]},fulltext_ru:["ru","en"],fulltext_en:["en"],fulltext_ru_nums:["ru","en","fullnum"],fulltext_en_nums:["en","fullnum"]},function(a){"use strict";function b(a){return-1===h.indexOf(a)}function c(a){var c=b(a)?" legend-clickable":"";return'<div class="legend-item legend-item-'+a+c+'" data-key="'+a+'"><i class="leg-icon leg-icon-'+a+'"></i><span class="legend-item-title"></span></div>'}function d(){for(var a,b,d="",e=0,f=g.length;f>e;e++)d+=c(g[e]);return a=document.createElement("div"),b=document.createElement("div"),a.className="legend",a.id="legend",b.className="legend-wrap",b.innerHTML=d,a.appendChild(b),$(a)}var e,f,g=["info","red","green","yellow","blue","rew","play","pause","stop","ff","tools","left","right","up","down","leftright","updown","move","number","enter","ret"],h=["leftright","left","right","up","down","updown","move","number"],i=[];f=function(){var a=this;this.$el=d(),this.keys={};for(var b=function(b){var c;a.keys[b]||(c=a.$el.find(".legend-item-"+b),a.keys[b]=new e(c))},j=0;j<g.length;j++)b(g[j]);this.addKey=function(a,d){var e;"undefined"==typeof d&&(d=!0),d||h.push(a),e=c(a),this.$el.find(".legend-wrap").append(e),b(a)},this.show=function(){this.$el.show()},this.hide=function(){this.$el.hide()},this.clear=function(){for(var a in this.keys)this.keys[a]("")},this.save=function(){for(var a in this.keys)i[a]=this.keys[a]()},this.restore=function(){_.each(g,function(a){f[a](i[a])});for(var a in i)this.keys[a](i[a]);i=[]}},e=function(a){return this.$el=a,this.$text=a.find(".legend-item-title"),_.bind(this.setText,this)},e.prototype.text="",e.prototype.isShown=!1,e.prototype.setText=function(a){return"undefined"==typeof a?this.text:(a!==this.text&&(a=a||"",!a&&this.isShown?(this.$el[0].style.display="none",this.$el.removeClass("legend-item-visible"),this.isShown=!1):a&&!this.isShown&&(this.$el[0].style.display="",this.$el.addClass("legend-item-visible"),this.isShown=!0),this.text=a,this.$text.html(a)),void 0)},a.$$legend=new f,$(function(){$$legend.$el.appendTo(document.body),$$legend.$el.on("click",".legend-clickable",function(){var a,b,c=$(this).attr("data-key");"ret"===c?c="return":"rew"===c&&(c="rw"),a=$.Event("nav_key:"+c),b=$.Event("nav_key"),b.keyName=a.keyName=c,$$nav.current().trigger(a).trigger(b)})})}(this),function(a){var b,c,d,e,f={},g={},h=[],i=0,j=20;b=$("<div></div>",{id:"log"}),$(function(){b.appendTo(document.body)}),c=$("<div></div>",{"class":"log-row"}),e=function(a){this.name=a,this.logs=0,this.states={};var c=b.find("#log_"+this.name);this.$content=c.find(".log_content"),this.$state=c.find(".log_states"),c=null},_.extend(e.prototype,{log:function(a){var b,d,e=c.clone();this.logs++,a=_.escape(a),e.html(a).appendTo(this.$content),this.logs>j&&(b=this.$content.find(".log-row"),d=b.length,b.slice(0,d-j).remove(),this.logs=b.length)},state:function l(a,b){var l=this.states[b]||this.createState(b);l.textContent=b+": "+a},createState:function(a){var b=document.createElement("div");return b.id="#log_"+this.name+"_"+a,this.states[a]=b,this.$state.append(b),b}});var k='<div class="log_pane" id="log_<%=name%>"><div class="log_name">Log: <%=name%></div><div class="log_content_wrap"><div class="log_content"></div></div><div class="log_states"></div></div>';d={create:function(a){var c=k.replace(/<%=name%>/g,a);return b.append(c),g[a]=new e(a),h.push(a),g[a]},getPanel:function(a){return a=a||"default",g[a]||this.create(a)}},a.SB.utils.log={log:function(a,b){d.getPanel(b).log(a)},state:function(a,b,c){d.getPanel(c).state(a,b)},show:function(a){a=a||h[i],a?(i++,b.show(),$(".log_pane").hide(),$("#log_"+a).show()):(i=0,this.hide())},hide:function(){b.hide()},startProfile:function(a){a&&(f[a]=(new Date).getTime())},stopProfile:function(a){f[a]&&(this.log(a+": "+((new Date).getTime()-f[a])+"ms","profiler"),delete f[a])}},a.$$log=SB.utils.log.log,a.$$error=SB.utils.error}(this),$(function(){var a=SB.config.logKey||"tools";$(document.body).on("nav_key:"+a,function(){SB.utils.log.show()})}),!function(a,b){function c(){function a(a){var b,d={},e=a.keyCode;!n&&k&&(b=f[e],b&&(m.indexOf(b)>-1?g(b):(l.indexOf(b)>-1&&(d.num=b[1],b="num"),c(b,d))))}function c(a,b){var c,d;k&&(c=$.Event("nav_key:"+a,b||{}),d=$.Event("nav_key"),c.keyName=a,d.keyName=a,k.trigger(c),k&&k.trigger(d))}function g(a){var b=j[a];b||(b=j[a]=_.throttle(function(){c(a)},800,{leading:!0})),b(a)}function h(){k&&k.click()}var i=[],j={},k=null,l=["n0","n1","n2","n3","n4","n5","n6","n7","n8","n9"],m=["green","red","yellow","blue"],n=0;return{area_selector:".nav-item",higlight_class:"focus",$container:null,loopType:null,phantom_selector:"[data-nav-phantom]",isPaused:function(){return!!n},pause:function(){return n++,this},resume:function(a){return n--,(0>n||a)&&(n=0),this},save:function(){return i.push({navCur:k,area_selector:this.area_selector,higlight_class:this.higlight_class,$container:this.$container}),this},restore:function(){if(i.length){this.off();var a=i.pop();this.area_selector=a.area_selector,this.higlight_class=a.higlight_class,this.on(a.$container,a.navCur)}return this},current:function(a,b){if(!a)return k;b=b||"nav_key";var c=$(a);if(c.is(this.phantom_selector)&&(c=$($(c.attr("data-nav-phantom"))[0])),c.length>1)throw new Error("Focused element must be only one!");if(!c.length)return this;var d=k;return k&&k.removeClass(this.higlight_class).trigger("nav_blur",[b,c]),k=c,c.addClass(this.higlight_class).trigger("nav_focus",[b,d]),this},on:function(b,c){var d,f=this;return e=e||$(document.body),this.off(),this.$container=b?$(b):e,"philips"!=SB.platform&&this.$container.on("mouseenter.nav",this.area_selector,function(){$(this).is(f.phantom_selector)||f.current(this,"mouseenter")}),d=this.$container.find("[data-nav_type]"),this.$container.attr("data-nav_type")&&(d=d.add(this.$container)),d.each(function(){var a=$(this),b=a.attr("data-nav_type");a.removeAttr("data-nav_type");var c=a.attr("data-nav_loop");f.siblingsTypeNav(a,b,c)}),e.bind("keydown.navigation",a).bind("nav_key:enter.navigation",h),c||(c=this.$container.find(this.area_selector).filter(":visible")[0]),this.current(c),this},siblingsTypeNav:function(a,b,c){var e=this;a.on("nav_key:left nav_key:right nav_key:up nav_key:down",this.area_selector,function(f){var g,h,i="last",j=e.current();if("hbox"==b&&"left"==f.keyName||"vbox"==b&&"up"==f.keyName?h="prev":("hbox"==b&&"right"==f.keyName||"vbox"==b&&"down"==f.keyName)&&(h="next"),"next"==h&&(i="first"),h){for(g=j[h](e.area_selector);g.length&&!g.is(":visible");)g=g[h](e.area_selector);if(!g.length&&c&&(g=a.find(e.area_selector).filter(":visible")[i]()),g.length)return d.current(g),!1}})},off:function(){return k&&k.removeClass(this.higlight_class).trigger("nav_blur"),this.$container&&this.$container.off("mouseenter.nav").off(".loop"),e.unbind(".navigation"),k=null,this},findSome:function(){var a;return k&&k.is(":visible")||(a=this.$container.find(this.area_selector).filter(":visible").eq(0),this.current(a)),this},findNav:function(a,b,c){function d(a,b,c){var d=null;switch(c){case"left":case"right":if(a.top>b.top&&(d=b,b=a,a=d),a.bottom>b.top)return a.top>b.right?b.top-a.right:b.height;break;case"up":case"down":if(a.left>b.left&&(d=b,b=a,a=d),a.right>b.left)return a.left>b.right?b.left-a.right:b.width}return!1}var e=this.checkUserDefined(a,b);if(e)return"none"===e?!1:e;var f,g,h,i,j=a[0].getBoundingClientRect(),k=[],l=null;for(h=0,i=c.length;i>h;h++)if(l=c[h].getBoundingClientRect(),l.left!=j.left||l.top!=j.top){switch(b){case"left":f=j.left>l.left;break;case"right":f=j.right<l.right;break;case"up":f=j.top>l.top;break;case"down":f=j.bottom<l.bottom}f&&k.push({obj:c[h],bounds:l})}var m=9999999,n=9999999,o=9999999,p=0,q=0,r=0,s=0,t=!1,u=!1;for(h=0,i=k.length;i>h;h++)if(this.checkEntryPoint(k[h].obj,b)){var v=k[h].bounds,w=d(j,v,b);if(q=Math.abs(v.top-j.top),r=Math.abs(v.left-j.left),s=Math.sqrt(q*q+r*r),!t||w)if(!w||t){switch(b){case"left":case"right":g=t?n>r||r==n&&m>q:m>q||q==m&&n>r;break;case"up":case"down":g=t?m>q||q==m&&n>r:n>r||r==n&&m>q}g&&(m=q,n=r,o=s,u=k[h].obj)}else m=q,n=r,p=w,u=k[h].obj,t=!0}return u},checkUserDefined:function(a,b){var c=a.data("nav_ud"),d=!1,e=a.data("nav_ud_"+b);if(!c&&!e)return!1;if(!e){var f=c.split(","),g=["up","right","down","left"];if(4!==f.length)return!1;a.data({nav_ud_up:f[0],nav_ud_right:f[1],nav_ud_down:f[2],nav_ud_left:f[3]}),e=f[g.indexOf(b)]}return"none"==e?d="none":"0"==e?d=!1:e&&(d=$(e).first()),d},checkEntryPoint:function(a,c){var d=$(a),e=d.attr("data-nav_ep"),f=null;if(!e)return!0;if(f=d.attr("data-nav_ep_"+c),f===b){var g=e.split(",");d.attr("data-nav_ep_top",g[0]),d.attr("data-nav_ep_right",g[1]),d.attr("data-nav_ep_bottom",g[2]),d.attr("data-nav_ep_left",g[3]),f=d.attr("data-nav_ep_"+c)}return!!parseInt(f)}}}var d,e=null,f={};SB.ready(function(){var a=SB.keys;for(var b in a)f[a[b]]=b.toLowerCase()}),d=a.$$nav=new c,$(function(){$(document.body).bind("nav_key:left nav_key:right nav_key:up nav_key:down",function(a){var b,c,e=d.current();b=d.$container.find(d.area_selector).filter(":visible"),c=d.findNav(e,a.keyName,b),c&&d.current(c)})})}(this),function(a){var b,c,d,e=0,f=function(a){a.state="play",b=setInterval(function(){a.trigger("update"),a.videoInfo.currentTime+=.5,a.videoInfo.currentTime>=a.videoInfo.duration&&(a.stop(),a.trigger("complete"))},500)},g=!1,h=a.Player={_init:function(){},state:"stop",play:function(a){g||(this._init(),g=!0),"string"==typeof a&&(a={url:a}),void 0!==a?(this.stop(),this.state="play",this._play(a)):void 0===a&&"pause"===this.state&&this.resume()},_play:function(){var a=this;setTimeout(function(){a.trigger("ready"),setTimeout(function(){a.trigger("bufferingBegin"),setTimeout(function(){a.videoInfo.currentTime=0,a.trigger("bufferingEnd"),f(a)},1e3)},1e3)},1e3)},stop:function(a){"stop"!=this.state&&(this._stop(),a||this.trigger("stop")),this.state="stop"},pause:function(){this._stop(),this.state="pause"},resume:function(){f(this)},togglePause:function(){"play"==this.state?this.pause():this.resume()},_stop:function(){clearInterval(b)},formatTime:function(a){var b=Math.floor(a/3600),c=a%3600,d=Math.floor(c/60),e=c%60,a=Math.ceil(e);return 10>a&&(a="0"+a),10>d&&(d="0"+d),(b?b+":":"")+d+":"+a},videoInfo:{duration:0,width:0,height:0,currentTime:0},seek:function(a){var b=this;b.videoInfo.currentTime=a,b.pause(),b.trigger("bufferingBegin"),setTimeout(function(){b.trigger("bufferingEnd"),b.resume()},500)},audio:{set:function(a){e=a},get:function(){for(var a=2,b=[],c=0;a>c;c++)b.push(0);return b},cur:function(){return e},toggle:function(){var a=this.get().length,b=this.cur();a>1&&(b++,b>=a&&(b=0),this.set(b))}},subtitle:{set:function(a){curSubtitle=a},get:function(){for(var a=2,b=[],c=0;a>c;c++)b.push(0);return b},cur:function(){return curSubtitle},toggle:function(){var a=h.subtitle.get().length,b=h.subtitle.cur();a>1&&(b++,b>=a&&(b=0),h.subtitle.set(b))},text:function(a){var b=h.subtitle.data,c=_.sortedIndex(b,{time:a},function(a){return a.time});return b[c-1]?b[c-1].text:""},data:[{time:0,text:""}],url:function(a){var b=/\.([^\.]+)$/.exec(a)[1];h.subtitle.set(void 0),$.ajax({url:a,dataType:"text",success:function(a){var c=$("#subtitles_view");$(h).off(".subtitles"),h.subtitle.init=!0,h.subtitle.remote=!0,h.subtitle.parse[b].call(h,a),c.show();var d=function(){$("#subtitles_text").html(h.subtitle.text(1e3*parseInt(h.videoInfo.currentTime)))};h.on("update",d),c.length||($("body").append('<div id="subtitles_view" style="position: absolute; z-index: 1;"><div id="subtitles_text"></div></div>'),c=$("#subtitles_view"),c.css({width:"1280px",height:"720px",left:"0px",top:"0px"}),$("#subtitles_text").css({position:"absolute","text-align":"center",width:"100%",left:"0",bottom:"50px","font-size":"24px",color:"#fff","text-shadow":"0 0 3px #000,0 0 3px #000,0 0 3px #000,0 0 3px #000,0 0 3px #000,0 0 3px #000,0 0 3px #000,0 0 3px #000,0 0 3px #000","line-height":"26px"}));var e=function(){$(h).off("update",d),$(h).off("stop",e),c.hide()};h.on("stop",e)}})},parse:{smi:function(a){a=a.split(/\s*<sync/i),a.shift(),h.subtitle.data=_.map(a,function(a){var b=/[\s\S]*start=(\d+)[\s\S]*<p[^>]*>([\s\S]*)<spanid/i.exec(a);return b?{time:parseInt(b[1],10),text:b[2]}:void 0})},srt:function(a){a=a.split("\r\n\r\n");var b=h.subtitle;b.data=[];var c=function(a){var b=a.match(/(\d{2}):(\d{2}):(\d{2}),(\d+)/);return 36e5*parseInt(b[1],10)+6e4*parseInt(b[2],10)+1e3*parseInt(b[3],10)+parseInt(b[4],10)};_.each(a,function(a){if(a){var d,e,f=a.split("\n"),g=f[1].split(" --> ");f.splice(0,2),d=c(g[0]),e=c(g[1]),b.data.push({time:d,text:f.join("<br/>")}),b.data.push({time:e,text:""})}}),b.data.unshift({time:0,text:""})}}}};a._&&_.extend?c=_.extend:a.$&&$.extend&&(c=$.extend),a.EventEmitter?d=EventEmitter.prototype:a.Backbone?d=Backbone.Events:a.Events&&(d=Events.prototype),h.extend=function(a){c(this,a)},h.extend(d)}(this),function(a){"use strict";function b(b){var c=[];return b.each(function(){var b=a(this),d=b.attr("data-voice"),e=b.attr("data-voice-group"),f="true"===b.attr("data-voice-hidden")?!0:!1,g=b.attr("data-voice-weight")||0,h=!1;return d?(b.attr("data-voice-disabled")||(g||(e||f?g=n.candidateWeight:(g=n.helpbarItemWeight,h=!0)),c.push({itemText:d,weight:g,group:e,hidden:f,main:h}),o[d.toLowerCase()]=b),void 0):(console.error("command in ",this," is not defined"),void 0)}),c}var c,d,e,f,g,h=!1,i=!1,j=[],k=a("<div/>"),l=!1,m=function(){if(!h){if(i=$$voice._nativeCheckSupport(),!i)return;$$voice._init(),f=a("#voice_buble"),h=!0}},n={selector:".voicelink",moreText:"More",eventName:"voice",useHidden:!1,helpText:"",showHelperTimes:3,helpbarMaxItems:6,sortByWeight:!0,helpbarItemWeight:200,candidateWeight:0};window.$$voice={voiceTimeout:1e4,_resetVisibilityTimeout:function(){$$voice.helpbarVisible=!0,clearTimeout(g),g=setTimeout(function(){"function"==typeof voiceServer&&(voiceServer=!1,$$voice.restore()),f.hide(),$$voice.helpbarVisible=!1},this.voiceTimeout)},_init:function(){},_nativeCheckSupport:function(){},helpbarVisible:!1,enabled:function(){return m(),i},_setVoiceHelp:function(){},pause:function(){l=!0},resume:function(){l=!1},say:function(b){if(!l){var c=b.toLowerCase(),f=a.extend({},n,d);o[c]&&o[c].trigger(f.eventName),e&&s.call(e,d)}},_nativeTurnOff:function(){},hide:function(){return this.enabled()?(this._nativeTurnOff(),f.hide(),this):void 0},setup:function(b){return a.extend(n,b),this},save:function(){return c&&j.push(c),this},restore:function(){var b=j.pop();return b&&a.fn.voiceLink.apply(b.self,b.args),this},_nativeFromServer:function(){},fromServer:function(a,b){return h?(this.save(),this._nativeFromServer(a,b),this):this},refresh:function(){return this.save().restore()}};var o,p=!1,q={},r=0,s=function(c){if(!p){p=!0,f.hide().empty();var d,e,g,h,i,j=[],l=[],m=a.extend({},n,c),s=m.helpbarMaxItems,t=this.find(m.selector),u={helpbarType:"HELPBAR_TYPE_VOICE_CUSTOMIZE",bKeepCurrentInfo:"false",helpbarItemsList:{}};if(o={},!c.useHidden){var v=t.filter("[data-voice-force-visible]");t=t.filter(":visible").add(v)}d=m.sortByWeight?_.sortBy(b(t),function(a){return-a.weight}):b(t),i=a.grep(d,function(a){return a.hidden===!0}),h=_.difference(d,i),h.length>s&&(h.splice(s-1,0,{itemText:m.moreText,commandList:[{command:m.moreText}]}),k.unbind().bind(m.eventName,function(){a("body").trigger("showVoiceHelpbar"),$$voice._resetVisibilityTimeout(),f.show()}),o[m.moreText.toLowerCase()]=k),e=h.splice(0,s),g=_.union(i,h),_.each(e,function(a){var b=a.itemText;j.push({itemText:b,commandList:[{command:b}]})}),_.each(g,function(a){var b=a.group,c=a.itemText,d=a.hidden,e=a.main;if(e&&!b&&(b=""),!d){q[b]||(r++,q[b]=r);var g=f.find("#voice_group_body_"+q[b]);g.length?g.append('<div class="voice_help_item">'+c+"</div>"):f.append('<div class="voice_group_head">'+b+'</div><div class="voice_group_body" id="voice_group_body_'+q[b]+'"><div class="voice_help_item">'+c+"</div></div>")}l.push({candidate:a.itemText})}),u.helpbarItemsList=j,l.length&&(u.candidateList=l),$$voice._setVoiceHelp(u)}};a.fn.voiceLink=function(a){(!h||i)&&(m(),c={self:this,args:arguments},p=!1,a||(a={}),d=a,e=this,$$voice.helpbarVisible&&s.call(this,d))}}(jQuery),SB.readyForPlatform("browser",function(){Player.extend({_init:function(){var a=this,b=1280,c=720;this.$video_container=$('<video id="smart_player" style="position: absolute; left: 0; top: 0;width: '+b+"px; height: "+c+'px;"></video>');var d=this.$video_container[0];$("body").append(this.$video_container),this.$video_container.on("loadedmetadata",function(){a.videoInfo.width=d.videoWidth,a.videoInfo.height=d.videoHeight,a.videoInfo.duration=d.duration,a.trigger("ready")}),this.$video_container.on("loadstart",function(){a.trigger("bufferingBegin")}).on("playing",function(){a.trigger("bufferingEnd")}).on("timeupdate",function(){a.videoInfo.currentTime=d.currentTime,a.trigger("update")}).on("ended",function(){a.state="stop",a.trigger("complete")}),this.$video_container.on("abort canplay canplaythrough canplaythrough durationchange emptied ended error loadeddata loadedmetadata loadstart mozaudioavailable pause play playing ratechange seeked seeking suspend volumechange waiting",function(){})},_play:function(a){this.$video_container.attr("src",a.url),this.$video_container[0].play()},_stop:function(){this.$video_container[0].pause(),this.$video_container[0].src=""},pause:function(){this.$video_container[0].pause(),this.state="pause"},resume:function(){this.$video_container[0].play(),this.state="play"},seek:function(a){this.$video_container[0].currentTime=a},audio:{set:function(){},get:function(){return[]},cur:function(){return 0}},subtitle:{set:function(a){if(Player.$video_container[0].textTracks){var b=_.filter(Player.$video_container[0].textTracks,function(a){return"subtitles"===a.kind
});if(b.length)return _.each(b,function(b,c){"showing"===b.mode?b.mode="disabled":c==a&&(b.mode="showing")}),!0}return!1},get:function(){if(Player.$video_container[0].textTracks){var a=_.filter(Player.$video_container[0].textTracks,function(a){return"subtitles"===a.kind});if(a.length)return _.map(a,function(b){return{index:a.indexOf(b),language:b.language}})}return!1},cur:function(){var a=-1;if(Player.$video_container[0].textTracks){var b=_.filter(Player.$video_container[0].textTracks,function(a){return"subtitles"===a.kind});b.length&&_.each(b,function(b,c){return"showing"===b.mode?(a=c,!1):void 0})}return a},toggle:function(){var a=Player.subtitle.get().length,b=Player.subtitle.cur();a>1&&(b++,b>=a&&(b=-1),Player.subtitle.set(b))}}})}),SB.createPlatform("browser",{keys:{RIGHT:39,LEFT:37,DOWN:40,UP:38,RETURN:27,EXIT:46,TOOLS:32,FF:33,RW:34,NEXT:107,PREV:109,ENTER:13,RED:65,GREEN:66,YELLOW:67,BLUE:68,CH_UP:221,CH_DOWN:219,N0:48,N1:49,N2:50,N3:51,N4:52,N5:53,N6:54,N7:55,N8:56,N9:57,PRECH:45,SMART:36,PLAY:97,STOP:98,PAUSE:99,SUBT:76,INFO:73,REC:82},detect:function(){return!0},getNativeDUID:function(){return this.DUID=-1!=navigator.userAgent.indexOf("Chrome")?"CHROMEISFINETOO":"FIREFOXISBEST",this.DUID}}),function(a){"use strict";SB.readyForPlatform("browser",function(){_.extend($$voice,{_init:function(){this.helpbarVisible=!0,a("body").append('<div id="voice_buble"></div><div id="help_voice_bubble"></div><div class="emul_voice_helpbar_wrap"><div id="emul_voice_helpbar"></div></div>'),a("#emul_voice_helpbar").on("click",".emul_voice_trigger",function(){$$voice.say(this.innerHTML)})},_nativeTurnOff:function(){a("#emul_voice_helpbar").empty()},_nativeFromServer:function(a,b){var c=prompt(a);b(c||"")},_nativeCheckSupport:function(){return!0},_setVoiceHelp:function(b){var c=a("#emul_voice_helpbar");c.empty(),b.helpbarItemsList&&a.each(b.helpbarItemsList,function(b,d){a("<div>",{attr:{"class":"emul_voice_trigger main"},html:d.itemText,appendTo:c})}),b.candidateList&&a.each(b.candidateList,function(b,d){a("<div>",{attr:{"class":"emul_voice_trigger"},html:d.candidate,appendTo:c})})}})})}(jQuery),SB.readyForPlatform("lg",function(){var a,b=!1;Player.extend({updateDelay:500,_init:function(){var a=this;$("body").append('<object type="video/mp4" data="" width="1280" height="720" id="pluginPlayer" style="z-index: 0; position: absolute; left: 0; top: 0;"></object>'),this.plugin=$("#pluginPlayer")[0],this.$plugin=$(this.plugin),this.plugin.onPlayStateChange=function(){a.onEvent.apply(a,arguments)},this.plugin.onBuffering=function(){a.onBuffering.apply(a,arguments)}},onEvent:function(){"5"==this.plugin.playState&&(this.state="stop",this.trigger("complete"))},_update:function(){var a=this.plugin.mediaPlayInfo();a&&!b&&(b=!0,this.trigger("ready"),this.videoInfo={duration:a.duration/1e3}),this.videoInfo.currentTime=a.currentPosition/1e3,this.trigger("update")},onBuffering:function(a){this.trigger(a?"bufferingBegin":"bufferingEnd")},_play:function(c){clearInterval(a),a=setInterval(function(){Player._update()},this.updateDelay),b=!1,this.plugin.data=c.url,this.plugin.play(1)},pause:function(){this.plugin.play(0),this.state="pause"},resume:function(){this.plugin.play(1),this.state="play"},_stop:function(){this.plugin.stop(),this.state="stop"},seek:function(a){this.plugin.seek(1e3*a)}})}),SB.createPlatform("lg",{platformUserAgent:"netcast",keys:{ENTER:13,PAUSE:19,LEFT:37,UP:38,RIGHT:39,DOWN:40,N0:48,N1:49,N2:50,N3:51,N4:52,N5:53,N6:54,N7:55,N8:56,N9:57,RED:403,GREEN:404,YELLOW:405,BLUE:406,RW:412,STOP:413,PLAY:415,FF:417,RETURN:461,CH_UP:33,CH_DOWN:34},getNativeDUID:function(){return this.device.serialNumber},getMac:function(){return this.device.net_macAddress.replace(/:/g,"")},getSDI:$.noop,setPlugins:function(){$("body").append('<object type="application/x-netcast-info" id="device" width="0" height="0"></object>'),this.device=$("#device")[0],this.modelCode=this.device.version,this.productCode=this.device.platform,this.getDUID(),setInterval(function(){var a;window.NetCastGetUsedMemorySize&&(a=window.NetCastGetUsedMemorySize())},5e3),Player&&Player.setPlugin&&Player.setPlugin()},sendReturn:function(){Player&&Player.stop(!0),window.NetCastBack()},exit:function(){Player&&Player.stop(!0),window.NetCastExit()},getUsedMemory:function(){return window.NetCastGetUsedMemorySize()},getChildlockPin:function(){return 1234}}),SB.readyForPlatform("mag",function(){var updateInterval,startUpdate=function(){updateInterval=setInterval(function(){var a=stb.GetPosTime();Player.videoInfo.currentTime=a,Player.trigger("update"),SB.utils.log.state(a,"position","player")},500)},stopUpdate=function(){clearInterval(updateInterval)};window.stbEvent={onEvent:function(data){if(data+="","1"==data)Player.trigger("complete");else if("2"==data)Player.videoInfo.duration=stb.GetMediaLen()+1,Player.videoInfo.currentTime=0,Player.trigger("ready");else if("4"==data)Player.trigger("bufferingEnd");else if("7"==data){var vi=eval(stb.GetVideoInfo());Player.videoInfo.width=vi.pictureWidth,Player.videoInfo.height=vi.pictureHeight}},event:0};var stb=window.gSTB;Player.extend({_init:function(){stb.InitPlayer(),stb.SetViewport(1280,720,0,0),stb.SetTopWin(0)},_play:function(a){stb.Play(a.url),startUpdate(),Player.trigger("bufferingBegin")},_stop:function(){stb.Stop(),stopUpdate()},pause:function(){stb.Pause(),this.state="pause",stopUpdate()},resume:function(){stb.Continue(),this.state="play",startUpdate()},seek:function(a){stb.SetPosTime(a)},audio:{set:function(a){stb.SetAudioPID(a)},get:function(){return stb.GetAudioPIDs()},cur:function(){return stb.GetAudioPID()}},subtitle:{set:function(a){stb.SetSubtitlePID(a)},get:function(){var a=[];return _.each(stb.GetSubtitlePIDs(),function(b){a.push({index:b.pid,language:b.lang[1]})}),a},cur:function(){return stb.GetSubtitlePID()}}})}),function(){var a;SB.createPlatform("mag",{keys:{RIGHT:39,LEFT:37,DOWN:40,UP:38,RETURN:8,EXIT:27,TOOLS:122,FF:70,RW:66,NEXT:34,PREV:33,ENTER:13,RED:112,GREEN:113,YELLOW:114,BLUE:115,CH_UP:9,CH_DOWN:9,N0:48,N1:49,N2:50,N3:51,N4:52,N5:53,N6:54,N7:55,N8:56,N9:57,PRECH:116,POWER:85,PLAY:82,STOP:83,INFO:89},onDetect:function(){var b=!1;a=window.gSTB,a.EnableVKButton(!1),window.moveTo(0,0),window.resizeTo(1280,720),SB(function(){var c=$(document.body);c.on("nav_key:power",function(){var d="standby_";b=!b,d+=b?"set":"unset",a.StandBy(b),$$log("trigger standby event "+d,"standby"),c.trigger(d)})}),window.localStorage={setItem:function(b,c){"object"==typeof c&&(c=JSON.stringify(c)),a.SaveUserData(b,c)},clear:function(){},getItem:function(b){return a.LoadUserData(b)},removeItem:function(b){a.SaveUserData(b,null)}}},detect:function(){return!!window.gSTB},exit:function(){$$log("try to location change"),Player.stop(!0),gSTB.DeinitPlayer(),window.location="file:///home/web/services.html"},sendReturn:function(){this.exit()},getMac:function(){return a.GetDeviceMacAddress()},getNativeDUID:function(){return a.GetDeviceSerialNumber()}})}(),SB.readyForPlatform("philips",function(){function a(){switch(b.playTime>1&&(d||(Player.videoInfo.duration=b.playTime/1e3+1,Player.trigger("ready"),d=!0)),b.playState){case 5:Player.trigger("complete"),f(),Player.state="stop";break;case 0:Player.state="stop";break;case 6:Player.trigger("error");break;case 1:Player.trigger("bufferingEnd"),e();break;case 2:case 3:case 4:Player.trigger("bufferingBegin"),f()}}var b,c,d=!1,e=function(){var a=0;c=setInterval(function(){b.playPosition!=a&&(Player.videoInfo.currentTime=b.playPosition/1e3,Player.trigger("update")),a=b.playPosition},500)},f=function(){clearInterval(c)};Player.extend({_init:function(){$("body").append('<div id="mediaobject" style="position:absolute;left:0px;top:0px;width:640px;height:480px;">\n <object id="videoPhilips" type="video/mpeg4" width="1280" height="720" />\n </div>'),b=document.getElementById("videoPhilips"),b.onPlayStateChange=a},_play:function(a){b.data=a.url,b.play(1),d=!1,Player.trigger("bufferingBegin")},_stop:function(){b.stop(),f()},pause:function(){b.play(0),this.state="pause",f()},resume:function(){b.play(1),this.state="play",e()},seek:function(a){b.seek(1e3*(a-10))}})}),SB.createPlatform("philips",{platformUserAgent:"nettv",setPlugins:function(){this.keys={ENTER:VK_ENTER,PAUSE:VK_PAUSE,LEFT:VK_LEFT,UP:VK_UP,RIGHT:VK_RIGHT,DOWN:VK_DOWN,N0:VK_0,N1:VK_1,N2:VK_2,N3:VK_3,N4:VK_4,N5:VK_5,N6:VK_6,N7:VK_7,N8:VK_8,N9:VK_9,RED:VK_RED,GREEN:VK_GREEN,YELLOW:VK_YELLOW,BLUE:VK_BLUE,RW:VK_REWIND,STOP:VK_STOP,PLAY:VK_PLAY,FF:VK_FAST_FWD,RETURN:VK_BACK,CH_UP:VK_PAGE_UP,CH_DOWN:VK_PAGE_DOWN}}}),function(){var a,b,c,d,e=window.localStorage;if(_.isFunction(window.FileSystem)){if(a=new FileSystem,b=a.isValidCommonPath(curWidget.id),b||a.createCommonDir(curWidget.id),c=curWidget.id+"_localStorage.db",d=a.openCommonFile(c,"r+"))try{JSON.parse(d.readAll())}catch(f){e&&e.clear()}else d=a.openCommonFile(c,"w"),d.writeAll("{}");if(a.closeCommonFile(d),!e){var g={},h=!1,i=_.debounce(function(){h&&(d=a.openCommonFile(c,"w"),d.writeAll(JSON.stringify(window.localStorage)),a.closeCommonFile(d),h=!1)},100);g.setItem=function(a,b){return h=!0,this[a]=b,i(),this[a]},g.getItem=function(a){return this[a]},g.removeItem=function(a){delete this[a],i()},g.clear=function(){var a=this;for(var b in a)"function"!=typeof a[b]&&delete a[b];i()},window.localStorage=g}}}(),SB.readyForPlatform("samsung",function(){var a=0,b=0,c=function(a,b,c){try{switch(c.length){case 0:return a[b]();case 1:return a[b](c[0]);case 2:return a[b](c[0],c[1]);case 3:return a[b](c[0],c[1],c[2]);case 4:return a[b](c[0],c[1],c[2],c[3]);case 5:return a[b](c[0],c[1],c[2],c[3],c[4]);case 6:return a[b](c[0],c[1],c[2],c[3],c[4],c[5]);case 7:return a[b](c[0],c[1],c[2],c[3],c[4],c[5],c[6]);case 8:return a[b](c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7])}}catch(d){throw d}};Player.extend({usePlayerObject:!0,_init:function(){var a=this;if(a.usePlayerObject?(a.plugin=document.getElementById("pluginPlayer"),$("body").append(a.$plugin)):a.plugin=sf.core.sefplugin("Player"),!a.plugin)throw new Error("failed to set plugin");a.plugin.OnStreamInfoReady="Player.OnStreamInfoReady",a.plugin.OnRenderingComplete="Player.OnRenderingComplete",a.plugin.OnCurrentPlayTime="Player.OnCurrentPlayTime",a.plugin.OnCurrentPlaybackTime="Player.OnCurrentPlayTime",a.plugin.OnBufferingStart="Player.OnBufferingStart",a.plugin.OnBufferingComplete="Player.OnBufferingComplete",a.plugin.OnEvent="Player.onEvent"},seek:function(a){0>=a&&(a=0);var b=Math.floor(a-this.videoInfo.currentTime-1);this.videoInfo.currentTime=a,alert("jump: "+b),0>b?this.doPlugin("JumpBackward",-b):this.doPlugin("JumpForward",b)},onEvent:function(a,b){switch(a){case 9:this.OnStreamInfoReady();break;case 4:break;case 8:this.OnRenderingComplete();break;case 14:this.OnCurrentPlayTime(b);break;case 13:break;case 12:this.OnBufferingComplete();break;case 11:this.OnBufferingStart()}},OnRenderingComplete:function(){alert("PLAYER COMPLETE"),Player.trigger("complete")},OnStreamInfoReady:function(){var a,b,c,d;try{a=this.doPlugin("GetDuration")}catch(e){alert("######## "+e.message)}if(a=Math.ceil(a/1e3),this.usePlayerObject)b=this.doPlugin("GetVideoWidth"),c=this.doPlugin("GetVideoHeight");else if(d=this.doPlugin("GetVideoResolution"),-1==d)b=0,c=0;else{var f=d.split("|");b=f[0],c=f[1]}this.videoInfo.duration=a,this.videoInfo.width=1*b,this.videoInfo.height=1*c,this.trigger("ready")},OnBufferingStart:function(){this.trigger("bufferingBegin")},OnBufferingComplete:function(){this.trigger("bufferingEnd")},OnCurrentPlayTime:function(a){"play"==this.state&&(alert(a/1e3),this.videoInfo.currentTime=a/1e3,this.trigger("update"))},_play:function(a){var b=a.url;switch(a.type){case"hls":b+="|COMPONENT=HLS"}this.doPlugin("InitPlayer",b),this.doPlugin("StartPlayback",a.from||0)},_stop:function(){this.doPlugin("Stop")},pause:function(){this.doPlugin("Pause"),this.state="pause"},resume:function(){this.doPlugin("Resume"),this.state="play"},doPlugin:function(){var a,b=this.plugin,d=arguments[0],e=Array.prototype.slice.call(arguments,1,arguments.length)||[];return this.usePlayerObject?a=c(b,d,e):(-1!=d.indexOf("Buffer")&&(d+="Size"),e.unshift(d),a=c(b,"Execute",e)),a},audio:{set:function(b){Player.doPlugin("SetStreamID",1,b),a=b},get:function(){for(var a=Player.doPlugin("GetTotalNumOfStreamID",1),b=[],c=0;a>c;c++)b.push(Player.doPlugin("GetStreamLanguageInfo",1,c));return b},cur:function(){return a}},subtitle:{set:function(a){Player.doPlugin("SetStreamID",5,a),b=a},get:function(){for(var a=Player.doPlugin("GetTotalNumOfStreamID",5),b=[],c=0;a>c;c++)b.push(Player.doPlugin("GetStreamLanguageInfo",5,c));return b},cur:function(){return b}}})}),!function(a){var b=a.document,c={audio:"SAMSUNG-INFOLINK-AUDIO",pluginObjectTV:"SAMSUNG-INFOLINK-TV",pluginObjectTVMW:"SAMSUNG-INFOLINK-TVMW",pluginObjectNetwork:"SAMSUNG-INFOLINK-NETWORK",pluginObjectNNavi:"SAMSUNG-INFOLINK-NNAVI",pluginPlayer:"SAMSUNG-INFOLINK-PLAYER"},d=["$MANAGER_WIDGET/Common/af/../webapi/1.0/deviceapis.js","$MANAGER_WIDGET/Common/af/../webapi/1.0/serviceapis.js","$MANAGER_WIDGET/Common/af/2.0.0/extlib/jquery.tmpl.js","$MANAGER_WIDGET/Common/Define.js","$MANAGER_WIDGET/Common/af/2.0.0/sf.min.js","$MANAGER_WIDGET/Common/API/Plugin.js","$MANAGER_WIDGET/Common/API/Widget.js","$MANAGER_WIDGET/Common/API/TVKeyValue.js","src/platforms/samsung/localstorage.js"];SB.createPlatform("samsung",{$plugins:{},platformUserAgent:"maple",onDetect:function(){for(var a="",e=0;e<d.length;e++)a+='<script type="text/javascript" src="'+d[e]+'"></script>';for(var f in c)a+="<object id="+f+' border=0 classid="clsid:'+c[f]+'" style="opacity:0.0;background-color:#000000;width:0px;height:0px;"></object>';b.write(a)},getNativeDUID:function(){return this.$plugins.pluginObjectNNavi.GetDUID(this.getMac())},getMac:function(){return this.$plugins.pluginObjectNetwork.GetMAC()},getSDI:function(){return this.SDI=this.$plugins.SDIPlugin.Execute("GetSDI_ID"),this.SDI},getHardwareVersion:function(){var a=this.firmware.match(/\d{4}/)||[];return this.hardwareVersion="2013"===a[0]?sf.core.sefplugin("Device").Execute("Firmware"):null,this.hardwareVersion},setPlugins:function(){function a(a){try{e.pluginAPI.unregistKey(d["KEY_"+a])}catch(b){$$error(b)}}var d,e=this,f=2;_.each(c,function(a,c){e.$plugins[c]=b.getElementById(c)}),this.$plugins.SDIPlugin=sf.core.sefplugin("ExternalWidgetInterface"),this.$plugins.tvKey=new Common.API.TVKeyValue;var g=this.$plugins.pluginObjectNNavi,h=this.$plugins.pluginObjectTV;this.modelCode=g.GetModelCode(),this.firmware=g.GetFirmware(),this.systemVersion=g.GetSystemVersion(0),this.productCode=h.GetProductCode(1),this.pluginAPI=new Common.API.Plugin,this.widgetAPI=new Common.API.Widget,d=new Common.API.TVKeyValue,this.productType=h.GetProductType(),this.setKeys(),this.pluginAPI.SetBannerState&&g.SetBannerState(f),a("VOL_UP"),a("VOL_DOWN"),a("MUTE"),this.widgetAPI.sendReadyEvent()},setKeys:function(){this.keys=sf.key,b.body.onkeydown=function(a){var b=a.keyCode;switch($$log("keyDown "+b),b){case sf.key.RETURN:case 147:case 261:sf.key.preventDefault()}}},enableScreenSaver:function(a){a=a||!1,sf.service.setScreenSaver(!0,a)},disableScreenSaver:function(){sf.service.setScreenSaver(!1)},exit:function(){sf.core.exit(!1)},sendReturn:function(){sf.core.exit(!0)},blockNavigation:function(){sf.key.preventDefault()}})}(this),function(a){"use strict";SB.readyForPlatform("samsung",function(){var b,c=function(a){switch(a.eventtype){case"EVENT_VOICE_END_MONITOR":break;case"EVENT_VOICE_BEGIN_MONITOR":case"EVENT_VOICE_BTSOUND_START":$$voice.refresh(),$$voice._resetVisibilityTimeout();break;case"EVENT_VOICE_RECOG_RESULT":var c=a.result.toLowerCase();"function"!=typeof b?$$voice.say(c):(b(c),b=!1,$$voice.restore())}};_.extend($$voice,{_init:function(){deviceapis.recognition.SubscribeExEvent(deviceapis.recognition.PL_RECOGNITION_TYPE_VOICE,"Smartbox",function(a){c(a)}),deviceapis.recognition.SetVoiceTimeout(this.voiceTimeout),a("body").append('<div id="voice_buble"></div><div id="help_voice_bubble"></div>')},_nativeCheckSupport:function(){var a=!1;try{a=deviceapis.recognition.IsRecognitionSupported()}catch(b){}return a},_nativeFromServer:function(a,c){b=c;var d={helpbarType:"HELPBAR_TYPE_VOICE_SERVER_GUIDE_RETURN",guideText:a};deviceapis.recognition.SetVoiceHelpbarInfo(JSON.stringify(d))},_setVoiceHelp:function(a){deviceapis.recognition.SetVoiceHelpbarInfo(JSON.stringify(a))},_nativeTurnOff:function(){deviceapis.recognition.SetVoiceHelpbarInfo(JSON.stringify({helpbarType:"HELPBAR_TYPE_VOICE_CUSTOMIZE",bKeepCurrentInfo:"false",helpbarItemsList:[]}))}})})}(jQuery);