Sindbad~EG File Manager
!function(){"use strict";var e=JSON.parse('[{"name":"modeDoorImage","type":"select","label":"Mode for door images","description":"Select whether you want to set each custom door image yourself or let H5P do the work for you based on the calendar background image set in the behavioural settings.","options":[{"value":"manual","label":"I want to set each door image myself"},{"value":"automatic","label":"H5P shall set the door images based on the background image"}],"default":"automatic"},{"name":"doors","type":"list","label":"Doors","entity":"door","min":24,"max":24,"field":{"name":"contentGroup","type":"group","fields":[{"name":"type","type":"select","label":"Content type","description":"Content type that shoud optionally pop up when the door is opened.","options":[{"value":"audio","label":"Audio"},{"value":"image","label":"Image"},{"value":"link","label":"Link"},{"value":"text","label":"Text"},{"value":"video","label":"Video"}]},{"name":"audio","type":"audio","label":"Audio","widget":"showWhen","showWhen":{"rules":[{"field":"type","equals":"audio"}]}},{"name":"image","type":"library","label":"Image","options":["H5P.Image 1.1"],"widget":"showWhen","showWhen":{"rules":[{"field":"type","equals":"image"}]}},{"name":"link","type":"library","label":"Link","options":["H5P.Link 1.3"],"widget":"showWhen","showWhen":{"rules":[{"field":"type","equals":"link"}]}},{"name":"text","type":"library","label":"Text","options":["H5P.AdvancedText 1.1"],"widget":"showWhen","showWhen":{"rules":[{"field":"type","equals":"text"}]}},{"name":"video","type":"video","label":"Video","widget":"showWhen","showWhen":{"rules":[{"field":"type","equals":"video"}]}},{"name":"autoplay","type":"boolean","label":"Autoplay","default":false,"widget":"showWhen","showWhen":{"type":"or","rules":[{"field":"type","equals":"audio"},{"field":"type","equals":"video"}]}},{"name":"doorCover","type":"image","label":"Door image","description":"Image that will be used for the door. Needs to have a size ratio of 1:1 if you want the left half fit the right half.","optional":true,"widget":"showWhen","showWhen":{"rules":[{"field":"../../modeDoorImage","equals":"manual"}]}},{"name":"previewImage","type":"image","label":"Background image","description":"Image that should appear inside the door. Will be the door\'s number by default.","optional":true}]},"widgets":[{"name":"VerticalTabs","label":"Default"}]},{"name":"visuals","type":"group","label":"Visual settings","description":"These options will let you configure the visual appearance.","importance":"low","fields":[{"name":"backgroundImage","type":"image","label":"Calendar background image","optional":true},{"name":"doorImageTemplate","type":"image","label":"Door image template","description":"If an image is set, it will be used for every door unless a specific door image is set for a single door.","optional":true,"widget":"showWhen","showWhen":{"rules":[{"field":"../modeDoorImage","equals":"manual"}]}},{"name":"hideDoorBorder","type":"boolean","label":"Hide door border","default":false,"optional":true},{"name":"hideNumbers","type":"boolean","label":"Hide door numbers","default":false,"optional":true},{"name":"hideDoorKnobs","type":"boolean","label":"Hide door knobs","default":false,"optional":true},{"name":"hideDoorFrame","type":"boolean","label":"Hide door frame","default":false,"optional":true},{"name":"snow","type":"boolean","label":"Let it snow","description":"Will add some snow falling in front of the calendar. It never rains in Southern California, it never snows on IE11.","default":false,"optional":true}]},{"name":"audio","type":"group","label":"Audio settings","description":"These options will let you configure the audio appearance.","importance":"low","fields":[{"name":"backgroundMusic","type":"audio","label":"Background music","optional":true},{"name":"autoplay","type":"boolean","label":"Autoplay background music","description":"If set, the background music will play automatically once the content is opened. Please note: Some browsers\' media policy may prevent autoplay.","default":false,"optional":true}]},{"name":"behaviour","type":"group","label":"Behavioural settings","description":"These options will let you override behaviour settings.","importance":"low","fields":[{"name":"modeDoorPlacement","type":"select","label":"Mode for door placement","description":"Select whether you want to set a fixed number of columns and rows for the doors or if H5P should decide dynamically depending on the available space. Note that the latter may interfere with the position of the background image and custom door cover images that should be at a particular position.","options":[{"value":"fixed","label":"Fixed"},{"value":"dynamic","label":"Dynamic"}],"default":"dynamic"},{"name":"doorPlacementRatio","type":"select","label":"Row-to-column ratio","description":"Select how many columns and rows the calender should use.","options":[{"value":"6x4","label":"6 × 4"},{"value":"4x6","label":"4 × 6"}],"default":"6x4","widget":"showWhen","showWhen":{"rules":[{"field":"modeDoorPlacement","equals":"fixed"}]}},{"name":"randomize","type":"boolean","label":"Random order","description":"Shuffle the order of the doors. If the \\"save content state\\" option is set in the H5P settings, that order will stay the same when the user returns later.","default":false,"optional":true},{"name":"keepImageOrder","type":"boolean","label":"Keep order of images","description":"Shuffle doors, but keep the door cover images at their fixed positions starting with 1 in the upper left corner down to 24 in the lower right corner.","default":false,"optional":true,"widget":"showWhen","showWhen":{"rules":[{"field":"randomize","equals":true}]}},{"name":"designMode","type":"boolean","label":"Design mode","description":"When in design mode, all doors can be opened. Otherwise, the doors can only be opened in December on and after the respective day indicated by the door number.","default":true,"optional":true}]},{"name":"l10n","type":"group","common":true,"label":"Localization","importance":"low","fields":[{"name":"nothingToSee","type":"text","label":"Nothing to see","importance":"low","default":"There is nothing to see here!🎄"},{"name":"dummy","type":"text","label":"Dummy","importance":"low","default":"Dummy","widget":"none"}]},{"name":"a11y","type":"group","common":true,"label":"Accessibility","importance":"low","fields":[{"name":"door","type":"text","label":"Door","importance":"low","default":"Door"},{"name":"locked","type":"text","label":"Locked","importance":"low","default":"Locked. It is not time to open this one yet."},{"name":"content","description":"Announce the content. @door is a variable and will be replaced with the related door description.","type":"text","label":"Content of","importance":"low","default":"Content of @door"},{"name":"mute","type":"text","label":"Mute audio","importance":"low","default":"Mute audio"},{"name":"unmute","type":"text","label":"Unmute audio","importance":"low","default":"Unmute audio"},{"name":"closeWindow","type":"text","label":"Close window","importance":"low","default":"Close window"}]}]');let t=function(){function e(){}return e.extend=function(){for(let e=1;e<arguments.length;e++)for(let t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&("object"==typeof arguments[0][t]&&"object"==typeof arguments[e][t]?this.extend(arguments[0][t],arguments[e][t]):arguments[0][t]=arguments[e][t]);return arguments[0]},e.htmlDecode=function(e){return(new DOMParser).parseFromString(e,"text/html").documentElement.textContent},e.shuffleArray=function(e){let t,a,o;for(o=e.length-1;o>0;o--)t=Math.floor(Math.random()*(o+1)),a=e[o],e[o]=e[t],e[t]=a},e.findSemanticsField=function(t,a){if(Array.isArray(a)){for(let o=0;o<a.length;o++){const n=e.findSemanticsField(t,a[o]);if(null!==n)return n}return null}return a.name===t?a:a.field?e.findSemanticsField(t,a.field):a.fields?e.findSemanticsField(t,a.fields):null},e}();var a=t;let o=function(){function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.params=t,this.callbacks=a.extend({onOpened:()=>{},onLoaded:()=>{}},o),this.opened=!1,this.toLoad=["door","previewImage"],this.container=document.createElement("div"),this.container.classList.add("h5p-advent-calendar-square-content"),this.container.classList.add(`h5p-advent-calendar-color-scheme-${e.colorSchemeNames[t.day%e.colorSchemeNames.length]}`),t.hideDoorBorder&&this.container.classList.add("h5p-advent-calendar-hide-door-border"),t.hideDoorFrame&&this.container.classList.add("h5p-advent-calendar-hide-door-frame"),this.container.setAttribute("role","button"),this.container.setAttribute("aria-label",t.day),this.container.setAttribute("tabIndex",0);let n=`${this.params.a11y.door} ${this.params.day}.`;this.canBeOpened()||(n+=this.params.a11y.locked),this.container.setAttribute("aria-label",n),this.canBeOpened()||this.container.classList.add("h5p-advent-calendar-disabled"),this.container.addEventListener("click",(e=>{this.handleClick(e)})),this.container.addEventListener("keypress",(e=>{this.handleKeypress(e)}));const i=document.createElement("div");i.classList.add("h5p-advent-calendar-door-container"),this.container.appendChild(i);const s=document.createElement("div");s.classList.add("h5p-advent-calendar-doorway"),s.classList.add("h5p-advent-calendar-left"),i.appendChild(s);const r=document.createElement("div");if(r.classList.add("h5p-advent-calendar-doorway"),r.classList.add("h5p-advent-calendar-right"),i.appendChild(r),this.doorLeft=document.createElement("div"),this.doorLeft.classList.add("h5p-advent-calendar-door"),this.doorLeft.classList.add("h5p-advent-calendar-left"),s.appendChild(this.doorLeft),!t.hideNumbers){const e=document.createElement("div");e.classList.add("h5p-advent-calendar-door-number"),e.innerText=t.day,this.doorLeft.appendChild(e)}if(!t.hideDoorKnobs){const e=document.createElement("div");e.classList.add("h5p-advent-calendar-doorknob"),this.doorLeft.appendChild(e)}if(this.doorRight=document.createElement("div"),this.doorRight.classList.add("h5p-advent-calendar-door"),this.doorRight.classList.add("h5p-advent-calendar-right"),r.appendChild(this.doorRight),!t.hideDoorKnobs){const e=document.createElement("div");e.classList.add("h5p-advent-calendar-doorknob"),this.doorRight.appendChild(e)}if(this.params.content.doorCover&&this.params.content.doorCover.path){const e=H5P.getPath(this.params.content.doorCover.path,this.params.contentId);if(e){let t=document.createElement("img");t.src=e,t.addEventListener("load",(()=>{this.doorLeft.style.backgroundImage=`url("${e}")`,this.doorRight.style.backgroundImage=`url("${e}")`,t=null,this.handleLoaded("door")})),this.container.classList.add("h5p-advent-calendar-cover-image")}}else this.toLoad=this.toLoad.filter((e=>"door"!==e));if(this.previewImage=document.createElement("button"),this.previewImage.setAttribute("aria-label",this.params.a11y.content.replace("@door",`${this.params.a11y.door} ${this.params.day}.`)),this.previewImage.setAttribute("tabIndex",-1),this.previewImage.classList.add("h5p-advent-calendar-preview-image"),this.previewImage.classList.add(`h5p-advent-calendar-${t.content.type}-symbol`),this.container.appendChild(this.previewImage),this.params.content.previewImage&&this.params.content.previewImage.path){const e=H5P.getPath(this.params.content.previewImage.path,this.params.contentId);if(e){let t=document.createElement("img");t.src=e,t.addEventListener("load",(()=>{this.previewImage.style.backgroundImage=`url("${e}")`,t=null,this.handleLoaded("previewImage")}))}}else this.toLoad=this.toLoad.filter((e=>"previewImage"!==e)),this.previewImage.innerText=t.day;0===this.toLoad.length&&this.callbacks.onLoaded(),this.previewImage.addEventListener("click",(()=>{this.open({delay:0})})),t.open&&this.open({skipCallback:!0})}var t=e.prototype;return t.getDOM=function(){return this.container},t.setDoorCover=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=a.extend({styles:{},offset:{left:0,top:0}},e),e.image=e.image||{src:""},this.container.classList.toggle("h5p-advent-calendar-cover-image",""!==e.image.src),this.doorLeft.style.backgroundImage=`url("${e.image.src}")`,this.doorRight.style.backgroundImage=`url("${e.image.src}")`;const t=this.doorLeft.getBoundingClientRect();this.doorLeft.style.backgroundPosition=`left ${e.offset.left-t.left}px top ${e.offset.top-t.top}px`;const o=this.doorRight.getBoundingClientRect(),n=getComputedStyle(this.doorRight),i=parseFloat(n.getPropertyValue("border-left").split(" ")[0]);this.doorRight.style.backgroundPosition=`left ${e.offset.left-o.left-i}px top ${e.offset.top-o.top}px`;for(let t in e.styles)this.doorLeft.style[t]=e.styles[t],this.doorRight.style[t]=e.styles[t]},t.handleKeypress=function(e){13!==e.keyCode&&32!==e.keyCode||this.handleClick(e)},t.handleClick=function(e){this.canBeOpened()&&!this.isOpen()&&(e.preventDefault(),this.open(),this.container.removeEventListener("click",(e=>{this.handleClick(e)})),this.container.removeEventListener("keypress",(e=>{this.handleKeypress(e)})))},t.handleLoaded=function(e){this.toLoad=this.toLoad.filter((t=>t!==e)),0===this.toLoad.length&&this.callbacks.onLoaded()},t.focus=function(){this.isOpen()?this.previewImage.focus():this.container.focus()},t.open=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.opened=!0,this.container.classList.add("h5p-advent-calendar-open"),this.container.setAttribute("tabIndex",-1),this.container.removeAttribute("role"),this.previewImage.setAttribute("tabIndex",0),e.skipCallback||this.callbacks.onOpened(this.params.day,e.delay)},t.lock=function(){this.locked=!0,this.container.classList.add("h5p-advent-calendar-disabled")},t.unlock=function(){this.container.classList.remove("h5p-advent-calendar-disabled"),this.locked=!1},t.isOpen=function(){return this.opened},t.canBeOpened=function(){if(this.locked)return!1;if(this.params.designMode)return!0;const e=new Date;return 11===e.getMonth()&&e.getDate()>=this.params.day},e}();o.colorSchemeNames=["red","white","lightgreen","darkgreen"];let n=function(){function e(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.params=a.extend({container:document.body,content:document.createElement("div"),styleBase:"h5p-advent-calendar-overlay",position:{offsetHorizontal:0,offsetVertical:0},a11y:{closeWindow:"Close"}},e),this.callbacks=a.extend({onClose:()=>{}},t),this.isVisible=!1,this.focusableElements=[],this.overlay=document.createElement("div"),this.overlay.classList.add(`${this.params.styleBase}-outer-wrapper`),this.overlay.classList.add("h5p-advent-calendar-invisible"),this.overlay.setAttribute("role","dialog"),this.params.a11y.title&&this.overlay.setAttribute("aria-label",this.params.a11y.title),this.overlay.setAttribute("aria-modal","true"),this.content=document.createElement("div"),this.content.classList.add(`${this.params.styleBase}-content`),this.content.appendChild(this.params.content),this.overlay.appendChild(this.content),this.buttonClose=document.createElement("button"),this.buttonClose.classList.add(`${this.params.styleBase}-button-close`),this.buttonClose.setAttribute("aria-label",this.params.a11y.closeWindow),this.buttonClose.addEventListener("click",(()=>{this.callbacks.onClose()})),this.overlay.appendChild(this.buttonClose),document.addEventListener("focus",(e=>{this.isVisible&&0!==this.focusableElements.length&&this.trapFocus(e)}),!0),this.blocker=document.createElement("div"),this.blocker.classList.add("h5p-advent-calendar-overlay-blocker"),this.blocker.classList.add("h5p-advent-calendar-display-none"),this.blocker.addEventListener("click",(()=>{this.callbacks.onClose()})),this.modifierClasses=[]}var t=e.prototype;return t.getDOM=function(){return this.overlay},t.setContent=function(e){for(;this.content.firstChild;)this.content.removeChild(this.content.firstChild);this.content.appendChild(e)},t.setModifierClass=function(e){(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&(this.modifierClasses.forEach((e=>{this.overlay.classList.remove(e)})),this.modifierClasses=[]),-1===this.modifierClasses.indexOf(e)&&this.modifierClasses.push(e),this.overlay.classList.add(e)},t.trapFocus=function(e){this.isChild(e.target)?this.currentFocusElement=e.target:(this.currentFocusElement===this.focusableElements[0]?this.currentFocusElement=this.focusableElements[this.focusableElements.length-1]:this.currentFocusElement=this.focusableElements[0],this.currentFocusElement.focus())},t.isChild=function(e){const t=e.parentNode;return!!t&&(t===this.overlay||this.isChild(t))},t.updateFocusableElements=function(){this.focusableElements=[].slice.call(this.overlay.querySelectorAll('video, audio, button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter((e=>"true"!==e.getAttribute("disabled")&&!0!==e.getAttribute("disabled")))},t.show=function(){this.blockerAppended||(this.container=document.body.querySelector(".h5p-container"),this.container.appendChild(this.blocker)),this.blockerAppended=!0,this.overlay.classList.remove("h5p-advent-calendar-invisible"),this.blocker.classList.remove("h5p-advent-calendar-display-none"),setTimeout((()=>{this.updateFocusableElements(),this.focusableElements.length>0&&this.focusableElements[0].focus(),this.isVisible=!0}),0)},t.hide=function(){this.isVisible=!1,this.overlay.classList.add("h5p-advent-calendar-invisible"),this.blocker.classList.add("h5p-advent-calendar-display-none")},e}();var i=function(){function e(e){this.classNameBase=e,this.container=document.createElement("div"),this.container.classList.add(`${this.classNameBase}-container`),this.spinnerElement=document.createElement("div"),this.spinnerElement.classList.add(e);const t=document.createElement("div");t.classList.add(`${this.classNameBase}-circle-head`),this.spinnerElement.appendChild(t);const a=document.createElement("div");a.classList.add(`${this.classNameBase}-circle-neck-upper`),this.spinnerElement.appendChild(a);const o=document.createElement("div");o.classList.add(`${this.classNameBase}-circle-neck-lower`),this.spinnerElement.appendChild(o);const n=document.createElement("div");n.classList.add(`${this.classNameBase}-circle-body`),this.spinnerElement.appendChild(n),this.container.appendChild(this.spinnerElement)}var t=e.prototype;return t.getDOM=function(){return this.container},t.show=function(){this.container.classList.remove(`${this.classNameBase}-none`)},t.hide=function(){this.container.classList.add(`${this.classNameBase}-none`)},e}();function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}let r=function(t){var r,d;function l(){var s;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},d=arguments.length>1?arguments[1]:void 0,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};(s=t.call(this)||this).params=a.extend({modeDoorImage:"automatic",visuals:{hideDoorBorder:!1,hideNumbers:!1,hideDoorKnobs:!1,hideDoorFrame:!1,snow:!1},audio:{autoplay:!1},behaviour:{modeDoorPlacement:"fixed",doorPlacementRatio:"6x4",randomize:!1,keepImageOrder:!1},l10n:{nothingToSee:"There is nothing to see here!🎄"},a11y:{door:"Door",locked:"Locked. It is not time to open this one yet.",content:"Content of @door",closeWindow:"Close window",mute:"Mute audio",unmute:"Unmute audio"}},r),s.doorsLoaded=0,s.continueBackgroundMusic=null;for(let e in s.params.l10n)s.params.l10n[e]=a.htmlDecode(s.params.l10n[e]);for(let e in s.params.a11y)s.params.a11y[e]=a.htmlDecode(s.params.a11y[e]);const c=a.findSemanticsField("text",e),h=c?.options[0]||"H5P.AdvancedText 1.1";for(;s.params.doors.length<24;)s.params.doors.push({text:{library:h,params:{text:s.params.l10n.nothingToSee},subContentId:H5P.createUUID()},type:"text"});const u=r.visuals.doorImageTemplate?.path?r.visuals.doorImageTemplate:null;if(r.visuals?.backgroundImage?.path){const e=H5P.getPath(r.visuals.backgroundImage.path,d);e&&(s.backgroundImage=document.createElement("img"),s.backgroundImage.addEventListener("load",(()=>{s.trigger("resize")})),s.backgroundImage.src=e)}s.columns=[],s.doors=s.params.doors.map(((e,t)=>(u&&!e.doorCover&&(e.doorCover=u),e.type||(e.type="text",e.text.params.text=s.params.l10n.nothingToSee),{day:t+1,content:e}))),l.previousState&&Array.isArray(l.previousState)?s.doors=l.previousState.map((e=>{const t=s.doors[e.day-1];return t.open=e.open,t})):r.behaviour.randomize&&a.shuffleArray(s.doors);const p=s.doors.map((e=>({day:e.day,doorCover:e.content.doorCover})));r.behaviour.keepImageOrder&&s.doors.forEach(((e,t)=>{e.content.doorCover=p.filter((e=>e.day===t+1))[0].doorCover})),s.instances=Array(25),s.muted=!s.params.audio.autoplay,s.container=document.createElement("div"),s.container.classList.add("h5p-advent-calendar-container"),s.spinner=new i("h5p-advent-calendar-spinner"),s.container.appendChild(s.spinner.getDOM()),s.table=document.createElement("div"),s.table.classList.add("h5p-advent-calendar-table"),s.table.classList.add("h5p-advent-calendar-display-none"),s.backgroundImage&&(s.table.style.backgroundImage=`url('${s.backgroundImage.src}')`),s.container.appendChild(s.table),s.doors.forEach((e=>{const t=document.createElement("div");t.classList.add("h5p-advent-calendar-square"),e.door=new o({contentId:d,day:e.day,content:e.content,open:e.open,hideDoorBorder:r.visuals.hideDoorBorder,hideNumbers:r.visuals.hideNumbers,hideDoorKnobs:r.visuals.hideDoorKnobs,hideDoorFrame:r.visuals.hideDoorFrame,designMode:r.behaviour.designMode,a11y:{door:s.params.a11y.door,locked:s.params.a11y.locked,content:s.params.a11y.content}},{onOpened:(e,t)=>{s.handleOverlayOpened(e,t)},onLoaded:()=>{s.handleDoorLoaded()}}),t.appendChild(e.door.getDOM()),s.columns.push(t),s.table.appendChild(t)})),r.audio.backgroundMusic&&(s.backgroundMusic=s.createAudio(r.audio.backgroundMusic,d),s.buttonAudio=document.createElement("button"),s.buttonAudio.classList.add("h5p-advent-calendar-audio-button"),s.muted?(s.buttonAudio.classList.add("muted"),s.buttonAudio.setAttribute("aria-label",s.params.a11y.unmute)):(s.buttonAudio.classList.add("unmuted"),s.buttonAudio.setAttribute("aria-label",s.params.a11y.mute)),s.buttonAudio.addEventListener("click",(()=>{s.toggleButtonAudio()?(s.buttonAudio.setAttribute("aria-label",s.params.a11y.unmute),s.stopAudio()):(s.buttonAudio.setAttribute("aria-label",s.params.a11y.mute),s.playAudio())})),s.container.appendChild(s.buttonAudio),r.audio.autoplay&&s.playAudio());const m=new Date;if(r.visuals.snow||11===m.getMonth()&&m.getDate()>=24){const e=document.createElement("div");e.classList.add("h5p-advent-calendar-sky"),s.container.appendChild(e);const t=document.createElement("div");t.classList.add("h5p-advent-calendar-snow"),e.appendChild(t);for(let e=0;e<30;e++){const e=document.createElement("span");t.appendChild(e)}}return s.overlay=new n({a11y:{closeWindow:s.params.a11y.closeWindow}},{onClose:()=>{s.handleOverlayClosed()}}),s.container.appendChild(s.overlay.getDOM()),s.on("resize",(()=>{s.resize()})),s}d=t,(r=l).prototype=Object.create(d.prototype),r.prototype.constructor=r,s(r,d);var c=l.prototype;return c.attach=function(e){e.get(0).classList.add("h5p-advent-calendar"),e.get(0).appendChild(this.container),this.trigger("resize")},c.determineRowColumnRatio=function(){const e=this.container.getBoundingClientRect().width,t=Math.floor(e/l.COLUMN_WIDTH_MIN);return t>=6?"6x4":t>=4?"4x6":t>=3?"3x8":t>=2?"2x12":"6x4"},c.setRowColumnRatio=function(e){e&&["",...l.ROW_COLUMN_RATIOS].includes(e)&&this.columns.forEach((t=>{l.ROW_COLUMN_RATIOS.forEach((e=>{t.classList.remove(`h5p-advent-calendar-row-column-ratio-${e}`)})),""!==e&&t.classList.add(`h5p-advent-calendar-row-column-ratio-${e}`)}))},c.updateDoorCovers=function(){if("automatic"!==this.params.modeDoorImage||!this.backgroundImage||0===this.backgroundImage.naturalWidth||0===this.backgroundImage.naturalHeight)return;const e=this.container.getBoundingClientRect();if(0===e.height)return;const t=e.width/e.height<this.backgroundImage.naturalWidth/this.backgroundImage.naturalHeight,a=t?this.backgroundImage.naturalWidth/this.backgroundImage.naturalHeight*e.height:e.width,o=t?e.height:this.backgroundImage.naturalHeight/this.backgroundImage.naturalWidth*e.width;this.doors.forEach((t=>{t.door.setDoorCover({image:this.backgroundImage,styles:{"background-size":`${a}px ${o}px`},offset:{left:e.left,top:e.top}})}))},c.resize=function(){if(this.table.style.fontSize=this.container.offsetWidth/48+"px",this.currentDayOpened&&(this.instances[this.currentDayOpened]&&this.instances[this.currentDayOpened].instance.trigger("resize"),this.h5pContainer=this.h5pContainer||document.body.querySelector(".h5p-container"),this.h5pContainer&&this.instances[this.currentDayOpened])){const e=parseInt(window.getComputedStyle(this.instances[this.currentDayOpened].wrapper).fontSize)||16;this.instances[this.currentDayOpened].wrapper.style.maxHeight=`calc(${this.h5pContainer.offsetHeight-7*e}px)`;const t=this.instances[this.currentDayOpened]?.instance;"H5P.Image"===t?.libraryInfo?.machineName&&t.$img?.get(0)&&(this.instances[this.currentDayOpened].wrapper.style.maxWidth=(this.h5pContainer.offsetHeight-7*e)/t.$img?.get(0).offsetHeight*t.$img?.get(0).offsetWidth+"px")}const e="fixed"===this.params.behaviour.modeDoorPlacement?this.params.behaviour.doorPlacementRatio:this.determineRowColumnRatio();this.setRowColumnRatio(e),clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout((()=>{this.updateDoorCovers()}),0)},c.getAnswerGiven=function(){return this.doors.some((e=>e.door.isOpen()))},c.getCurrentState=function(){if(this.getAnswerGiven())return this.doors.map((e=>({day:e.day,open:e.door.isOpen()})))},c.handleOverlayOpened=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;this.doors.forEach((e=>e.door.lock())),this.currentDayOpened=e;const a=this.doors.filter((t=>t.day===e))[0];if(this.overlay.setModifierClass(`h5p-advent-calendar-content-type-${a.content.type}`),!this.instances[e]){const t=document.createElement("div");if(t.classList.add("h5p-advent-calendar-instance-wrapper"),!a.content[a.content.type])return this.doors.forEach((e=>e.door.unlock())),void a.door.focus();let o;if("audio"===a.content.type)o=new H5P.Audio({files:a.content.audio,playerMode:"full",fitToWrapper:!1,controls:!0,autoplay:a.content.autoplay||!1},this.contentId),o.attach(H5P.jQuery(t)),o.audio.style.width="100%",this.backgroundMusic&&(o.audio.addEventListener("play",(()=>{this.handleOverlayMedia("play")})),o.audio.addEventListener("pause",(()=>{this.handleOverlayMedia("stop")})),o.audio.addEventListener("ended",(()=>{this.handleOverlayMedia("stop")})));else if("video"===a.content.type){const e=!(a.content.video.length>0&&"video/YouTube"===a.content.video[0].mime);o=new H5P.Video({sources:a.content.video,visuals:{fit:e,controls:!0},playback:{autoplay:a.content.autoplay||!1,loop:!1}},this.contentId),o.attach(H5P.jQuery(t)),this.backgroundMusic&&o.on("stateChange",(e=>{e.data===H5P.Video.PLAYING?this.handleOverlayMedia("play"):e.data!==H5P.Video.PAUSED&&e.data!==H5P.Video.ENDED||this.handleOverlayMedia("stop")}))}else o=H5P.newRunnable(a.content[a.content.type],this.contentId,H5P.jQuery(t));"image"===a.content.type&&o.on("loaded",(()=>{this.trigger("resize")})),this.instances[e]={instance:o,wrapper:t}}this.popupWaiting&&clearTimeout(this.popupWaiting),this.popupWaiting=setTimeout((()=>{if("link"===a.content.type){const t=this.instances[e].wrapper.querySelector(".h5p-link a").getAttribute("href");window.open(t,"_blank")}else this.resize(),this.overlay.setContent(this.instances[e].wrapper),this.overlay.show(),this.instances[e].instance.trigger("resize"),a.content.type&&a.content.autoplay&&this.instances[e].instance.audio&&this.instances[e].instance.audio.paused&&this.instances[e].instance.play();this.doors.forEach((e=>e.door.unlock()))}),t)},c.handleOverlayClosed=function(){this.overlay.hide();const e=this.instances[this.currentDayOpened].instance;"function"==typeof e.pause&&e.pause(),this.doors.filter((e=>e.day===this.currentDayOpened))[0].door.focus()},c.handleOverlayMedia=function(e){this.backgroundMusic&&this.backgroundMusic.player&&("play"===e?(this.continueBackgroundMusic=!this.backgroundMusic.player.paused,this.continueBackgroundMusic&&this.stopAudio()):"stop"===e&&this.continueBackgroundMusic&&this.playAudio())},c.handleDoorLoaded=function(){this.doorsLoaded++,24===this.doorsLoaded&&(this.spinner.hide(),this.table.classList.remove("h5p-advent-calendar-display-none"),this.trigger("resize"))},c.createAudio=function(e,t){if(!e||e.length<1||!e[0].path)return null;const a=document.createElement("audio");return a.src=H5P.getPath(e[0].path,t),a.addEventListener("ended",(()=>{this.playAudio()})),{player:a,promise:null}},c.toggleButtonAudio=function(e){if(this.buttonAudio)return this.muted="boolean"==typeof e?e:!this.muted,this.muted?(this.buttonAudio.classList.remove("unmuted"),this.buttonAudio.classList.add("muted"),this.buttonAudio.setAttribute("aria-label",this.params.a11y.unmute)):(this.buttonAudio.classList.add("unmuted"),this.buttonAudio.classList.remove("muted"),this.buttonAudio.setAttribute("aria-label",this.params.a11y.mute)),this.muted},c.playAudio=function(){this.backgroundMusic&&(this.backgroundMusic.promise||(this.backgroundMusic.promise=this.backgroundMusic.player.play(),this.backgroundMusic.promise&&this.backgroundMusic.promise.then((()=>{this.backgroundMusic.promise=null,this.toggleButtonAudio(!1)})).catch((()=>{this.backgroundMusic.promise=null,this.toggleButtonAudio(!0)}))))},c.stopAudio=function(){this.backgroundMusic.promise?this.backgroundMusic.promise.then((()=>{this.backgroundMusic.player.pause(),this.backgroundMusic.promise=null,this.toggleButtonAudio(!0)})):(this.backgroundMusic.player.pause(),this.toggleButtonAudio(!0))},l}(H5P.EventDispatcher);r.ROW_COLUMN_RATIOS=["6x4","4x6","3x8","2x12"],r.COLUMN_WIDTH_MIN=120,H5P.AdventCalendar=r}();
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists