1 !function(){"use strict";function e(e){var t=[],n=[];this.getId=function(){return e.sliderid},this.getCbHandle=function(){return e.cbhandle},this.getView=function(a){return a||(a=0),e.value[a]===t[a]?n[a]:(t[a]=e.value[a],e.formatter?n[a]=e.formatter(e.value[a],e.ctrlhandle):n[a]=e.value[a],n[a])},this.updateClass=function(t,n){e.updateClass(t,n)},this.forceRefresh=function(t){e.forceRefresh(t)},this.getValue=function(t){return t||(t=0),e.value[t]},this.getRelative=function(t){return t||(t=0),e.relative[t]},this.setValue=function(t,n){n||(n=0),e.setValue(t,n)},this.setDisable=function(t){e.setDisable(t)}}var t=angular.module("RangeSlider",[]);t.directive("rangeSlider",["$log","$document","$timeout",function(t,n,a){function i(t,i,s,o){t.initWidget=function(e){e.byStep&&(t.byStep=parseInt(e.byStep)),e.notMore&&(t.notMore=parseInt(e.notMore)),e.notLess&&(t.notLess=parseInt(e.notLess)),e.id&&(t.sliderid=e.id),void 0!==e.value&&(t.value=e.value,t.forceRefresh(50))},t.forceRefresh=function(e){var n=t.value;t.value=[void 0,void 0],a(function(){t.setValue(n[0],0),t.dual&&t.setValue(n[1],1)},e)},t.updateClass=function(e,t){t?i.addClass(e):i.removeClass(e)},t.setDisable=function(e){e?(i.addClass("disable"),t.handles[0].css("visibility","hidden"),t.dual&&t.handles[1].css("visibility","hidden")):(i.removeClass("disable"),t.handles[0].css("visibility","visible"),t.dual&&t.handles[1].css("visibility","visible"))},t.normalize=function(e){var n,a=t.notMore-t.notLess,i=e*a;if(t.byStep>0){var s=(i-i%t.byStep)/t.byStep,o=i%t.byStep,l=o>=.5*t.byStep?t.byStep:0;return n=s*t.byStep+l+t.notLess}if(t.byStep<0){var r=Math.pow(10,-1*t.byStep);return n=t.notLess+parseInt(i*r)/r}return i},t.getValue=function(e,n){t.vertical?t.relative[n]=(e-t.bounds.handles[n].getBoundingClientRect().height)/(t.bounds.bar.getBoundingClientRect().height-t.bounds.handles[n].getBoundingClientRect().height):t.relative[n]=e/(t.bounds.bar.getBoundingClientRect().width-t.bounds.handles[n].getBoundingClientRect().width);var a=t.normalize(t.relative[n]);a!==t.value[n]&&(a<t.startValue&&(a=t.startValue),a>t.stopValue&&(a=t.stopValue),t.formatter?t.viewValue=t.formatter(a,t.ctrlhandle):t.viewValue=a,t.displays[n]&&t.displays[n].html(t.viewValue),t.value[n]=a,o&&o.$setViewValue(t.viewValue),t.$apply(),a>t.startValue&&a<t.stopValue&&t.translate(e,n))},t.setStart=function(e){var n;e>t.value[0]&&(t.dual?t.setValue(e,1):t.setValue(e,0)),t.vertical?(n=t.bounds.bar.getBoundingClientRect().height*(e-t.notLess)/(t.notMore-t.notLess),t.start.css("height",n+"px")):(n=t.bounds.bar.getBoundingClientRect().width*(e-t.notLess)/(t.notMore-t.notLess),t.start.css("width",n+"px")),t.startValue=e},t.setStop=function(e){var n;e<t.value[0]&&(t.dual?t.setValue(e,1):t.setValue(e,0)),t.vertical?(n=t.bounds.bar.getBoundingClientRect().height*(e-t.notLess)/(t.notMore-t.notLess),t.start.css("height",n+"px")):(n=t.bounds.bar.getBoundingClientRect().width*(e-t.notLess)/(t.notMore-t.notLess),t.stop.css({right:0,width:t.bounds.bar.getBoundingClientRect().width-n+"px"})),t.stopValue=e},t.translate=function(e,n){var a;if(t.vertical){var i=t.bounds.bar.getBoundingClientRect().height-e;if(t.handles[n].css({"-webkit-transform":"translateY("+i+"px)","-moz-transform":"translateY("+i+"px)","-ms-transform":"translateY("+i+"px)","-o-transform":"translateY("+i+"px)",transform:"translateY("+i+"px)"}),t.dual){if(t.relative[1]&&t.relative[0]){var s=(t.relative[1]-t.relative[0])*t.bounds.bar.getBoundingClientRect().height;a=t.relative[0]*t.bounds.bar.getBoundingClientRect().height,t.slider.css({bottom:a+"px",height:s+"px"})}}else t.slider.css("height",e+"px")}else if(t.handles[n].css({"-webkit-transform":"translateX("+e+"px)","-moz-transform":"translateX("+e+"px)","-ms-transform":"translateX("+e+"px)","-o-transform":"translateX("+e+"px)",transform:"translateX("+e+"px)"}),t.dual){if(t.relative[1]&&t.relative[0]){var o=(t.relative[1]-t.relative[0])*t.bounds.bar.getBoundingClientRect().width;a=t.relative[0]*t.bounds.bar.getBoundingClientRect().width,t.slider.css({left:a+"px",width:o+"px"})}}else t.slider.css("width",e+"px")},t.setValue=function(e,n){var a;e!==t.value[n]&&(void 0===e&&(e=0),e>t.notMore&&(e=t.notMore),e<t.notLess&&(e=t.notLess),t.vertical?(t.relative[n]=(e-t.notLess)/(t.notMore-t.notLess),0===n&&(a=t.relative[n]*t.bounds.bar.getBoundingClientRect().height+t.bounds.handles[n].getBoundingClientRect().height/2),1===n&&(a=t.relative[n]*t.bounds.bar.getBoundingClientRect().height)):(t.relative[n]=(e-t.notLess)/(t.notMore-t.notLess),a=t.relative[n]*(t.bounds.bar.getBoundingClientRect().width-t.bounds.handles[n].getBoundingClientRect().width)),t.translate(a,n),t.value[n]=e,t.formatter?t.viewValue=t.formatter(e,void 0):t.viewValue=e,o&&o.$setViewValue(t.viewValue),t.displays[n]&&t.displays[n].html(t.viewValue))},t.keydown=function(e){switch(e.keyCode){case 39:case 38:t.byStep>0&&t.$apply(t.setValue(t.value[t.actif]+t.byStep,t.actif)),t.byStep<0&&t.$apply(t.setValue(t.value[t.actif]+1/Math.pow(10,-1*t.byStep),t.actif)),t.callback&&t.callback(t.value[t.actif],t.ctrlhandle);break;case 37:case 40:t.byStep>0&&t.$apply(t.setValue(t.value[t.actif]-t.byStep,t.actif)),t.byStep<0&&t.$apply(t.setValue(t.value[t.actif]-1/Math.pow(10,-1*t.byStep),t.actif)),t.callback&&t.callback(t.value[t.actif],t.ctrlhandle);break;case 27:t.handles[t.actif][0].blur()}},t.moveHandle=function(e,n,a){var i;t.vertical?(i=t.bounds.bar.getBoundingClientRect().bottom-a,i>t.bounds.bar.getBoundingClientRect().height&&(i=t.bounds.bar.getBoundingClientRect().height),i<t.bounds.handles[e].getBoundingClientRect().height&&(i=t.bounds.handles[e].getBoundingClientRect().height)):(i=n-t.bounds.bar.getBoundingClientRect().left,0>i&&(i=0),n+t.bounds.handles[e].getBoundingClientRect().width>t.bounds.bar.getBoundingClientRect().right&&(i=t.bounds.bar.getBoundingClientRect().width-t.bounds.handles[e].getBoundingClientRect().width)),t.getValue(i,e),t.dual&&t.value[0]>t.value[1]&&(0===e?t.setValue(t.value[0],1):t.setValue(t.value[1],0))},t.focusCB=function(e){e?n.on("keydown",t.keydown):n.unbind("keydown",t.keydown)},t.touchBarCB=function(e){var n,a=0,i=e.changedTouches,s=t.value[a];if(e.preventDefault(),t.dual){n=t.vertical?(i[0].pageY-t.bounds.bar.getBoundingClientRect().bottom)/t.bounds.bar.getBoundingClientRect().height:(i[0].pageX-t.bounds.bar.getBoundingClientRect().left)/t.bounds.bar.getBoundingClientRect().width;var o=Math.abs(n-t.relative[0]),l=Math.abs(n-t.relative[1]);o>l&&(a=1)}t.moveHandle(a,i[0].pageX,i[0].pageY),t.callback&&s!==t.value[a]&&t.callback(t.value[a],t.ctrlhandle)},t.touchHandleCB=function(e,a){function s(e){e.preventDefault();for(var n=e.changedTouches,i=0;i<n.length;i++)t.moveHandle(a,n[i].pageX,n[i].pageY)}function o(e){n.unbind("touchmove",s),n.unbind("touchend",o),i.on("touchstart",t.touchBarCB),t.callback&&l!==t.value[a]&&t.callback(t.value[a],t.ctrlhandle)}var l=t.value[a];e.preventDefault(),n.on("touchmove",s),n.on("touchend",o),i.unbind("touchstart",t.touchBarCB)},t.handleCB=function(e,a){function i(e){t.moveHandle(a,e.clientX,e.clientY)}function o(){n.unbind("mousemove",i),n.unbind("mouseup",o),t.callback&&l!==t.value[a]&&t.callback(t.value[a],t.ctrlhandle)}if(!s.automatic){var l=t.value[a];e.preventDefault(),n.on("mousemove",i),n.on("mouseup",o),t.handles[a][0].focus(),t.actif=a}},t.find=function(e,t){var n;n=t?t[0].querySelector(e):i[0].querySelector(e);var a=angular.element(n);return a},t.initialSettings=function(e){var n;t.value=[],t.relative=[],null===t.precision&&(n=(""+t.byStep).match(/\.([\d]*)/),t.precision=n&&n[1]?n[1].length:0),i.on("touchstart",t.touchBarCB),t.handles[0].on("touchstart",function(e){t.touchHandleCB(e,0)}),t.dual&&(t.handles[1].addClass("range-slider-handle"),t.handles[1].on("touchstart",function(e){t.touchHandleCB(e,1)}),t.initvalues||t.setValue(e[1],1)),t.initvalues?t.initWidget(t.initvalues):t.setValue(e[0],0)},t.init=function(){if(t.sliderid=s.id||"slider-"+parseInt(1e3*Math.random()),t.startValue=-(1/0),t.stopValue=1/0,t.byStep=parseInt(s.byStep)||1,t.vertical=s.vertical||!1,t.dual=s.dualHandles||!1,t.trigger_input_change=!1,t.notMore=parseInt(s.notMore)||100,t.notLess=parseInt(s.notLess)||0,t.vertical&&i.addClass("vertical-range"),t.handles=[t.find(".handle-min"),t.find(".handle-max")],t.bar=i,t.slider=t.find(".range-slider-active-segment"),t.start=t.find(".ibz-range-slider-start"),t.stop=t.find(".ibz-range-slider-stop"),t.disable=s.disable||!1,t.ctrlhandle=new e(t),t.bounds={bar:i[0],handles:[t.handles[0][0],t.handles[1][0]]},"true"===s.disable&&t.setDisable(!0),s.displayTarget)switch(s.displayTarget){case!0:case"handle":t.displays=t.handles,t.handles[0].addClass("ibz-range-slider-display"),t.dual&&t.handles[1].addClass("ibz-range-slider-display");break;default:t.displays=[n.getElementById(s.displayTarget)]}else t.displays=[];if(s.initial){var a=s.initial.split(",");t.initial=[void 0!==a[0]?parseInt(a[0]):t.notLess,void 0!==a[1]?parseInt(a[1]):t.notMore]}else t.initial=[t.ngModel,t.ngModel];t.$watch("startAt",function(){t.value<t.startAt,t.startAt&&t.setStart(t.startAt)}),t.$watch("stopAt",function(){t.value>t.stopAt,t.stopAt&&t.setStop(t.stopAt)}),t.initialSettings(t.initial)},t.init(),t.$watch("inithook",function(){t.inithook&&t.inithook(t.ctrlhandle)}),t.$watch("initvalues",function(){t.initvalues&&t.initWidget(t.initvalues)}),t.$watch("ngModel",function(e){t.setValue(e,0)})}var s='<div class="ibz-range-slider range-slider" title="{{title}}"data-slider><span class="range-slider-handle handle-min" ng-mousedown="handleCB($event,0)" ng-focus="focusCB(true)" ng-blur="focusCB(false)" role="slider" tabindex="0"></span><span class="handle-max" ng-mousedown="handleCB($event,1)" ng-focus="focusCB(true)" ng-blur="focusCB(false)" role="slider" tabindex="0"></span><span class="range-slider-active-segment"></span><span class="ibz-range-slider-start" ></span> <span class="ibz-range-slider-stop"></span> <input id={{sliderid}} type="hidden"></div>';return{restrict:"E",scope:{startAt:"=",stopAt:"=",callback:"=",formatter:"=",inithook:"=",cbhandle:"=",initvalues:"=",ngModel:"="},require:"?ngModel",template:s,replace:!0,link:i}}])}(),function(){"use strict";var e='<div class="afb-monitor" ng-click="getping()"><span class="afb-refresh-token" >afb://{{hostname}}:{{httpdport}}</span><i class="{{icon}}"></i></div>';angular.module("TokenRefresh",["AppConfig","ModalNotification"]).directive("tokenRefresh",["$log","$window","$timeout","$location","Notification","AppConfig","AppCall",function(t,n,a,i,s,o,l){function r(e,r,u){e.logged=void 0,n.onbeforeunload=function(){l.get(e.plugin,"logout",{},function(){t.log("OPA exit")})},e.online=function(){r.addClass("online"),r.removeClass("offline"),e.logged=!0},e.offline=function(){r.addClass("offline"),r.removeClass("online"),e.logged=!1},e.onerror=function(){e.logged!==!1&&(s.warning({message:"AppFramework Binder Lost",delay:5e3}),e.offline()),e.status=0},e.onsuccess=function(t,n){return 200!==n||"success"!==t.request.status?(s.warning({message:"auto-connect :"+t.request.info,delay:1e4}),e.offline(),!1):(e.logged!==!0&&(s.success({message:"AppFramework Binder Connected",delay:3e3}),e.online(),e.callback&&e.callback(t)),e.status=1,!0)},e.getping=function(){l.get(e.plugin,"ping",{},function(t,n){return 200!==n||"success"!==t.request.status?(s.warning({message:t.request.info,delay:5e3}),void e.offline()):void a(e.getping,1e3*o.session.pingrate)},e.onerror)},e.refresh=function(){l.get(e.plugin,"refresh",{},function(t,n){e.onsuccess(t,n),a(e.refresh,250*o.session.timeout)},e.onerror)},e.loggin=function(){l.get(e.plugin,"connect",{token:o.session.initial},function(t,n){e.onsuccess(t,n)&&(a(e.getping,1e3*o.session.pingrate),a(e.refresh,250*o.session.timeout))},e.onerror)},e.plugin=u.plugin||"auth",e.icon=u.icon||"fi-lightbulb",e.hostname=i.host(),e.httpdport=i.port(),e.autolog=JSON.parse(u.autolog||!1),e.autolog&&e.loggin()}return{template:e,scope:{callback:"="},restrict:"E",link:r}}])}(),function(){"use strict";var e='<div class="tip-modal-popup"><i class="{{icon}}"></i><span>{{tip}}</span></span></div>';angular.module("ModalNotification",[]).directive("tipModal",["$timeout",function(t){function n(e,n,a){function i(){function n(){e.show&&e.modal.css({opacity:1,visibility:"visible"})}e.show=!0,e.timeout=t(n,e.delay)}function s(){e.show=!1,e.modal.css({opacity:0,visibility:"hidden"})}e.parent=n.parent(),e.modal=n.find("div"),e.icon=a.icon||"fi-lightbulb",e.parent.addClass("as-modal-tip"),e.parent.bind("click",s),e.parent.bind("focus",i),e.parent.bind("mouseover",i),e.parent.bind("mouseleave",s),e.parent.bind("blur",s),e.delay=a.delay||1e3}return{restrict:"E",template:e,link:n,scope:{tip:"="}}}])}(),function(){"use strict";var e='<span title="Goto: {{href}}" ng-click="clicked()"><i class="{{icon}}"></i><span>{{label}}</span></span>';angular.module("LinkButton",[]).directive("linkButton",["$location",function(t){function n(e,n,a){e.clicked=function(){a.query?t.path(a.href).search(a.query):t.path(a.href)},e.icon=a.icon||"fi-link",e.label=a.label||"Jump",e.href=a.href||"/home",n.addClass(e.label.toLowerCase())}return{restrict:"E",template:e,link:n,scope:{}}}])}(),function(){"use strict";function e(e,t,n,a,i){var s=new XMLHttpRequest,o=new FormData,l=function(e){i(e)};s.upload.onprogress=function(t){var n=Math.round(t.lengthComputable?100*t.loaded/t.total:0);e.slider&&e.slider.setValue(n)},s.onload=function(){t.addClass("success"),t.removeClass("error");var n={status:s.status,headers:s.getAllResponseHeaders()};e.callback(n)},s.onerror=function(){t.addClass("error"),t.removeClass("success");var n={status:s.status,headers:s.getAllResponseHeaders()};e.callback(n)},s.onabort=function(){t.addClass("error"),t.removeClass("success");var n={status:s.status,headers:s.getAllResponseHeaders()};e.callback(n)};for(var r=0;r<a.length;r++){var u=a[r];if(u.type.match(e.mimetype)){if(u.size>1024*e.maxsize)return e.thumbnail=e.istoobig,void e.$apply("thumbnail");if(isNaN(u.size))return e.thumbnail=e.isnotvalid,void e.$apply("thumbnail");if(e.Basename=u.name.split("/").reverse()[0],e.imgElem[0].file=u,i){var c=new FileReader;c.readAsArrayBuffer(u),c.onload=l}o.append(e.name,u,u.name)}}s.open("POST",n,!0),s.send(o)}var t='<input type="file" name="{{name}}-input" onchange="angular.element(this).scope().UpLoadFile(this.files)" accept="{{mimetype}}" style="display:none"><div class="upload-file" ng-click="imgClicked()"><img id="{{name}}-img" src="{{thumbnail}}"><range-slider ng-show="!noslider" id="{{name}}-slider" automatic=true inithook="SliderInitCB"></range-slider></div>';angular.module("UploadFiles",["AppConfig","ModalNotification","RangeSlider"]).directive("uploadImage",["AppConfig","JQemu","Notification",function(n,a,i){function s(t,a,i){if(t.imgElem=a.find("img"),t.inputElem=a.find("input"),t.imgClicked=function(){t.inputElem[0].click()},t.SliderInitCB=function(e){t.slider=e},t.UpLoadFile=function(s){var o=function(e){return t.imgElem[0].src=window.URL.createObjectURL(new Blob([e.target.result],{type:"image"})),!0},l=i.posturl+"?token="+n.session.token;new e(t,a,l,s,o)},t.name=i.name||"file",t.category=i.category||"image",t.mimetype=(i.accept||"image")+"/*",t.maxsize=i.maxsize||100,t.regexp=new RegExp(i.accept+".*","i"),i.thumbnail?t.thumbnail=n.paths[t.category]+i.thumbnail:t.thumbnail=n.paths[t.category]+"tux-bzh.png",i.thumbnail?t.isnotvalid=n.paths[t.category]+i.isnotvalid:t.isnotvalid=n.paths[t.category]+"isnotvalid.png",i.istoobig?t.istoobig=n.paths[t.category]+i.istoobig:t.istoobig=n.paths[t.category]+"istoobig.png",t.noslider=i.noslider||!1,!i.posturl)throw new TypeError("file-upload %s posturl=/api/xxxx/xxxx required",t.attrs)}return{restrict:"E",template:t,link:s,scope:{callback:"="}}}]).directive("uploadAudio",["AppConfig","JQemu","Notification",function(n,a,i){function s(t,a,i){if(t.imgElem=a.find("img"),t.inputElem=a.find("input"),t.imgClicked=function(){t.inputElem[0].click()},t.SliderInitCB=function(e){t.slider=e},t.UpLoadFile=function(s){var o=i.posturl+"?token="+n.session.token;new e(t,a,o,s,!1)},t.name=i.name||"audio",t.category=i.category||"audio",t.mimetype=(i.accept||"audio")+"/*",t.maxsize=i.maxsize||1e4,t.regexp=new RegExp(i.accept+".*","i"),i.thumbnail?t.thumbnail=n.paths[t.category]+i.thumbnail:t.thumbnail=n.paths[t.category]+"upload-music.png",i.thumbnail?t.isnotvalid=n.paths[t.category]+i.isnotvalid:t.isnotvalid=n.paths[t.category]+"isnotvalid.png",i.istoobig?t.istoobig=n.paths[t.category]+i.istoobig:t.istoobig=n.paths[t.category]+"istoobig.png",t.noslider=i.noslider||!1,!i.posturl)throw new TypeError("file-upload %s posturl=/api/xxxx/xxxx required",t.attrs)}return{restrict:"E",template:t,link:s,scope:{callback:"="}}}]).directive("uploadAppli",["AppConfig","JQemu","Notification",function(n,a,i){function s(t,a,i){if(t.imgElem=a.find("img"),t.inputElem=a.find("input"),t.imgClicked=function(){t.inputElem[0].click()},t.SliderInitCB=function(e){t.slider=e},t.UpLoadFile=function(s){var o=function(e){var a=new JSZip(e.target.result),i=a.file("afa-pkg/thumbnail.jpg");return i?(t.imgElem[0].src=window.URL.createObjectURL(new Blob([i.asArrayBuffer()],{type:"image"})),!0):(t.thumbnail=n.paths[t.category]+"isnotvalid.png",t.$apply("thumbnail"),!1)},l=i.posturl+"?token="+n.session.token;new e(t,a,l,s,o)},t.name=i.name||"appli",t.category=i.category||"appli",t.mimetype=i.accept||".zip",t.maxsize=i.maxsize||1e5,t.regexp=new RegExp(i.accept+".*","i"),i.thumbnail?t.thumbnail=n.paths[t.category]+i.thumbnail:t.thumbnail=n.paths[t.category]+"upload-appli.png",i.thumbnail?t.isnotvalid=n.paths[t.category]+i.isnotvalid:t.isnotvalid=n.paths[t.category]+"isnotvalid.png",i.istoobig?t.istoobig=n.paths[t.category]+i.istoobig:t.istoobig=n.paths[t.category]+"istoobig.png",t.noslider=i.noslider||!1,!i.posturl)throw new TypeError("file-upload %s posturl=/api/xxxx/xxxx required",t.attrs)}return{restrict:"E",template:t,link:s,scope:{callback:"="}}}])}(),function(){"use strict";var e='<div ng-click="clicked()"><i class="{{icon}}"></i><span>{{label}}</span></div>';angular.module("SubmitButton",[]).directive("submitButton",function(){function t(e,t,n){e.icon=n.icon||"fi-foot",e.label=n.label||"Next",t.addClass(e.label.toLowerCase())}return{restrict:"E",template:e,link:t,scope:{clicked:"="}}})}(),function(){"use strict";var e='<div ng-click="clicked()"><img ng-src="{{icon}}"><span>{{label}}</span></div>',t='<b class="close-button" ng-click="close()">×</b><img ng-src="{{icon}}"><span class="modal-text">Application <b>{{label}}</b></span><ul class="vertical icon-left primary menu-bar appli-menu-start"><li class=start-{{runstatus}}><a ng-click=action("start")><i class="fi-check"> Start</i></a></li><li class=stop-{{runstatus}}><a ng-click=action("stop")><i class="fi-x"> Stop</i></a></li><li><a ng-click=action("info")><i class="fi-info"> Info</i></a></li><li class=start-{{runstatus}}><a ng-click=action("uninstall")><i class="fi-x"> Uninstall</i></a></li></ul>',n='<b class="close-button" ng-click="close()">×</b><img ng-src="{{icon}}"><span class="modal-text">Application <b>{{label}}</b></span><ul class="vertical icon-left appli-menu-info"><li><i class="fi-paperclip"> Name : {{detail.name}} </i></li><li><i class="fi-info"> Description {{detail.description}}</i></li><li><i class="fi-torso"> Author : {{detail.author}}</i></li></ul>';angular.module("AppliButton",[]).directive("appliButton",["AppConfig","AppCall","ModalFactory","Notification","$timeout","$window","$location","urlquery",function(a,i,s,o,l,r,u,c){function d(e,d,p){e.runstatus="stop",e.runmode=c.runmode||"auto",e.clicked=function(){var a=function(t,n){o.error({message:"Fail /api/afm-main"+t+"="+e.label+" RunID="+e.appID,delay:5e3}),d.addClass("fail"),d.removeClass("success"),e.callback(e.appID,t,n)},c=function(t,n){d.removeClass("fail"),e.runID=n.data.response.runid,e.callback(e.appID,t,n)},p=function(){e.modApp.deactivate(),l(function(){e.modApp.destroy()},1e3)},g=function(){e.modInfo.deactivate(),l(function(){e.modInfo.destroy()},1e3)},f=function(t){switch(t){case"start":if("stop"!==e.runstatus)return;i.get("afm-main","start",{id:e.appID,mode:e.runmode},function(n){return 200!==n.status||"afb-reply"!==n.data.jtype?void a("start",n):(e.runstatus="start",c(t,n),void(n.data.response.uri&&(e.winapp=r.open(n.data.response.uri.replace("%h",u.host())))))});break;case"stop":if("start"!==e.runstatus)return;i.get("afm-main","terminate",{runid:e.runID},function(n){return 200!==n.status||"afb-reply"!==n.data.jtype?void a("stop",n):(e.runstatus="stop",e.winapp&&(e.winapp.close(),e.winapp=!1),void c(t,n))});break;case"info":i.get("afm-main","detail",{id:e.appID},function(t){if(200!==t.status||"afb-reply"!==t.data.jtype)return void a("detail",t);var i={animationIn:"slideInFromTop",contentScope:{close:g,icon:e.icon,label:e.appID,detail:t.data.response},template:n};e.modInfo=new s(i),e.modInfo.activate()});break;case"uninstall":if("stop"!==e.runstatus)return;i.get("afm-main","uninstall",{id:e.appID},function(e){return 200!==e.status||"afb-reply"!==e.data.jtype?void a("uninstall",e):void c(t,e)})}p()},m={animationIn:"slideInFromTop",contentScope:{action:f,runstatus:e.runstatus,close:p,icon:e.icon,label:e.label},template:t};e.modApp=new s(m),e.modApp.activate()},p.handle&&e.store[p.handle].name?(e.icon=a.paths.icons+p.handle,e.label=e.store[p.handle].name,e.appID=p.handle):(e.icon=a.paths.icons+"w3c-ico.png",e.label=p.handle),d.addClass(e.label.toLowerCase())}return{restrict:"E",template:e,link:d,scope:{callback:"=",store:"="}}}])}(),function(){"use strict";angular.module("SamplePostModule",["SubmitButton","UploadFiles"]).controller("SamplePostController",["$http",function(e){var t=this;t.FileUploaded=function(e){}}])}(),function(){"use strict";angular.module("SampleHomeModule",["SamplePostModule","SubmitButton","TokenRefresh","ModalNotification"]).controller("SampleHomeController",["AppCall","Notification",function(e,t){var n=this;n.uuid="none",n.token="none",n.session="none",n.status="err-no",n.OnResponse=function(e,a){n.status=e.request.status,n.errcode=a,n.request=e.request,n.response=e.response;var i=e.request.reqid.toUpperCase();switch(i){case"CONNECT":if("success"!==e.request.status)return t.error({message:i+": Logout before reconnecting",delay:5e3}),void(n["class"][e.request.reqid]="fail");n["class"]={};break;case"LOGOUT":if("success"!==e.request.status)return t.error({message:i+": Do connect first",delay:5e3}),void(n["class"][e.request.reqid]="fail");n["class"]={};break;case"REFRESH":case"CHECK":if("success"!==e.request.status)return t.error({message:i+": Need to be Connected to check/refresh session",delay:5e3}),void(n["class"][e.request.reqid]="fail");break;default:return void t.error({message:"Invalid RequestID:"+e.request.reqid,delay:5e3})}n["class"][e.request.reqid]="success"},n.ProcessError=function(e,a,i){t.error({message:"Invalid API:"+e.request.reqid,delay:5e3}),n.status="err-fx",n.errcode=a,n.request=e.request,n.response=""},n.ConnectClient=function(){e.get("auth","connect",{},n.OnResponse,n.InvalidApiCall)},n.CheckSession=function(){e.get("auth","check",{},n.OnResponse,n.InvalidApiCall)},n.RefreshSession=function(){e.get("auth","refresh",{},n.OnResponse,n.InvalidApiCall)},n.LogoutClient=function(){e.get("auth","logout",{},n.OnResponse,n.InvalidApiCall)},n.Initialised=function(){n["class"]={connect:"success"}}}])}(),function(){"use strict";angular.module("JQueryEmu",[]).factory("JQemu",function(){var e=function(e,t){for(var n=e,a=t.toUpperCase();n[0];){if(a===n[0].tagName)return n;n=n.parent()}},t=function(e,t,n){for(var a=n.toLowerCase(),i=t.toLowerCase()+"Name",s=e.children();s[0];){if(a===s[0][i])return s;s=s.next()}},n=function(e,t){for(var n=t.toLowerCase(),a=e.children();a[0];){if(a.hasClass(n))return a;a=a.next()}},a={FindInParent:e,FindByTag:t,FindByClass:n};return a})}();var foundationRoutes=[{name:"PostSample",url:"/sample-post",controller:"SamplePostController as ctrl",animationIn:"slideInRight",path:"pages/SamplePost/SamplePost.html"},{name:"SampleHome",url:"/sample-home",controller:"SampleHomeController as ctrl",animationIn:"slideInRight",path:"pages/SampleHome/SampleHome.html"}];!function(){"use strict";angular.module("AppConfig",[]).factory("AppConfig",["urlquery",function(e){var t={paths:{image:"images/",avatar:"images/avatars/"},session:{initial:e.token||"123456789",timeout:3600,pingrate:30,uuid:"",token:""}};return t}]).factory("AppCall",["$http","AppConfig","$log",function(e,t,n){var a={get:function(n,a,i,s,o){var l=function(e){o?o(e.data,e.status,e.config):s(e.data,e.status,e.config)},r=function(e){if(!e.data||!e.data.request)return void l(e);var n=e.data.request;n.token&&(t.session.token=n.token),n.uuid&&(t.session.uuid=n.uuid),n.timeout&&(t.session.timeout=n.timeout),s(e.data,e.status,e.config)};i.token||(i.token=t.session.token),i.reqid||(i.reqid=a);e.get("/api/"+n+"/"+a,{params:i}).then(r,l)}};return a}])}(),function(){"use strict";function e(){var e={};return location.search.substr(1).split("&").forEach(function(t){var n=t.split("=")[0],a=decodeURIComponent(t.split("=")[1]);n in e?e[n].push(a):e[n]=[a]}),e}function t(e,t,n){e.otherwise("/sample-home"),t.html5Mode(!0).hashPrefix("!")}function n(){FastClick.attach(document.body)}angular.module("AFBclient",["ui.router","ngAnimate","foundation","foundation.dynamicRouting","foundation.dynamicRouting.animations","ui-notification","AppConfig","JQueryEmu","SampleHomeModule","UploadFiles","LinkButton","TokenRefresh","RangeSlider","ModalNotification"]).value("urlquery",e()).config(t).run(n),t.$inject=["$urlRouterProvider","$locationProvider"]}(),function(){angular.module("AFBclient").run(["$templateCache",function(e){e.put("pages/SamplePost/SamplePost.html",'<h1><img class="logo" src="images/logo/triskel_iot_bzhx250.png" alt="IoT.bzh Logo" style="height:150px"> Post File Upload</h1><div class="sample-box box-content"><upload-image category="avatar" thumbnail="tux-visitor.png" maxsize="100" posturl="/api/post/upload-image" callback="ctrl.FileUploaded" accept="image" title="Change your Avatar"></upload-image></div><link-button href="home" icon="fi-home" label="home"></link-button>')}])}(),function(){angular.module("AFBclient").run(["$templateCache",function(e){e.put("pages/SampleHome/SampleHome.html",'<h3><img class="logo" src="images/logo/triskel_iot_bzhx250.png" alt="IoT.bzh Logo" style="height:150px"> App Framework Binder Simple Client</h3><token-refresh autolog="true" callback="ctrl.Initialised"></token-refresh><div class="button-box box-content"><submit-button class="session-button {{ctrl.class.connect}}" icon="fi-unlock" label="Connect" clicked="ctrl.ConnectClient"></submit-button><submit-button class="session-button {{ctrl.class.check}}" icon="fi-checkbox" label="Check" clicked="ctrl.CheckSession"></submit-button><submit-button class="session-button {{ctrl.class.refresh}}" icon="fi-arrows-compress" label="Refresh" clicked="ctrl.RefreshSession"></submit-button><submit-button class="session-button {{ctrl.class.logout}}" icon="fi-lock" label="Logout" clicked="ctrl.LogoutClient"></submit-button></div><div class="message-box box-content vertical grid-frame"><div class="response"><span class="grid-content noscroll req {{ctrl.status}}">req= {{ctrl.request}}</span> <span class="grid-content noscroll res {{ctrl.status}}">res= {{ctrl.response}}</span> <span class="grid-content noscroll status {{ctrl.status}}">status= {{ctrl.errcode}}</span></div></div><link-button href="sample-post" icon="fi-home" label="SamplePost"></link-button>')}])}();