diff --git a/HypeReactiveContent.min.js b/HypeReactiveContent.min.js index aaac621..157355d 100644 --- a/HypeReactiveContent.min.js +++ b/HypeReactiveContent.min.js @@ -1,8 +1,9 @@ /* - Hype Reactive Content 1.0.4 + Hype Reactive Content 1.0.5 copyright (c) 2022 Max Ziebell, (https://maxziebell.de). MIT-license */ -!1==="HypeReactiveContent"in window&&(window.HypeReactiveContent=function(){function h(a,e){return new Proxy(a,{get:function(c,b,d){c=Reflect.get(c,b,d);return"object"===typeof c?h(c,e):c},set:function(c,b,d,f){var g=Reflect.set(c,b,d,f);e(b,d,c,f);return g},has:function(c,b,d){return"hypeDocument"==b?!1:c.hasOwnProperty(b)||window[b]?Reflect.has(c,b,d):!0}})}function l(a){return function(){if(!a.timeout){var e=arguments;a.timeout=requestAnimationFrame(function(){a.apply(this,e);a.timeout=null}.bind(this))}}} -!1==="HYPE_eventListeners"in window&&(window.HYPE_eventListeners=[]);window.HYPE_eventListeners.push({type:"HypeDocumentLoad",callback:function(a,e,c){a.updateContent=function(b,d){void 0!==b&&void 0!==d&&a.triggerCustomBehaviorNamed(b+" equals "+("string"===typeof d?'"'+d+'"':d));void 0!==b&&a.triggerCustomBehaviorNamed(b+" was updated");document.getElementById(a.currentSceneId()).querySelectorAll("[data-content], [data-visibility]").forEach(function(f){var g=f.getAttribute("data-content"),k=a.runCode(g, -!0);g&&(f.innerHTML=void 0!==k?k:"");if(g=f.getAttribute("data-visibility"))f.style.visibility=a.runCode(g,!0)?"visible":"hidden"})};a.runCode=function(b,d){try{return d&&(b="return "+b),(new Function("hypeDocument","customData","with(customData){ "+b+"}"))(a,a.customData)}catch(f){console.error(f)}};a.customData=h(a.customData,l(a.updateContent));a.functions().HypeReactiveContent&&a.functions().HypeReactiveContent(a,e,c)}});window.HYPE_eventListeners.push({type:"HypeTriggerCustomBehavior",callback:function(a, -e,c){e=c.customBehaviorName;/[;=()]/.test(e)&&a.runCode(e)}});window.HYPE_eventListeners.push({type:"HypeScenePrepareForDisplay",callback:function(a,e,c){a.updateContent()}});return{version:"1.0.4"}}()); +!1==="HypeReactiveContent"in window&&(window.HypeReactiveContent=function(){function l(a,c){return new Proxy(a,{get:function(b,d,f){b=Reflect.get(b,d,f);return"object"===typeof b?l(b,c):b},set:function(b,d,f,g){var e=Reflect.set(b,d,f,g);c(d,f,b,g);return e},has:function(b,d,f){return"hypeDocument"==d?!1:b.hasOwnProperty(d)||window[d]?Reflect.has(b,d,f):!0}})}function m(a){return function(){if(!a.timeout){var c=arguments;a.timeout=requestAnimationFrame(function(){a.apply(this,c);a.timeout=null}.bind(this))}}} +function k(a,c){try{return(new Function("hypeDocument","customData","with(customData){ "+a+"}"))(c,c.customData)}catch(b){console.error(b)}}function n(a,c,b){!1==="HypeActionEvents"in window&&(c=b.customBehaviorName,/[;=()]/.test(c)&&k(c,a))}!1==="HYPE_eventListeners"in window&&(window.HYPE_eventListeners=[]);window.HYPE_eventListeners.push({type:"HypeDocumentLoad",callback:function(a,c,b){a.updateContent=function(d,f){void 0!==d&&void 0!==f&&a.triggerCustomBehaviorNamed(d+" equals "+("string"=== +typeof f?'"'+f+'"':f));void 0!==d&&a.triggerCustomBehaviorNamed(d+" was updated");document.getElementById(a.currentSceneId()).querySelectorAll("[data-content], [data-visibility]").forEach(function(g){var e=g.getAttribute("data-content"),h=g.getAttribute("data-visibility");!1==="HypeActionEvents"in window?(e&&(e=k("return "+e,a),g.innerHTML=void 0!==e?e:""),h&&(h=k("return "+h,a),g.style.visibility=h?"visible":"hidden")):(e&&(e=a.triggerAction("return "+e,{element:g,event:{type:"HypeReactiveContent"}}), +g.innerHTML=void 0!==e?e:""),h&&(h=a.triggerAction("return "+h,{element:g,event:{type:"HypeReactiveContent"}}),g.style.visibility=h?"visible":"hidden"))})};a.customData=l(a.customData,m(a.updateContent));a.functions().HypeReactiveContent&&a.functions().HypeReactiveContent(a,c,b)}});window.HYPE_eventListeners.push({type:"HypeScenePrepareForDisplay",callback:function(a,c,b){a.updateContent()}});!1==="HypeActionEvents"in window&&window.HYPE_eventListeners.push({type:"HypeTriggerCustomBehavior",callback:n}); +return{version:"1.0.5"}}());