芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/novabrasil.mgaplay.com.br/web/dist/preview/html-preview.js
var LOG_LEVEL,previewLayout,VERSION="3.1",ID_COUNTER=0;function dsInit(e,i,t){LOG_LEVEL=10,$(".preview-log").css("display","none"),$(".preview-info").css("display","none"),$(".preview-end").css("display","none"),document.onkeypress=keyHandler,playLog(0,"info","Xibo HTML Preview v"+VERSION+" Starting Up",!0);var a={addedFiles:[],preloader:html5Preloader(),addFiles:function(e){this.addedFiles.includes(e)||(this.preloader.addFiles(e),this.addedFiles.push(e))}};previewLayout=new Layout(e,i,a,t)}function nextId(){return ID_COUNTER>500&&(ID_COUNTER=0),ID_COUNTER+=1}function playLog(e,i,t,a){if(e<=LOG_LEVEL){var n=timestamp()+" "+i.toUpperCase()+": "+t;e>0&&console.log(n),a&&$(".preview-log").html(n)}}function timestamp(){var e="",i=new Date,t=i.getDate(),a=i.getMonth()+1,n=i.getFullYear(),o=i.getHours(),r=i.getMinutes(),d=i.getSeconds();return r<10&&(r="0"+r),d<10&&(d="0"+d),(e+=t+"/"+a+"/"+n+" ")+(o+":")+r+":"+d+"'"+i.getMilliseconds()}function keyHandler(e){var i="charCode"in e?e.charCode:e.keyCode;if("l"==String.fromCharCode(i)){var t=$(".preview-log");"none"==t.css("display")?t.css("display","block"):t.css("display","none")}}function Layout(e,i,t,a){var n=this;n.id=e,n.parseXlf=function(e){playLog(10,"debug","Parsing Layout "+n.id,!1),n.containerName="L"+n.id+"-"+nextId(),n.regionMaxZIndex=0;var o=$("#screen_"+n.id);o.append('
'),!1===a&&o.append('
');var r=$("#"+n.containerName);if(r.css("display","none"),r.css("outline","red solid thin"),n.sw=o.width(),n.sh=o.height(),playLog(7,"debug","Screen is ("+n.sw+"x"+n.sh+") pixels"),n.layoutNode=e,n.xw=$(n.layoutNode).filter(":first").attr("width"),n.xh=$(n.layoutNode).filter(":first").attr("height"),n.zIndex=$(n.layoutNode).filter(":first").attr("zindex"),playLog(7,"debug","Layout is ("+n.xw+"x"+n.xh+") pixels"),n.scaleFactor=Math.min(n.sw/n.xw,n.sh/n.xh),n.sWidth=Math.round(n.xw*n.scaleFactor),n.sHeight=Math.round(n.xh*n.scaleFactor),n.offsetX=Math.abs(n.sw-n.sWidth)/2,n.offsetY=Math.abs(n.sh-n.sHeight)/2,playLog(7,"debug","Scale Factor is "+n.scaleFactor),playLog(7,"debug","Render will be ("+n.sWidth+"x"+n.sHeight+") pixels"),playLog(7,"debug","Offset will be ("+n.offsetX+","+n.offsetY+") pixels"),r.css("width",n.sWidth+"px"),r.css("height",n.sHeight+"px"),r.css("position","absolute"),r.css("left",n.offsetX+"px"),r.css("top",n.offsetY+"px"),null!=n.zIndex&&r.css("z-index",n.zIndex),n.bgColour=$(n.layoutNode).filter(":first").attr("bgcolor"),n.bgImage=$(n.layoutNode).filter(":first").attr("background"),""!=n.bgImage&&null!=n.bgImage){n.bgId=n.bgImage.substring(0,n.bgImage.indexOf("."));var d=i.layoutBackgroundDownloadUrl.replace(":id",n.id)+"?preview=1";t.addFiles(d+"&width="+n.sWidth+"&height="+n.sHeight+"&dynamic&proportional=0"),r.css("background","url('"+d+"&width="+n.sWidth+"&height="+n.sHeight+"&dynamic&proportional=0')"),r.css("background-repeat","no-repeat"),r.css("background-size",n.sWidth+"px "+n.sHeight+"px"),r.css("background-position","0px 0px")}r.css("background-color",n.bgColour);var s=[];$($.parseXML(n.layoutNode)).find("action").each((function(e,i){playLog(4,"debug","Creating action "+$(this).attr("id"),!1),s.push(new Action($(this).attr("id"),this))})),n.actionController=new ActionController(n,s,i),$($.parseXML(n.layoutNode)).find("drawer").each((function(){playLog(4,"debug","Creating drawer "+$(this).attr("id"),!1),n.drawer=this})),$($.parseXML(n.layoutNode)).find("region").each((function(){playLog(4,"debug","Creating region "+$(this).attr("id"),!1),n.regionObjects.push(new Region(n,$(this).attr("id"),this,i,t))})),playLog(4,"debug","Layout "+n.id+" has "+n.regionObjects.length+" regions"),n.actionController.initTouchActions(),n.ready=!1,t.addFiles(i.loaderUrl),a?t.preloader.on("finish",n.run):n.run()},n.run=function(){if(playLog(4,"debug","Running Layout ID "+n.id,!1),n.ready){$("#"+n.containerName).css("display","block"),$("#splash_"+n.id).css("display","none");for(var e=0;e
Old: "+o.curMedia.id),o.oldMedia=o.curMedia):o.oldMedia=void 0,o.currentMedia=o.currentMedia+1,o.currentMedia>=o.mediaObjects.length&&(o.finished(),o.currentMedia=0),playLog(8,"debug","nextMedia -> Next up is media "+(o.currentMedia+1)+" of "+o.mediaObjects.length),o.curMedia=o.mediaObjects[o.currentMedia],null!=o.curMedia&&playLog(8,"debug","nextMedia -> New: "+o.curMedia.id),o.transitionNodes(o.oldMedia,o.curMedia))},o.previousMedia=function(){o.currentMedia=o.currentMedia-1,o.currentMedia<0||o.ended?o.currentMedia=0:(o.curMedia?(playLog(8,"debug","previousMedia -> Old: "+o.curMedia.id),o.oldMedia=o.curMedia):o.oldMedia=void 0,o.curMedia=o.mediaObjects[o.currentMedia],null!=o.curMedia&&playLog(8,"debug","previousMedia -> New: "+o.curMedia.id),o.transitionNodes(o.oldMedia,o.curMedia))},o.checkReadyState=function(){for(var e=0;e
0&&o.nextMedia()},o.options=[],$(o.xml).children("options").children().each((function(){playLog(9,"debug","Option "+this.nodeName.toLowerCase()+" -> "+$(this).text(),!1),o.options[this.nodeName.toLowerCase()]=$(this).text()})),o.sWidth=$(t).attr("width")*o.layout.scaleFactor,o.sHeight=$(t).attr("height")*o.layout.scaleFactor,o.offsetX=$(t).attr("left")*o.layout.scaleFactor,o.offsetY=$(t).attr("top")*o.layout.scaleFactor,o.zIndex=$(t).attr("zindex"),$("#"+o.layout.containerName).append('
'),$("#"+o.containerName).css("width",o.sWidth+"px"),$("#"+o.containerName).css("height",o.sHeight+"px"),$("#"+o.containerName).css("position","absolute"),$("#"+o.containerName).css("left",o.offsetX+"px"),$("#"+o.containerName).css("top",o.offsetY+"px"),null!=o.zIndex&&($("#"+o.containerName).css("z-index",o.zIndex),parseInt(o.zIndex)>o.layout.regionMaxZIndex&&(o.layout.regionMaxZIndex=parseInt(o.zIndex))),playLog(4,"debug","Created region "+o.id,!1),playLog(7,"debug","Render will be ("+o.sWidth+"x"+o.sHeight+") pixels"),playLog(7,"debug","Offset will be ("+o.offsetX+","+o.offsetY+") pixels"),$(o.xml).children("media").each((function(){playLog(5,"debug","Creating media "+$(this).attr("id"),!1),o.mediaObjects.push(new media(o,$(this).attr("id"),this,a,n))}));for(var r=0;r
o.sHeight?o.sHeight:o.sWidth,$self.css("background-color","rgba(255, 0, 0, 0.25)"),$self.append('
'),$message=$("#empty_"+o.containerName),$message.append('
'),$message.append('
'+previewTranslations.emptyRegionMessage+"
")),playLog(4,"debug","Region "+o.id+" has "+o.mediaObjects.length+" media items")}function media(e,i,t,a,n){var o=this;o.region=e,o.xml=t,o.id=i,o.containerName="M-"+o.id+"-"+nextId(),o.iframeName=o.containerName+"-iframe",o.mediaType=$(o.xml).attr("type"),o.render=$(o.xml).attr("render"),o.attachedAudio=!1,o.singlePlay=!1,o.timeoutId=void 0,o.ready=!0,o.checkIframeStatus=!1,null==o.render&&(o.render="module"),o.run=function(){if(o.iframe)if(o.checkIframeStatus){var e=$("#"+o.containerName+" #"+o.iframeName);e[0].src=e[0].src}else $("#"+o.containerName).empty().append(o.iframe);playLog(5,"debug","Running media "+o.id+" for "+o.duration+" seconds"),"video"==o.mediaType&&$("#"+o.containerName+"-vid").get(0).play(),"audio"==o.mediaType&&$("#"+o.containerName+"-aud").get(0).play(),o.attachedAudio&&$("#"+o.containerName+"-attached-aud").get(0).play(),0==o.duration?"video"==o.mediaType?($("#"+o.containerName+"-vid").bind("ended",o.region.nextMedia),$("#"+o.containerName+"-vid").bind("error",o.region.nextMedia),$("#"+o.containerName+"-vid").bind("click",o.region.nextMedia)):"audio"==o.mediaType?($("#"+o.containerName+"-aud").bind("ended",o.region.nextMedia),$("#"+o.containerName+"-aud").bind("error",o.region.nextMedia),$("#"+o.containerName+"-aud").bind("click",o.region.nextMedia)):(o.duration=3,o.timeoutId=setTimeout(o.region.nextMedia,1e3*o.duration)):o.timeoutId=setTimeout(o.region.nextMedia,1e3*o.duration)},o.reset=function(){playLog(5,"debug","Reset media "+o.id),"video"==o.mediaType&&($("#"+o.containerName+"-vid").get(0).currentTime=0),"audio"==o.mediaType&&($("#"+o.containerName+"-aud").get(0).currentTime=0),o.attachedAudio&&($("#"+o.containerName+"-attached-aud").get(0).currentTime=0)},o.pause=function(){"video"==o.mediaType&&$("#"+o.containerName+"-vid").get(0).pause(),"audio"==o.mediaType&&$("#"+o.containerName+"-aud").get(0).pause(),o.attachedAudio&&$("#"+o.containerName+"-attached-aud").get(0).pause()},o.stop=function(){playLog(5,"debug","Stop media "+o.id),$("#"+o.containerName).css("display","none")},o.duration=$(o.xml).attr("duration"),o.lkid=$(o.xml).attr("lkid"),o.options=[],$(o.xml).find("options").children().each((function(){playLog(9,"debug","Option "+this.nodeName.toLowerCase()+" -> "+$(this).text(),!1),o.options[this.nodeName.toLowerCase()]=$(this).text()})),"1"===o.options.showfullscreen?(o.divWidth=o.region.layout.sWidth,o.divHeight=o.region.layout.sHeight):(o.divWidth=o.region.sWidth,o.divHeight=o.region.sHeight),$("#"+o.region.containerName).append('
');var r=$("#"+o.containerName);r.css("display","none"),r.css("width",o.divWidth+"px"),r.css("height",o.divHeight+"px"),r.css("position","absolute"),r.css("background-size","contain"),r.css("background-repeat","no-repeat"),r.css("background-position","center"),"1"===o.options.showfullscreen&&(r.css("left",-o.region.offsetX+"px"),r.css("top",-o.region.offsetY+"px"),r.css("z-index",o.region.layout.regionMaxZIndex+1));var d=a.getResourceUrl.replace(":regionId",o.region.id).replace(":id",o.id)+"?preview=1&layoutPreview=1&scale_override="+o.region.layout.scaleFactor,s="1"==o.options.loop||"1"==o.region.options.loop&&1==o.region.totalMediaObjects;if("html"==o.render||"ticker"==o.mediaType){if(o.checkIframeStatus=!0,o.iframe=$('
'),"1"==o.options.durationisperitem||"1"==o.options.durationisperpage){var c=new RegExp("\x3c!-- NUMITEMS=(.*?) --\x3e");jQuery.ajax({url:d+"&width="+o.divWidth+"&height="+o.divHeight,success:function(e){var i=c.exec(e);null!=i&&(o.duration=parseInt(o.duration)*parseInt(i[1]))},async:!1})}}else if("image"===o.mediaType)if(n.addFiles(d),r.css("background-image","url('"+d+"')"),"stretch"===o.options.scaletype)r.css("background-size","100% 100%");else if("fit"===o.options.scaletype)r.css("background-size","cover");else{var l=""==o.options.align?"center":o.options.align,g=""==o.options.valign||"middle"==o.options.valign?"center":o.options.valign;r.css("background-position",l+" "+g)}else if("text"==o.mediaType||"datasetview"==o.mediaType||"webpage"==o.mediaType||"embedded"==o.mediaType)o.checkIframeStatus=!0,o.iframe=$('
');else if("video"==o.mediaType)n.addFiles(d),o.iframe=$('
Unsupported Video
'),"stretch"==o.options.scaletype&&o.iframe.css("object-fit","fill");else if("audio"==o.mediaType)n.addFiles(d),r.append('
Unsupported Audio
');else if("flash"==o.mediaType){var p='
';p=p+'
',n.addFiles(d),o.iframe=$(p)}else r.css("outline","red solid thin");if(o.iframe&&o.checkIframeStatus&&(o.ready=!1,$("#"+o.containerName).empty().append(o.iframe),$(o.iframe).on("load",(function(){o.ready=!0}))),$(o.xml).find("audio").length>0){var u=$(o.xml).find("audio"),h=u.find("uri"),m=h.attr("mediaid"),f=a.libraryDownloadUrl.replace(":id",m);if(null!=n.preloader.filesLoadedMap[f]&&n.addFiles(f),null!=h.attr("volume")){var y=h.attr("volume")/100;u.get(0).volume=y}u.prop("loop","1"==h.get(0).getAttribute("loop")),u.attr("id",o.containerName+"-attached-aud"),u.append('
Unsupported Audio'),r.append(u),o.attachedAudio=!0}playLog(5,"debug","Created media "+o.id)}function Action(e,i){this.id=e,this.xml=i}function ActionController(e,i,t){var a=this;a.parent=e,a.actions=[];var n=$('
').appendTo($("#"+e.containerName));n.append($('
'+previewTranslations.actionControllerTitle+"
"));for(var o=$('
').appendTo(n),r=0;r
"),c=$(d.xml).prop("attributes");$.each(c,(function(){s.data(this.name,this.value),s.attr(this.name,this.value)}));var l="";l+='
'+previewTranslations[s.attr("actiontype")],"navWidget"==s.attr("actiontype")?l+='
['+s.attr("widgetId")+"]
":"navLayout"==s.attr("actiontype")&&(l+='
['+s.attr("layoutCode")+"]
"),l+="
",l+='
'+s.attr("target"),""!=s.attr("targetid")&&(l+="("+s.attr("targetid")+s.attr("layoutcode")+")"),l+="
",s.html(l),s.addClass("action",d.id),s.attr("originalId",d.id),s.attr("id","A-"+d.id+"-"+nextId()),s.appendTo(o)}n.draggable({handle:".action-controller-title",scroll:!1,cursor:"dragging",containment:"parent"}),n.find(".toggle").click((function(){n.toggleClass("d-none")})),n.toggle(n.find('.action[triggerType="webhook"]').length>0);var g=function(e){"navLayout"==e.actionType?function(e){if(confirm(previewTranslations.navigateToLayout.replace("[layoutTag]",e))){var i=t.layoutPreviewUrl.replace("[layoutCode]",e)+"?findByCode=1";window.open(i,"_blank")}}(e.layoutCode):"previous"!=e.actionType&&"next"!=e.actionType||"region"!=e.target?"navWidget"==e.actionType&&"region"==e.target?function(e,i){var t,n,o=0;for(o=0;o
"+e.target+"["+e.targetId+"]"):function(e,i){for(var t=0;t