magcore-osd-access-control
Version:
OSD for access control for MAGCORE platform.
2 lines • 14 kB
JavaScript
!function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var i=n(1),s=n(6).parse,o=new i;o.query=s(document.location.search.substring(1)),o.config=n(7),o.activePage=null,o.route=function(t,e){var n,i=o.activePage;return!(!t||t.active)&&(t.name,t.id,t.name,t.id,(n=o.activePage)&&n.active&&(n.$node.classList.remove("active"),n.active=!1,o.activePage=null,n.name,n.id,n.name,n.id,n.events["hide"]&&n.emit("hide")),function(t,e){!t||t.active||(t.$node.classList.add("active"),t.active=!0,o.activePage=t,t.name,t.id,t.name,t.id,t.events["show"]&&t.emit("show",{data:e}))}(t,e),this.events["route"]&&this.emit("route",{from:i,to:t}),!0)},t.exports=o},function(t,e,n){"use strict";function i(){this.events={}}i.prototype={addListener:function(t,e){this.events[t]=this.events[t]||[],this.events[t].push(e)},once:function(t,e){var n=this;this.events[t]=this.events[t]||[],this.events[t].push(function i(){n.removeListener(t,i),e.apply(n,arguments)})},addListeners:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this.addListener(e,t[e])},removeListener:function(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(function(t){return t!==e}),0===this.events[t].length&&(this.events[t]=void 0))},emit:function(t){var e,n=this.events[t];if(n)for(e=0;e<n.length;e++)n[e].apply(this,Array.prototype.slice.call(arguments,1))}},i.prototype.constructor=i,t.exports=i},function(t,e,n){"use strict";var i=n(0);t.exports=function(t){var e=document.createElement("link");e.rel="stylesheet",e.href="css/"+t+"."+i.metrics.height+".css",document.head.appendChild(e)}},function(t,e,n){"use strict";var i=n(4),s=n(13);i.once("load",function(){i.pages={main:n(15)},s.load({name:core.environment.language},function(){parent.extendCorePrototype("accessControl",n(19)),i.route(i.pages.main)})})},function(t,e,n){"use strict";var i=n(5);t.exports=i},function(t,e,n){"use strict";var i=n(0),s=n(8);window.core=window.parent.getCoreInstance(window,i),n(9),n(10),n(2)("sdk"),n(12),n(2)("app"),i.platform="mag",i.ready=function(){window.core.call("app:ready")},i.exit=function(){i.events["exit"]&&i.emit("exit"),core.call("exit")},s.load=function(t){document.body.setAttribute("platform",i.platform),core.ready?i.events["load"]&&i.emit("load",{}):core.once("load",function(){i.events[t.type]&&i.emit(t.type,t)})},s.contextmenu=function(t){t.preventDefault()},Object.keys(s).forEach(function(t){window.addEventListener(t,s[t])}),t.exports=i},function(t,e,n){"use strict";t.exports={parse:function(t){var e={};return t.split("&").forEach(function(t){2===(t=t.split("=")).length&&(e[t[0]]=decodeURIComponent(t[1]))}),e},stringify:function(t){var e=[];return Object.keys(t).forEach(function(n){e.push(n+"="+encodeURIComponent(t[n]))}),e.join("&")}}},function(t,e,n){"use strict";t.exports={}},function(t,e,n){"use strict";var i=n(0);t.exports={DOMContentLoaded:function(t){i.events["dom"]&&i.emit("dom",t)},load:function(t){i.events[t.type]&&i.emit(t.type,t)},unload:function(t){i.events[t.type]&&i.emit(t.type,t)},error:function(t){},keydown:function(t){var e,n=i.activePage,s={code:t.keyCode,stop:!1};t.ctrlKey&&(s.code+="c"),t.altKey&&(s.code+="a"),t.shiftKey&&(s.code+="s"),(e=n.activeComponent)&&e!==n&&(e.events[t.type]&&e.emit(t.type,s,t),!s.stop&&e.propagate&&e.parent&&e.parent.events[t.type]&&e.parent.emit(t.type,s,t)),s.stop||(n.events[t.type]&&n.emit(t.type,s,t),t.stop||i.events[t.type]&&i.emit(t.type,s,t))},keypress:function(t){var e=i.activePage;e.activeComponent&&e.activeComponent!==e&&e.activeComponent.events[t.type]&&e.activeComponent.emit(t.type,t)},mousewheel:function(t){var e=i.activePage;e.activeComponent&&e.activeComponent!==e&&e.activeComponent.events[t.type]&&e.activeComponent.emit(t.type,t),t.stop||e.events[t.type]&&e.emit(t.type,t)}}},function(t,e,n){"use strict";if(!document.documentElement.classList){var i=Array.prototype,s=i.indexOf,o=i.slice,a=i.push,r=i.splice,c=i.join;window.DOMTokenList=function(t){if(this._element=t,t.className!==this._classCache){if(this._classCache=t.className,!this._classCache)return;var e,n=this._classCache.replace(/^\s+|\s+$/g,"").split(/\s+/);for(e=0;e<n.length;e++)a.call(this,n[e])}},window.DOMTokenList.prototype={add:function(t){this.contains(t)||(a.call(this,t),this._element.className=o.call(this,0).join(" "))},contains:function(t){return-1!==s.call(this,t)},item:function(t){return this[t]||null},remove:function(t){var e=s.call(this,t);-1!==e&&(r.call(this,e,1),this._element.className=o.call(this,0).join(" "))},toString:function(){return c.call(this," ")},toggle:function(t){return this.contains(t)?this.remove(t):this.add(t),this.contains(t)}},Object.defineProperty(Element.prototype,"classList",{get:function(){return new window.DOMTokenList(this)}})}},function(t,e,n){"use strict";var i=n(0),s=n(11);i.metrics=s[i.query.screenHeight]||s[screen.height]||s[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(t,e,n){"use strict";t.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(t,e,n){"use strict";var i,s=n(0);(i=document.createElement("link")).rel="stylesheet",i.href=window.core.theme.path+s.metrics.height+".css",document.head.appendChild(i),t.exports=i},function(t,e,n){"use strict";var i=n(1),s=n(14),o=new i;function a(t){var e=new s(t);return window.gettext=window._=e.gettext,window.pgettext=e.pgettext,window.ngettext=e.ngettext,e}o.defaultLanguage="en",o.load=function(t,e){var n;return t.ext=t.ext||"json",t.path=t.path||"lang",t.name===o.defaultLanguage?(a(),e(null),!1):((n=new XMLHttpRequest).onload=function(){try{a(JSON.parse(n.responseText)),e(null),o.events["load"]&&o.emit("load")}catch(t){n.onerror(t)}},n.ontimeout=n.onerror=function(t){a(),e(t),o.events["error"]&&o.emit("error",t)},n.open("GET",t.path+"/"+t.name+"."+t.ext,!0),n.send(null),!0)},t.exports=o},function(module,exports,__webpack_require__){"use strict";function Gettext(config){var data,meta;config=config||{},data=config.data||{},data[""]=data[""]||{},meta=config.meta,this.gettext=function(t){return data[""][t]||t},this.pgettext=function(t,e){return data[t]&&data[t][e]||e},this.ngettext=function(msgId,plural,value){var n,evalResult;return data&&meta&&data[""][msgId]?(evalResult=eval("n = "+value+"; "+meta.plural),"boolean"==typeof evalResult&&(evalResult=+evalResult),data[""][msgId][evalResult]):1===value?msgId:plural}}Gettext.prototype.constructor=Gettext,module.exports=Gettext},function(t,e,n){"use strict";var i=new(n(16))({$node:document.getElementById("pageMain")});t.exports=i},function(t,e,n){"use strict";t.exports=n(17),t.exports.prototype.name="stb-component-page"},function(t,e,n){"use strict";var i=n(18);function s(t){t=t||{},this.active=!1,this.activeComponent=null,i.call(this,t),this.active=this.$node.classList.contains("active"),null===this.$node.parentNode&&document.body.appendChild(this.$node),this.page=this}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,s.prototype.name="spa-component-page",t.exports=s},function(t,e,n){"use strict";var i=n(0),s=n(1),o=0;function a(t){var e,n=this;if(t=t||{},this.visible=!0,this.focusable=!0,this.$node=null,this.$body=null,this.parent=null,this.children=[],this.propagate=!!t.propagate,s.call(this),this.$node=t.$node||document.createElement("div"),this.$body=t.$body||this.$node,this.$node.className=this.name+" "+(t.className||""),this.id=t.id||this.$node.id||"cid"+o++,t.parent&&t.parent.add(this),!1===t.visible&&this.hide(),!1===t.focusable&&(this.focusable=!1),this.defaultEvents)for(e in t.events=t.events||{},this.defaultEvents)t.events[e]=t.events[e]||this.defaultEvents[e];t.events&&Object.keys(t.events).forEach(function(e){n.addListener(e,t.events[e])}),t.children&&this.add.apply(this,t.children),this.$node.addEventListener("click",function(t){n.focus(),n.events["click"]&&n.emit("click",t),t.stopPropagation()}),this.name,this.id,this.name,this.id}a.prototype=Object.create(s.prototype),a.prototype.constructor=a,a.prototype.defaultEvents=null,a.prototype.add=function(t){var e;for(e=0;e<arguments.length;e++)t=arguments[e],this.children.push(t),t.parent=this,t.$node&&null===t.$node.parentNode&&this.$body.appendChild(t.$node),t.name,t.id,this.name,this.id,this.name,this.id,t.name,t.id,this.events["add"]&&this.emit("add",{item:t})},a.prototype.remove=function(){this.parent&&(i.activePage.activeComponent===this&&(this.blur(),this.parent.focus()),this.parent.children.splice(this.parent.children.indexOf(this),1)),this.children.forEach(function(t){t.remove()}),this.$node.parentNode.removeChild(this.$node),this.events["remove"]&&this.emit("remove"),this.events={},this.name,this.id,this.name,this.id},a.prototype.focus=function(t){var e=i.activePage,n=e.activeComponent;return!(!this.focusable||this===n)&&(n&&n.blur(),e.activeComponent=n=this,n.$node.classList.add("focus"),this.name,this.id,this.name,this.id,n.events["focus"]&&n.emit("focus",t),!0)},a.prototype.blur=function(){var t=i.activePage,e=t.activeComponent;return this.$node.classList.remove("focus"),this===e?(t.activeComponent=null,this.name,this.id,this.name,this.id,this.events["blur"]&&this.emit("blur"),!0):(this.name,this.id,this.name,this.id,!1)},a.prototype.show=function(t,e){return!this.visible&&(this.$node.classList.remove("hidden"),this.visible=!0,this.name,this.id,this.name,this.id,this.events["show"]&&this.emit("show",t),"function"==typeof e&&setTimeout(e),!0)},a.prototype.hide=function(t){return!!this.visible&&(this.$node.classList.add("hidden"),this.visible=!1,this.name,this.id,this.name,this.id,this.events["hide"]&&this.emit("hide"),"function"==typeof t&&setTimeout(t),!0)},t.exports=a},function(t,e,n){"use strict";var i,s,o={password:"0000",sessionTime:0,active:!0},a="parent.settings",r=!1,c=null;function u(t,e){return core.intent({action:"keyboard",data:{type:t.type,mode:t.mode,title:t.title,value:t.value},events:{done:e}},function(t){})}function d(){core.backend.request("storage/",{method:"POST",body:JSON.stringify({key:a,value:JSON.stringify(o)})})}i={request:function(t,e){var n,s=null;"function"==typeof(t=t||null)&&(e=t,t=null),i.settings.active?r?e(!1,!0):null===t?(null!==c&&(c.close(),c=null),(n=u({type:"password",mode:"number",title:gettext("Input password"),description:gettext("Parental control")},function(t){(s=t.value===i.settings.password)||(c=core.notify({title:gettext("Wrong password for parental control"),icon:"alert",type:"warning",timeout:1e4})),e(!s,s)})).state===n.STATE_NOT_RESOLVED?e(!1,!1):n.once("close",function(){null===s&&e(!0)})):(s=t===i.settings.password,e(!s,s)):e(!1,!0)},settings:{update:function(t,e){var n=!1;void 0!==t.active&&t.active!==o.isActive&&(n=!0),void 0!==t.sessionTime&&t.sessionTime!==o.sessionTime&&t.sessionTime===Number(t.sessionTime)&&(n=!0),void 0!==t.password&&t.password!==o.password&&(n=!0),n&&i.request(t.oldPassword,function(n){var i=null;n||(void 0!==t.active&&(o.active=!!t.active),void 0!==t.sessionTime&&(o.sessionTime=t.sessionTime,r=!0,setTimeout(function(){r=!1},o.sessionTime)),void 0!==t.password&&(i=!0,o.password=""+t.password),core.backend&&core.backend.request?(i&&core.backend.request("users/"+core.backend.session.userId+"/settings",{headers:{"Content-Type":"application/x-www-form-urlencoded"},method:"PUT",body:"parent_password="+o.password}),core.backend.request("storage/",{method:"POST",async:!0,body:JSON.stringify({key:a,value:JSON.stringify(o)})})):core.storage.setItem(a,o)),e(n)})},updatePassword:function(t){null!==c&&(c.close(),c=null),u({type:"password",mode:"number",title:gettext("Enter current password"),description:gettext("Parental control")},function(e){var n=e.value;n===o.password?u({type:"password",mode:"number",title:gettext("Enter new password"),description:gettext("Parental control")},function(e){e.value===o.password?c=core.notify({title:gettext("The new password is the same as current one"),icon:"alert",type:"warning"}):core.accessControl.settings.update({oldPassword:n,password:e.value},function(e,n){e||(c=core.notify({title:gettext("Password changed successfully"),icon:"info",type:"success"})),t(e,n)})}):c=core.notify({title:gettext("Wrong current password"),icon:"alert",type:"error"})})}}},Object.defineProperties(i.settings,{password:{get:function(){return o.password}},sessionTime:{get:function(){return o.sessionTime}},active:{get:function(){return o.active}}}),Object.defineProperty(i,"state",{get:function(){return r}}),core.backend?(o.password=core.backend.settings.parent_password,core.backend.request("storage/"+a,{onload:function(t,e){if(t)d();else if(e.data&&e.data.value)try{e.data.value=JSON.parse(e.data.value),o.sessionTime=e.data.value.sessionTime,o.active=e.data.value.active}catch(t){d()}}})):(s=core.storage.getItem(a))&&(o.password=s.password,o.active=!!s.active,o.sessionTime=parseInt(s.sessionTime,10)),t.exports=i}]);
//# sourceMappingURL=main.js.map