magcore-app-browser-engine
Version:
Browser Engine application for Ministra TV platform.
2 lines • 16.1 kB
JavaScript
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t,n){"use strict";var i=n(9),o=n(10).parse,a=new i;a.query=o(document.location.search.substring(1)),a.config=n(2),a.activePage=null,a.route=function(e,t){var n,i=a.activePage;return!(!e||e.active)&&(e.name,e.id,e.name,e.id,(n=a.activePage)&&n.active&&(n.$node.classList.remove("active"),n.active=!1,a.activePage=null,n.name,n.id,n.name,n.id,n.events["hide"]&&n.emit("hide")),function(e,t){!e||e.active||(e.$node.classList.add("active"),e.active=!0,a.activePage=e,e.name,e.id,e.name,e.id,e.events["show"]&&e.emit("show",{data:t}))}(e,t),this.events["route"]&&this.emit("route",{from:i,to:e}),!0)},e.exports=a},function(e,t,n){"use strict";var i=n(0),o=n(11);n(12),n(13),n(3)("sdk"),n(3)("app"),window.moveTo(0,0),window.resizeTo(i.metrics.width,i.metrics.height),window.stbEvent=n(15),window.gSTB&&gSTB.SetNativeStringMode&&gSTB.SetNativeStringMode(!0),o.contextmenu=function(e){e.preventDefault()},Object.keys(o).forEach(function(e){window.addEventListener(e,o[e])}),e.exports=i},function(e,t,n){"use strict";e.exports={startPage:"https://www.google.com",portalWindowId:1}},function(e,t,n){"use strict";var i=n(0);e.exports=function(e){var t=document.createElement("link");t.rel="stylesheet",t.href="css/"+e+"."+i.metrics.height+".css",document.head.appendChild(t)}},function(e,t,n){"use strict";e.exports={validateUrl:function(e){return/^(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i.test(e)},bind:function(e,t){var n;if(this.events||(this.events={}),"object"==typeof e)for(n in e)this.bind(n,e[n]);else"string"==typeof e&&"function"==typeof t&&(void 0===this.events[e]&&(this.events[e]=[]),this.events[e].push(t))},trigger:function(e,t){var n,i=[],o=this;return void 0!==e&&void 0!==this.events&&void 0!==this.events[e]&&this.events[e].forEach(function(e){void 0!==(n=e.call(o,t))&&i.push(n)}),i}}},function(e,t,n){"use strict";var i={toEngine:["reload","stopLoad","navigateForward","navigateBackward","hideWebWindow","openVirtualKeyboard","search","setFullScreen","userTextInput","userSettings","showWebWindow","intentUrl"],toApp:["ready","openTaskManager","openMenu","home","back","search","openSettings","notification","favoritesState","setFavicon","unsetFavicon","setLoadProgress","changeUrl","reload","mediaAvailable"]};Object.keys(i).forEach(function(e){i[e]=i[e].reduce(function(e,t){return e[t]=t,e},{})}),e.exports=i},function(e,t,n){"use strict";function i(e){for(var t=i.options,n=t.parser[t.strictMode?"strict":"loose"].exec(e),o={},a=14;a--;)o[t.key[a]]=n[a]||"";return o[t.q.name]={},o[t.key[12]].replace(t.q.parser,function(e,n,i){n&&(o[t.q.name][n]=i)}),o}i.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e.exports={parse:i}},function(e,t,n){"use strict";var i=n(17);i.back=i.backspace,i.channelNext=i.tab,i.channelPrev=i.tab+"s",i.ok=i.enter,i.exit=i.escape,i.volumeUp=107,i.volumeDown=109,i.f1="112c",i.f2="113c",i.f3="114c",i.f4="115c",i.refresh="116c",i.frame="117c",i.phone="119c",i.set="120c",i.tv="121c",i.menu="122c",i.app="123c",i.rewind="66a",i.forward="70a",i.audio="71a",i.standby="74a",i.keyboard="76a",i.usbMounted="80a",i.usbUnmounted="81a",i.playPause="82a",i.play=-1,i.pause=-1,i.stop="83a",i.power="85a",i.record="87a",i.info="89a",i.mute="192a",i.digit0=48,i.digit1=49,i.digit2=50,i.digit3=51,i.digit4=52,i.digit5=53,i.digit6=54,i.digit7=55,i.digit8=56,i.digit9=57,e.exports=i},function(e,t,n){"use strict";var i=n(1),o=n(4),a=n(5).toApp;stbEvent.trigger=o.trigger,stbEvent.bind=o.bind,i.activePage={},i.activePage.events={},gSTB.EnableVKButton(!0),gSTB.EnableAppButton(!1),gSTB.EnableServiceButton(!1),i.once("load",function(){var e=(0,n(6).parse)(location.href).queryKey,t=n(16),o=n(7),s=i.config;s.portalWindowId=e.portalWindowId||s.portalWindowId,e.page&&(t.resourcesLoadState.browseIntent=!0),t.loadUrl(e.page||s.startPage),i.addListener("keydown",function(e){switch(e.code){case o.f1:t.actions.f1();break;case o.f2:t.actions.f2();break;case o.f3:t.actions.f3();break;case o.f4:t.actions.f4();break;case o.menu:t.mode=t.MODE_MENU,stbWindowMgr.windowHide(t.webWindowHandle),stbWebWindow.messageSend(s.portalWindowId,a.openMenu);break;case o.frame:t.actions.frame();break;case o.back:gSTB.CloseWebWindow(),stbWebWindow.messageSend(s.portalWindowId,a.back);break;case o.exit:t.resourcesLoadState.isLoadStartTriggered&&t.actions.stop(),stbWindowMgr.windowHide(t.webWindowHandle),stbWebWindow.messageSend(s.portalWindowId,a.home);break;case o.mute:break;case o.app:t.mode=t.MODE_MENU,stbWindowMgr.windowHide(t.webWindowHandle),stbWebWindow.messageSend(s.portalWindowId,a.openTaskManager);break;case o.set:t.mode=t.MODE_MENU,stbWindowMgr.windowHide(t.webWindowHandle),stbWebWindow.messageSend(s.portalWindowId,a.openSettings)}})})},function(e,t,n){"use strict";function i(){this.events={}}i.prototype={addListener:function(e,t){this.events[e]=this.events[e]||[],this.events[e].push(t)},once:function(e,t){var n=this;this.events[e]=this.events[e]||[],this.events[e].push(function i(){n.removeListener(e,i),t.apply(n,arguments)})},addListeners:function(e){var t;for(t in e)e.hasOwnProperty(t)&&this.addListener(t,e[t])},removeListener:function(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(function(e){return e!==t}),0===this.events[e].length&&(this.events[e]=void 0))},emit:function(e){var t,n=this.events[e];if(n)for(t=0;t<n.length;t++)n[t].apply(this,Array.prototype.slice.call(arguments,1))}},i.prototype.constructor=i,e.exports=i},function(e,t,n){"use strict";e.exports={parse:function(e){var t={};return e.split("&").forEach(function(e){2===(e=e.split("=")).length&&(t[e[0]]=decodeURIComponent(e[1]))}),t},stringify:function(e){var t=[];return Object.keys(e).forEach(function(n){t.push(n+"="+encodeURIComponent(e[n]))}),t.join("&")}}},function(e,t,n){"use strict";var i=n(0);e.exports={DOMContentLoaded:function(e){i.events["dom"]&&i.emit("dom",e)},load:function(e){i.events[e.type]&&i.emit(e.type,e)},unload:function(e){i.events[e.type]&&i.emit(e.type,e)},error:function(e){},keydown:function(e){var t,n=i.activePage,o={code:e.keyCode,stop:!1};e.ctrlKey&&(o.code+="c"),e.altKey&&(o.code+="a"),e.shiftKey&&(o.code+="s"),(t=n.activeComponent)&&t!==n&&(t.events[e.type]&&t.emit(e.type,o,e),!o.stop&&t.propagate&&t.parent&&t.parent.events[e.type]&&t.parent.emit(e.type,o,e)),o.stop||(n.events[e.type]&&n.emit(e.type,o,e),e.stop||i.events[e.type]&&i.emit(e.type,o,e))},keypress:function(e){var t=i.activePage;t.activeComponent&&t.activeComponent!==t&&t.activeComponent.events[e.type]&&t.activeComponent.emit(e.type,e)},mousewheel:function(e){var t=i.activePage;t.activeComponent&&t.activeComponent!==t&&t.activeComponent.events[e.type]&&t.activeComponent.emit(e.type,e),e.stop||t.events[e.type]&&t.emit(e.type,e)}}},function(e,t,n){"use strict";if(!document.documentElement.classList){var i=Array.prototype,o=i.indexOf,a=i.slice,s=i.push,r=i.splice,d=i.join;window.DOMTokenList=function(e){if(this._element=e,e.className!==this._classCache){if(this._classCache=e.className,!this._classCache)return;var t,n=this._classCache.replace(/^\s+|\s+$/g,"").split(/\s+/);for(t=0;t<n.length;t++)s.call(this,n[t])}},window.DOMTokenList.prototype={add:function(e){this.contains(e)||(s.call(this,e),this._element.className=a.call(this,0).join(" "))},contains:function(e){return-1!==o.call(this,e)},item:function(e){return this[e]||null},remove:function(e){var t=o.call(this,e);-1!==t&&(r.call(this,t,1),this._element.className=a.call(this,0).join(" "))},toString:function(){return d.call(this," ")},toggle:function(e){return this.contains(e)?this.remove(e):this.add(e),this.contains(e)}},Object.defineProperty(Element.prototype,"classList",{get:function(){return new window.DOMTokenList(this)}})}},function(e,t,n){"use strict";var i=n(0),o=n(14);i.metrics=o[i.query.screenHeight]||o[screen.height]||o[720],i.metrics.availHeight=i.metrics.height-(i.metrics.availTop+i.metrics.availBottom),i.metrics.availWidth=i.metrics.width-(i.metrics.availLeft+i.metrics.availRight)},function(e,t,n){"use strict";e.exports={480:{height:480,width:720,availTop:24,availBottom:24,availRight:32,availLeft:48},576:{height:576,width:720,availTop:24,availBottom:24,availRight:26,availLeft:54},720:{height:720,width:1280,availTop:30,availBottom:30,availRight:40,availLeft:40},1080:{height:1080,width:1920,availTop:45,availBottom:45,availRight:60,availLeft:60}}},function(e,t,n){"use strict";var i=n(0);e.exports={EVENT_END_OF_FILE:1,EVENT_GET_MEDIA_INFO:2,EVENT_PLAYBACK_BEGIN:4,EVENT_CONTENT_ERROR:5,EVENT_DUAL_MONO_DETECT:6,EVENT_INFO_GET:7,EVENT_SUBTITLE_LOAD_ERROR:8,EVENT_SUBTITLE_FIND:9,EVENT_HDMI_CONNECT:32,EVENT_HDMI_DISCONNECT:33,EVENT_RECORD_FINISH_SUCCESSFUL:34,EVENT_RECORD_FINISH_ERROR:35,EVENT_DVB_SCANING:40,EVENT_DVB_FOUND:41,EVENT_DVB_CHANNEL_EPG_UPDATE:42,EVENT_DVB_ANTENNA_OFF:43,onEvent:function(e,t){if(i.events["media"]){if(t)try{t=JSON.parse(t)}catch(e){}i.emit("media",{code:parseInt(e,10),info:t})}},onBroadcastMessage:function(e,t,n){i.events["message"]&&i.emit("message",{broadcast:!0,windowId:e,message:t,data:n})},onMessage:function(e,t,n){i.events["message"]&&i.emit("message",{broadcast:!1,windowId:e,message:t,data:n})},onMediaAvailable:function(e,t){i.events["media:available"]&&i.emit("media:available",{mime:e,url:t})},onWebBrowserProgress:function(e){i.events["browser:progress"]&&i.emit("browser:progress",{progress:e})},onWindowActivated:function(){i.events["window:focus"]&&i.emit("window:focus")}}},function(e,t,n){"use strict";var i=n(1),o=n(7),a=n(5),s=a.toEngine,r=a.toApp,d=n(4),c=n(2),l={},u={x:i.metrics.availLeft,y:3*i.metrics.availTop,w:i.metrics.width-i.metrics.availLeft-i.metrics.availRight,h:i.metrics.height-3*i.metrics.availTop-3*i.metrics.availBottom},w={x:i.metrics.availLeft,y:i.metrics.availTop,w:i.metrics.width-i.metrics.availLeft-i.metrics.availRight,h:i.metrics.height-i.metrics.availTop-i.metrics.availBottom},f=0;function b(){l.actions.frame(l.webWindowIsFullScreen),l.actions.f2(l.webWindowIsVMouse),l.actions.scale(l.webWindowZoom)}l.storage={},l.MODE_MENU=1,l.MODE_BROWSER=2,l.mode=l.MODE_BROWSER,l.webWindowHandle=null,l.webWindowIsFullScreen=!1,l.webWindowIsVMouse=!1,l.webWindowZoom=100,l.webWindowUrl=null,l.resourcesLoadState={isColdStart:!0,isLoadStartTriggered:!1,browseIntent:!1},stbEvent.onMessage=function(e,t,n){switch(t){case s.userSettings:l.storage=JSON.parse(n),l.webWindowZoom=l.storage.settings.scale,l.webWindowIsFullScreen=l.storage.settings.isFullScreen,l.webWindowIsVMouse=l.storage.settings.isVirtualMouse,l.resourcesLoadState.isColdStart&&(l.resourcesLoadState.isColdStart=!1,b());break;case s.reload:l.actions.f1();break;case s.stopLoading:l.actions.stop();break;case s.navigateForward:l.actions.goForward();break;case s.navigateBackward:l.actions.goBack();break;case s.userTextInput:l.webWindowShow(!0),l.loadUrl(n);break;case s.showWebWindow:l.mode=l.MODE_BROWSER,l.webWindowShow(!0),n?l.loadUrl(n):f<100&&l.loadUrl(l.webWindowUrl);break;case s.hideWebWindow:i.emit("keydown",{code:o.menu});break;case s.openVirtualKeyboard:gSTB.IsVirtualKeyboardActive()?gSTB.HideVirtualKeyboard():gSTB.ShowVirtualKeyboard();break;case s.search:i.emit("keydown",{code:o.f4});break;case s.setFullScreen:i.emit("keydown",{code:o.frame});break;case s.intentUrl:l.resourcesLoadState.browseIntent=!0,l.webWindowShow(!0),d.validateUrl(n)&&l.loadUrl(n)}},stbEvent.bind("load.start",function(e){l.webWindowUrl!==e&&(stbWebWindow.messageSend(c.portalWindowId,r.changeUrl,JSON.stringify({url:e,title:stbWindowMgr.getCurrentTitle()})),l.webWindowUrl=e),stbWebWindow.messageSend(c.portalWindowId,r.unsetFavicon),l.resourcesLoadState.browseIntent&&stbWebWindow.messageSend(c.portalWindowId,r.reload,l.webWindowUrl)}),stbEvent.bind("load.finish",function(e){stbWebWindow.messageSend(c.portalWindowId,r.setFavicon),3===e&&(l.setWebWindowFullScreen(!1),stbWebWindow.messageSend(c.portalWindowId,r.notification,"This webpage is not available"))}),stbEvent.onWebBrowserProgress=function(e,t){l.resourcesLoadState.isLoadStartTriggered||(stbEvent.trigger("load.start",stbWindowMgr.getCurrWebUrl()),l.resourcesLoadState.isLoadStartTriggered=!0),stbWebWindow.messageSend(c.portalWindowId,r.setLoadProgress,""+e),f=e,100===e&&(stbEvent.trigger("load.finish",t),l.resourcesLoadState.isLoadStartTriggered=!1)},stbEvent.onMediaAvailable=function(e,t){l.mode=l.MODE_MENU,stbWindowMgr.windowHide(l.webWindowHandle),stbWebWindow.messageSend(c.portalWindowId,r.openMenu),stbWebWindow.messageSend(c.portalWindowId,r.mediaAvailable,JSON.stringify({itemMime:e,itemLink:t,itemName:n(6).parse(t).file}))},stbEvent.onWebBrowserFullScreenExit=function(){l.actions.frame()},l.loadUrl=function(e){l.webWindowHandle?(stbWindowMgr.LoadUrl(e),b()):(l.webWindowHandle=stbWindowMgr.initWebWindow(e),stbWindowMgr.resizeWebWindow(u.x,u.y,u.w,u.h),stbWindowMgr.raiseWebWindow(),stbWebWindow.messageSend(c.portalWindowId,r.ready))},l.actions={f1:function(){stbWebWindow.ReloadDocument()},f2:function(e){void 0===e?(l.webWindowIsVMouse=!l.webWindowIsVMouse,stbWindowMgr.setVirtualMouseMode(l.webWindowIsVMouse)):stbWindowMgr.setVirtualMouseMode(e)},f3:function(){l.setWebWindowFullScreen(!1),stbWebWindow.messageSend(c.portalWindowId,r.favoritesState,JSON.stringify({url:l.webWindowUrl,title:stbWindowMgr.getCurrentTitle()}))},f4:function(){l.setWebWindowFullScreen(!1),stbWindowMgr.windowHide(l.webWindowHandle),stbWebWindow.messageSend(c.portalWindowId,r.search)},frame:function(e){void 0===e?l.setWebWindowFullScreen(!l.webWindowIsFullScreen):(l.webWindowIsFullScreen=!e,l.setWebWindowFullScreen(e))},goBack:function(){stbWebWindow.NavigateBack()},goForward:function(){stbWebWindow.NavigateForward()},stop:function(){stbWebWindow.StopLoading()},scale:function(e){stbWebWindow.SetZoomFactor(e)}},l.webWindowShow=function(){null!==l.webWindowHandle&&(gSTB.EnableVKButton(!0),stbWindowMgr.windowShow(l.webWindowHandle),b())},l.setWebWindowFullScreen=function(e){var t;null!==l.webWindowHandle&&l.webWindowIsFullScreen!==e&&(t=e?w:u,l.webWindowIsFullScreen=e,stbWindowMgr.resizeWebWindow(t.x,t.y,t.w,t.h),stbWebWindow.SetFullScreenMode(e))},e.exports=l},function(e,t,n){"use strict";e.exports={backspace:8,tab:9,enter:13,escape:27,space:32,pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,del:46}}]);
//# sourceMappingURL=main.js.map