diff --git a/public/presentationmaker.js b/public/presentationmaker.js new file mode 100644 index 0000000..24f460f --- /dev/null +++ b/public/presentationmaker.js @@ -0,0 +1 @@ +(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{PresentationMaker:()=>P});var i=Object.defineProperty,s=(t,e,s)=>(((t,e,s)=>{e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(t,"symbol"!=typeof e?e+"":e,s),s);const r={PI:Math.PI,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2};class n{static createOperatorExpression(t,e,i){if("^"===t)return new c(e,i);if("*"===t||"/"===t)return new l(t,e,i);if("+"===t||"-"===t)return new h(t,e,i);throw new Error(`Unknown operator: ${t}`)}evaluate(t={}){throw new Error("Empty Expression - Must be defined in child classes")}toString(){return""}}class o extends n{constructor(t){if(super(),s(this,"innerExpression"),this.innerExpression=t,!(this.innerExpression instanceof n))throw new Error("No inner expression given for bracket expression")}evaluate(t={}){return this.innerExpression.evaluate(t)}toString(){return`(${this.innerExpression.toString()})`}}class a extends n{constructor(t){if(super(),s(this,"value"),this.value=Number(t),isNaN(this.value))throw new Error("Cannot parse number: "+t)}evaluate(){return this.value}toString(){return String(this.value)}}class h extends n{constructor(t,e,i){if(super(),s(this,"operator"),s(this,"left"),s(this,"right"),!["+","-"].includes(t))throw new Error(`Operator not allowed in Plus/Minus expression: ${t}`);this.operator=t,this.left=e,this.right=i}evaluate(t={}){if("+"===this.operator)return this.left.evaluate(t)+this.right.evaluate(t);if("-"===this.operator)return this.left.evaluate(t)-this.right.evaluate(t);throw new Error("Unknown operator for PlusMinus expression")}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}class l extends n{constructor(t,e,i){if(super(),s(this,"operator"),s(this,"left"),s(this,"right"),!["*","/"].includes(t))throw new Error(`Operator not allowed in Multiply/Division expression: ${t}`);this.operator=t,this.left=e,this.right=i}evaluate(t={}){if("*"===this.operator)return this.left.evaluate(t)*this.right.evaluate(t);if("/"===this.operator)return this.left.evaluate(t)/this.right.evaluate(t);throw new Error("Unknown operator for MultDiv expression")}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}class c extends n{constructor(t,e){super(),s(this,"base"),s(this,"exponent"),this.base=t,this.exponent=e}evaluate(t={}){return Math.pow(this.base.evaluate(t),this.exponent.evaluate(t))}toString(){return`${this.base.toString()}^${this.exponent.toString()}`}}class u extends n{constructor(t,e,i=null){super(),s(this,"fn"),s(this,"varPath"),s(this,"argumentExpressions"),s(this,"formulaObject"),s(this,"blacklisted"),this.fn=null!=t?t:"",this.varPath=this.fn.split("."),this.argumentExpressions=e||[],this.formulaObject=i,this.blacklisted=void 0}evaluate(t={}){var e;t=t||{};const i=this.argumentExpressions.map((e=>e.evaluate(t)));try{let e=p(t,this.varPath,this.fn);if(e instanceof Function)return e.apply(this,i)}catch(t){}let s;try{s=p(null!=(e=this.formulaObject)?e:{},this.varPath,this.fn)}catch(t){}if(this.formulaObject&&s instanceof Function){if(this.isBlacklisted())throw new Error("Blacklisted function called: "+this.fn);return s.apply(this.formulaObject,i)}try{const t=p(Math,this.varPath,this.fn);if(t instanceof Function)return t.apply(this,i)}catch(t){}throw new Error("Function not found: "+this.fn)}toString(){return`${this.fn}(${this.argumentExpressions.map((t=>t.toString())).join(", ")})`}isBlacklisted(){return void 0===this.blacklisted&&(this.blacklisted=m.functionBlacklist.includes(this.formulaObject?this.formulaObject[this.fn]:null)),this.blacklisted}}function p(t,e,i){let s=t;for(let t of e){if("object"!=typeof s)throw new Error(`Cannot evaluate ${t}, property not found (from path ${i})`);if(void 0===s[t])throw new Error(`Cannot evaluate ${t}, property not found (from path ${i})`);s=s[t]}if("object"==typeof s)throw new Error("Invalid value");return s}class g extends n{constructor(t,e=null){super(),s(this,"fullPath"),s(this,"varPath"),s(this,"formulaObject"),this.formulaObject=e,this.fullPath=t,this.varPath=t.split(".")}evaluate(t={}){var e;let i;try{i=p(t,this.varPath,this.fullPath)}catch(t){}if(void 0===i&&(i=p(null!=(e=this.formulaObject)?e:{},this.varPath,this.fullPath)),"function"==typeof i||"object"==typeof i)throw new Error(`Cannot use ${this.fullPath} as value: It contains a non-numerical value.`);return Number(i)}toString(){return`${this.varPath.join(".")}`}}const f=class t{constructor(t,e={}){s(this,"formulaExpression"),s(this,"options"),s(this,"formulaStr"),s(this,"_variables"),s(this,"_memory"),this.formulaExpression=null,this.options={memoization:!1,...e},this.formulaStr="",this._variables=[],this._memory={},this.setFormula(t)}setFormula(t){return t&&(this.formulaExpression=null,this._variables=[],this._memory={},this.formulaStr=t,this.formulaExpression=this.parse(t)),this}enableMemoization(){this.options.memoization=!0}disableMemoization(){this.options.memoization=!1,this._memory={}}splitFunctionParams(t){let e=0,i="";const s=[];for(let r of t.split(""))if(","===r&&0===e)s.push(i),i="";else if("("===r)e++,i+=r;else if(")"===r){if(e--,i+=r,e<0)throw new Error("ERROR: Too many closing parentheses!")}else i+=r;if(0!==e)throw new Error("ERROR: Too many opening parentheses!");return i.length>0&&s.push(i),s}cleanupInputString(t){return t=t.replace(/\s+/g,""),Object.keys(r).forEach((e=>{t=t.replace(new RegExp(`\\b${e}\\b`,"g"),`[${e}]`)})),t}parse(t){return t=this.cleanupInputString(t),this._do_parse(t)}_do_parse(t){let e=t.length-1,i=0,s="initial",r=[],h="",l="",c=null,p=0;for(;i<=e;){switch(s){case"initial":if(h=t.charAt(i),h.match(/[0-9.]/))s="within-nr",l="",i--;else if(this.isOperator(h)){if("-"===h&&(0===r.length||this.isOperatorExpr(r[r.length-1]))){s="within-nr",l="-";break}if(i===e||this.isOperatorExpr(r[r.length-1])){s="invalid";break}r.push(n.createOperatorExpression(h,new n,new n)),s="initial"}else"("===h?(s="within-parentheses",l="",p=0):"["===h?(s="within-named-var",l=""):h.match(/[a-zA-Z]/)&&(i0&&r[r.length-1]instanceof a&&r.push(n.createOperatorExpression("*",new n,new n)),r.push(new g(h,this)),this.registerVariable(h),s="initial",l=""));break;case"within-nr":h=t.charAt(i),h.match(/[0-9.]/)?(l+=h,i===e&&(r.push(new a(l)),s="initial")):("-"===l&&(l="-1"),r.push(new a(l)),l="",s="initial",i--);break;case"within-func":if(h=t.charAt(i),h.match(/[a-zA-Z0-9_.]/))l+=h;else{if("("!==h)throw new Error("Wrong character for function at position "+i);c=l,l="",p=0,s="within-func-parentheses"}break;case"within-named-var":if(h=t.charAt(i),"]"===h)r.push(new g(l,this)),this.registerVariable(l),l="",s="initial";else{if(!h.match(/[a-zA-Z0-9_.]/))throw new Error("Character not allowed within named variable: "+h);l+=h}break;case"within-parentheses":case"within-func-parentheses":if(h=t.charAt(i),")"===h)if(p<=0){if("within-parentheses"===s)r.push(new o(this._do_parse(l)));else if("within-func-parentheses"===s){let t=this.splitFunctionParams(l).map((t=>this._do_parse(t)));r.push(new u(c,t,this)),c=null}s="initial"}else p--,l+=h;else"("===h&&p++,l+=h}i++}if("initial"!==s)throw new Error("Could not parse formula: Syntax error.");return this.buildExpressionTree(r)}buildExpressionTree(t){if(t.length<1)throw new Error("No expression given!");const e=[...t];let i=0,s=null;for(;ithis.evaluate(t)));let e=this.getExpression();if(!(e instanceof n))throw new Error("No expression set: Did you init the object with a Formula?");if(this.options.memoization){let i=this.resultFromMemory(t);return null!==i||(i=e.evaluate({...r,...t}),this.storeInMemory(t,i)),i}return e.evaluate({...r,...t})}hashValues(t){return JSON.stringify(t)}resultFromMemory(t){let e=this.hashValues(t),i=this._memory[e];return void 0!==i?i:null}storeInMemory(t,e){this._memory[this.hashValues(t)]=e}getExpression(){return this.formulaExpression}getExpressionString(){return this.formulaExpression?this.formulaExpression.toString():""}static calc(e,i=null,s={}){return i=null!=i?i:{},new t(e,s).evaluate(i)}};s(f,"Expression",n),s(f,"BracketExpression",o),s(f,"PowerExpression",c),s(f,"MultDivExpression",l),s(f,"PlusMinusExpression",h),s(f,"ValueExpression",a),s(f,"VariableExpression",g),s(f,"FunctionExpression",u),s(f,"MATH_CONSTANTS",r),s(f,"functionBlacklist",Object.getOwnPropertyNames(f.prototype).filter((t=>f.prototype[t]instanceof Function)).map((t=>f.prototype[t])));let m=f;class d{calc(t){if(""===t)return 0;try{return new m(t).evaluate({})}catch(t){}return 0}constructor(t){this.root=t}static getField(t,e){let i=t.getAttribute(e);return t.childNodes.forEach((t=>{if(1===t.nodeType){const s=t;s.localName===e&&(i=s.innerHTML)}})),i}resolveString(t){if(!t||t.indexOf("$")<0)return t;let e,i=t,s=0;for(;(e=i.indexOf("${",s))>=0;){if("\\"==i.at(e-1)){i=i.substring(0,e-1)+i.substring(e),s=e+1;continue}const t=i.indexOf("}",e);if(t<0)break;const r=i.substring(e+2,t),n=this.root.getDefinition(r);i=i.replace(i.substring(e,t+1),n)}return i}}class v extends d{clone(){const t=new E(this.root.getMain(),this.tree);return new v(this.root,t)}constructor(t,e){super(t),this.tree=e}render(t){this.tree.render(t)}}class w extends d{clone(){return new w(this.root,this.src,this.x,this.y,this.width,this.height,this.maskImage)}constructor(t,e,i,s,r,n,o){super(t),this.src=e,this.x=i,this.y=s,this.width=r,this.height=n,this.maskImage=o}static fromElem(t,e){return new w(t,this.getField(e,"src"),this.getField(e,"x"),this.getField(e,"y"),this.getField(e,"width"),this.getField(e,"height"),this.getField(e,"mask-image"))}render(t){const e=document.createElement("img");e.style.position="absolute",e.style.top=this.calc(this.resolveString(this.y))+"px",e.style.left=this.calc(this.resolveString(this.x))+"px",e.setAttribute("width",this.calc(this.resolveString(this.width)).toString()),e.setAttribute("height",this.calc(this.resolveString(this.height)).toString()),e.setAttribute("src",this.resolveString(this.src)),this.maskImage&&(e.style.maskImage=this.maskImage),t.append(e)}}class y extends d{clone(){return new y(this.root,this.target,this.expression)}constructor(t,e,i){super(t),this.target=e,this.expression=i}static fromElem(t,e){return new y(t,e.getAttribute("name")||"",e.innerHTML)}render(t){const e=this.resolveString(this.expression),i=new m(e).evaluate({});this.root.set(this.target,i.toString())}}class b extends d{clone(){return new b(this.root,this.x0,this.y0,this.x1,this.y1,this.width,this.height,this.pos,this.halign,this.valign,this.fontSize,this.text,this.color)}static fromElem(t,e){return new b(t,e.getAttribute("x0"),e.getAttribute("y0"),e.getAttribute("x1"),e.getAttribute("y1"),e.getAttribute("w"),e.getAttribute("h"),e.getAttribute("pos"),e.getAttribute("halign")||"center",e.getAttribute("valign"),e.getAttribute("size"),e.innerHTML,e.getAttribute("color")||t.getDefinition("defaultfontcolor"))}constructor(t,e,i,s,r,n,o,a,h,l,c,u,p){super(t),this.x0=e,this.y0=i,this.x1=s,this.y1=r,this.width=n,this.height=o,this.pos=a,this.halign=h,this.valign=l,this.fontSize=c,this.text=u,this.color=p}render(t){let e,i,s,r;if(this.pos){const t=this.resolveString(this.pos).split(",");if(4!=t.length)return;e=this.calc(this.resolveString(t[0])),i=this.calc(this.resolveString(t[1])),s=this.calc(this.resolveString(t[2])),r=this.calc(this.resolveString(t[3]))}else e=this.calc(this.resolveString(this.x0)),i=this.calc(this.resolveString(this.y0)),this.x1?(s=this.calc(this.resolveString(this.x1)),r=this.calc(this.resolveString(this.y1))):(s=e+this.calc(this.resolveString(this.width)),r=i+this.calc(this.resolveString(this.height)));const n=this.resolveString(this.halign),o=this.resolveString(this.valign),a=this.resolveString(this.text),h=document.createElement("div");switch(this.color&&(h.style.color=this.resolveString(this.color)),h.style.position="absolute",this.fontSize&&(h.style.fontSize=this.calc(this.resolveString(this.fontSize))+"px"),h.style.left=e+"px",h.style.top=i+"px",h.style.width=s-e+"px",h.style.height=r-i+"px",h.style.overflow="clip",n){case"center":h.style.textAlign="center";break;case"right":h.style.textAlign="right"}switch(o){case"center":h.style.alignContent="center";break;case"bottom":h.style.alignContent="end"}h.insertAdjacentHTML("afterbegin",a),t.append(h)}}class x extends d{clone(){return new x(this.root,this.subtree,this.opacity,this.blendmode,this.flip,this.rotate,this.y)}constructor(t,e,i,s,r,n,o){super(t),this.subtree=e,this.opacity=i,this.blendmode=s,this.flip=r,this.rotate=n,this.y=o}static fromElem(t,e,i){const s=new E(t);return s.createFromElem(i),new x(e,s,this.getField(i,"opacity")||"",this.getField(i,"blend")||"",this.getField(i,"flip")||"",this.getField(i,"rotate")||"",this.getField(i,"y")||"")}render(t){const e=document.createElement("div");if(e.classList.add("option"),""!==this.opacity&&(e.style.opacity=this.opacity),""!==this.blendmode&&(e.style.mixBlendMode=this.blendmode),""!==this.flip&&"v"==this.flip&&(e.style.transform="scaleY(-1)"),this.y&&(e.style.position="absolute",e.style.bottom="0px"),""!==this.rotate){const t=this.rotate.split(",");let i="";t[0]&&(i+="rotateX("+this.calc(this.resolveString(t[0]))+"deg)"),t[1]&&(i+="rotateY("+this.calc(this.resolveString(t[1]))+"deg)"),t[2]&&(i+="rotateZ("+this.calc(this.resolveString(t[2]))+"deg)"),e.style.transform=i,e.style.transformOrigin="top left"}this.subtree.render(e),t.append(e)}}class S extends d{clone(){return new S(this.root,this.subtree,this.id,this.transformation.size.w,this.transformation.size.h,this.transformation.position.x,this.transformation.position.y,this.transformation.position.z,this.transformation.rotation.y,this.transformation.rotation.y,this.transformation.rotation.z,this.transformation.viewpos.x,this.transformation.viewpos.y,this.transformation.viewpos.z,this.transformation.viewSize.w,this.transformation.viewSize.h,this.transformation.viewRotation.x,this.transformation.viewRotation.y,this.transformation.viewRotation.z,this.name)}constructor(t,e,i,s,r,n,o,a,h,l,c,u,p,g,f,m,d,v,w,y){super(t),this.subtree=e,this.id=i,this.transformation={size:{w:s,h:r},position:{x:n,y:o,z:a},rotation:{x:h,y:l,z:c},viewpos:{x:u,y:p,z:g},viewSize:{w:f,h:m},viewRotation:{x:d,y:v,z:w}},this.name=y}static fromElem(t,e,i){const s=new E(t);return s.createFromElem(i),new S(e,s,i.getAttribute("id")||"",i.getAttribute("width")||"${width}",i.getAttribute("height")||"${height}",i.getAttribute("x")||"0",i.getAttribute("y")||"0",i.getAttribute("z")||"0",i.getAttribute("rx")||"0",i.getAttribute("ry")||"0",i.getAttribute("rz")||"0",i.getAttribute("vx")||"",i.getAttribute("vy")||"",i.getAttribute("vz")||"",i.getAttribute("vwidth")||"",i.getAttribute("vheight")||"",i.getAttribute("vrx")||"",i.getAttribute("vry")||"",i.getAttribute("vrz")||"",i.getAttribute("name")||"${page}")}getName(){return this.name}getView(){let t,e,i;return t=""!==this.transformation.viewpos.x||""!==this.transformation.viewpos.y||""!==this.transformation.viewpos.z?{x:this.calc(this.resolveString(this.transformation.viewpos.x)),y:this.calc(this.resolveString(this.transformation.viewpos.y)),z:this.calc(this.resolveString(this.transformation.viewpos.z))}:{x:this.calc(this.resolveString(this.transformation.position.x)),y:this.calc(this.resolveString(this.transformation.position.y)),z:this.calc(this.resolveString(this.transformation.position.z))},e=""!==this.transformation.viewSize.w||""!==this.transformation.viewSize.h?{w:this.calc(this.resolveString(this.transformation.viewSize.w)),h:this.calc(this.resolveString(this.transformation.viewSize.h))}:{w:this.calc(this.resolveString(this.transformation.size.w)),h:this.calc(this.resolveString(this.transformation.size.h))},i=""!==this.transformation.viewRotation.x||""!==this.transformation.viewRotation.y||""!==this.transformation.viewRotation.z?{x:this.calc(this.resolveString(this.transformation.viewRotation.x)),y:this.calc(this.resolveString(this.transformation.viewRotation.y)),z:this.calc(this.resolveString(this.transformation.viewRotation.z))}:{x:0,y:0,z:0},{position:t,size:e,viewRotation:i}}render(t){this.root.set("page",(parseInt(this.root.getDefinition("page"))+1).toString());const e=document.createElement("article");e.classList.add("page"),e.classList.add("inactive");let i="";const s=this.calc(this.resolveString(this.transformation.position.x)),r=this.calc(this.resolveString(this.transformation.position.y)),n=this.calc(this.resolveString(this.transformation.position.z));(s||r||n)&&(i+="translate3d("+s+"px, "+r+"px, "+n+"px)");const o=-this.calc(this.resolveString(this.transformation.rotation.x)),a=-this.calc(this.resolveString(this.transformation.rotation.y)),h=-this.calc(this.resolveString(this.transformation.rotation.z));o&&(i+="rotateX("+o+"deg)"),a&&(i+="rotateY("+a+"deg)"),h&&(i+="rotateZ("+h+"deg)"),""!==i&&(e.style.transform=i);const l=this.calc(this.resolveString(this.transformation.size.w)).toString(),c=this.calc(this.resolveString(this.transformation.size.h)).toString();e.style.width=l+"px",e.style.height=c+"px",this.id&&(e.id=this.id),t.append(e),this.root.push(),this.subtree.set("width",l),this.subtree.set("height",c),this.subtree.render(e),this.root.pop()}}class E{constructor(t,e=null){this.main=t,this.elements=[],this.definitions=new Map,null!==e&&e.elements.forEach((t=>{this.elements.push(t.clone())}))}createFromElem(t){t.childNodes.forEach((t=>{if(1===t.nodeType){const e=this.createNodeFromElem(t);null!==e&&this.elements.push(e)}}))}createNodeFromElem(t){const e=t.localName;switch(e){case"calc":return y.fromElem(this,t);case"img":return w.fromElem(this,t);case"options":return x.fromElem(this.main,this,t);case"page":return S.fromElem(this.main,this,t);case"text":return b.fromElem(this,t)}const i=this.main.getNewModule(e);if(null===i)return console.log("unknown module",e),null;i.definitions.clear();for(let e=0;e{if(1===t.nodeType){const e=t;i.definitions.set(e.localName,e.innerHTML)}})),new v(this,i)}getDefinition(t){return this.main.getDefinition(t)}getElement(t){return t>=0&&t<=this.elements.length?this.elements[t]:null}getElementCount(){return this.elements.length}getMain(){return this.main}pop(){this.main.pop()}push(){this.main.push()}render(t){this.main.push(),this.definitions.forEach(((t,e)=>{this.main.set(e,t)})),this.elements.forEach((e=>{e.render(t)})),this.main.pop()}set(t,e){this.main.set(t,e)}}class P{changeSlide(t){if(t<0&&t>=this.numPages)return;this.tree.getElement(t);const e=this.viewportElement.querySelectorAll(".page");this.currentPage>=0&&this.currentPage=0&&this.currentPage=0&&this.currentPage=this.numPages?s.classList.add("disabled"):s.classList.remove("disabled")}constructor(t){if(this.handleClick=t=>{const e=t.target;let i,s=e.getAttribute("data-action");switch(null===s&&(s=e.getAttribute("data-id")),s){case"fullscreen":document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen(),t.stopPropagation(),t.preventDefault();break;case"prev":i=Math.max(this.currentPage-1,0);break;case"next":case null:i=Math.min(this.currentPage+1,this.numPages-1)}return void 0!==i&&this.changeSlide(i),e.closest(".ui")&&(t.stopPropagation(),t.preventDefault()),!1},this.handleDropdown=t=>(t.stopPropagation(),t.preventDefault(),this.changeSlide(parseInt(this.select.value)),!1),this.handleKey=t=>{switch(t.key){case"ArrowLeft":this.changeSlide(Math.max(this.currentPage-1,0));break;case"ArrowRight":this.changeSlide(Math.min(this.currentPage+1,this.numPages-1))}},this.handleMouseMove=()=>{this.timer&&window.clearTimeout(this.timer),this.ui.classList.add("visible"),document.body.style.cursor="auto",this.timer=window.setTimeout(this.hideUI,2e3)},this.handleTouchEnd=t=>{const e=t.changedTouches[0].screenX;if(Math.abs(this.touchStartX-e)>100){let t;t=this.touchStartX{this.touchStartX=t.changedTouches[0].screenX},this.hideUI=()=>{this.ui.classList.remove("visible"),document.body.style.cursor="none"},this.moveViewpoint=()=>{const t=this.tree.getElement(this.currentPage).getView();let e="";t.viewRotation.x&&(e+=" rotateX("+-t.viewRotation.x+"deg) "+e),t.viewRotation.y&&(e+=" rotateY("+-t.viewRotation.y+"deg) "+e),t.viewRotation.z&&(e+=" rotateZ("+-t.viewRotation.z+"deg) "+e),e+=" translate3d("+-t.position.x+"px,"+-t.position.y+"px, "+-t.position.z+"px)";const i=parseInt(this.getDefinition("width"))/t.size.w,s=parseInt(this.getDefinition("height"))/t.size.h,r=Math.min(i,s),n=this.viewportElement.parentElement.clientHeight/parseFloat(this.getDefinition("height"))*r;1!=n&&(e="scale("+n+")"+e),this.viewportElement.style.transform=e},void 0===t)throw"please supply a configuration";this.definitions=[],this.modules=new Map,this.currentPage=0,this.numPages=0,this.transition=t.transitionType||"flip",this.tree=new E(this,null),this.ui=document.querySelector(t.uiSelector||".ui"),this.select=this.ui.querySelector("select[data-id=pages]"),document.location.hash&&(this.currentPage=parseInt(document.location.hash.substring(1))-1),this.config=t}createDefinitions(t){const e=new Map;t.childNodes.forEach((t=>{if(1==t.nodeType){const i=t;e.set(i.localName,i.innerHTML)}})),this.definitions.push(e)}createModules(t){t.childNodes.forEach((t=>{if(1==t.nodeType){const e=t,i=new E(this);i.createFromElem(e),this.modules.set(e.localName,i)}}))}createPages(t){const e=t;this.tree.createFromElem(e),this.numPages=this.tree.getElementCount(),this.definitions[0].set("numpages",this.numPages.toString()),this.definitions[0].set("page","0");for(let t=0;t{const e=t;switch(e.localName){case"definitions":this.createDefinitions(e);break;case"modules":this.createModules(e);break;case"pages":this.createPages(e)}t=t.nextSibling})),this.viewportElement=document.createElement("div"),this.viewportElement.id="viewport",this.tree.render(this.viewportElement),document.querySelector(this.config.targetSelector).append(this.viewportElement)},new((i=void 0)||(i=Promise))((function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function a(t){try{h(s.throw(t))}catch(t){n(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}));var t,e,i,s}getDefinition(t){let e="";return this.definitions.forEach((i=>{const s=i.get(t);void 0!==s&&(e=s)})),""===e&&console.log("failed to get definition for",t),e}getNewModule(t){const e=this.modules.get(t);return void 0!==e?new E(this,e):(console.log("unknown render element",t),null)}pop(){this.definitions.pop()}present(){window.addEventListener("resize",this.moveViewpoint),document.querySelectorAll("body, [data-action]").forEach((t=>{t.addEventListener("click",this.handleClick)})),window.addEventListener("keydown",this.handleKey),this.select.addEventListener("change",this.handleDropdown),window.addEventListener("mousemove",this.handleMouseMove),document.body.addEventListener("touchstart",this.handleTouchStart),document.body.addEventListener("touchend",this.handleTouchEnd),this.moveViewpoint(),this.changeSlide(this.currentPage)}push(){this.definitions.push(new Map)}set(t,e){this.definitions.at(-1).set(t,e)}}var M=self;for(var z in e)M[z]=e[z];e.__esModule&&Object.defineProperty(M,"__esModule",{value:!0})})(); \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 46e593a..f60f728 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,7 +16,7 @@ module.exports = { extensions: ['.tsx', '.ts', '.js'], }, output: { - path: path.resolve(__dirname, 'dist'), + path: path.resolve(__dirname, 'public'), filename: 'presentationmaker.js', libraryTarget: 'global', },