From 6674b5d75cf076966272b879a1ab24e6daa1e696 Mon Sep 17 00:00:00 2001 From: Arthur Guiot Date: Mon, 11 Dec 2017 14:37:39 +0800 Subject: [PATCH] Fixed repeat function before release display.min.js didn't handled the repeat function until now. --- __test__/display.js | 4 ++-- dist/display.js | 4 ++-- dist/display.min.js | 2 +- dist/light/display.es6.js | 4 ++-- dist/light/display.es6.min.js | 2 +- dist/light/display.js | 4 +--- dist/light/display.min.js | 2 +- src/base.js | 4 ++-- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/__test__/display.js b/__test__/display.js index da99dde..f720e06 100644 --- a/__test__/display.js +++ b/__test__/display.js @@ -188,7 +188,7 @@ class DisplayJS { return list; } // custom repeat function - repeat(el, object, position="in") { + repeat(el, object) { el = this.s(el); const text = el[0].innerHTML; el[0].innerHTML = "" @@ -196,7 +196,7 @@ class DisplayJS { function interpolate(str) { return function interpolate(o) { return str.replace(/{([^{}]*)}/g, function(a, b) { - const data = o; + window["data"] = o; let r = eval(b) return r }); diff --git a/dist/display.js b/dist/display.js index da99dde..f720e06 100644 --- a/dist/display.js +++ b/dist/display.js @@ -188,7 +188,7 @@ class DisplayJS { return list; } // custom repeat function - repeat(el, object, position="in") { + repeat(el, object) { el = this.s(el); const text = el[0].innerHTML; el[0].innerHTML = "" @@ -196,7 +196,7 @@ class DisplayJS { function interpolate(str) { return function interpolate(o) { return str.replace(/{([^{}]*)}/g, function(a, b) { - const data = o; + window["data"] = o; let r = eval(b) return r }); diff --git a/dist/display.min.js b/dist/display.min.js index 009e3a6..5c08051 100644 --- a/dist/display.min.js +++ b/dist/display.min.js @@ -1 +1 @@ -class DisplayJS{constructor(a){this.obj=a}var(a){const b=()=>{this.if(),this.else();const a=document.querySelectorAll("[var]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}render(a){this.var(a)}renderVariables(a){this.var(a)}xss(a){const b=//g,d=/'/g,e=/"/g;return a.toString().replace(b,"<").replace(c,">").replace(d,"'").replace(e,""")}xssURI(a){return encodeURI(a)}target(a=()=>{this.var()}){const b=(()=>{return document.addEventListener?(a,b,c)=>{a.addEventListener(b,c,!1)}:(a,b,c)=>{a.attachEvent(`on${b}`,c)}})(),c=this.obj;[].forEach.call(document.querySelectorAll("[target]"),(d)=>{b(d,"change",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"keydown",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"input",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"paste",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)})})}if(a){const b=()=>{const a=document.querySelectorAll("[if]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}else(a){const b=()=>{const a=document.querySelectorAll("[else]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}toNodeList(a){a.setAttribute("wrapNodeList","");const b=document.querySelectorAll("[wrapNodeList]");return a.removeAttribute("wrapNodeList"),b}repeat(a,b,c="in"){function d(a){return function(c){return a.replace(/{([^{}]*)}/g,function(d,a){const b=c;let e=eval(a);return e})}}a=this.s(a);const e=a[0].innerHTML;a[0].innerHTML="";for(var f=0;f{eval(d)})}}all(a,b){a=this.s(a),a.forEach((a)=>{b(this.toNodeList(a))})}text(a,b){return a=this.s(a),b?a[0].innerHTML=this.xss(b):a[0].innerHTML}html(a,b){return a=this.s(a),b?a[0].innerHTML=b:a[0].innerHTML}append(a,b){a=this.s(a),a[0].innerHTML+=b}after(a,b){a=this.s(a),a[0].insertAdjacentHTML("afterend",b)}before(a,b){a=this.s(a),a[0].insertAdjacentHTML("beforebegin",b)}clone(a){a[0].cloneNode(!0)}is(a,b){return a=this.s(a),b=this.s(b),a[0]===b[0]}select(a){return a instanceof NodeList?a:document.querySelectorAll(a)}single(a){return this.isElement(a)?a:document.querySelector(a)}s(a){return this.select(a)}empty(a){a=this.s(a),a[0].innerHTML=""}valEmpty(a){a=this.s(a),a[0].value=null}remove(a){a=this.s(a),a[0].parentNode.removeChild(a[0])}on(a,b,c){a=this.s(a),a[0].addEventListener(b,c)}ready(a){(document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?a():document.addEventListener("DOMContentLoaded",a)}scroll(a){window.addEventListener("scroll",a)}scrollTo(a,b){window.scroll(a,b)}scrollTop(a){return a=null==a?0==document.body.scrollTop?this.toNodeList(document.documentElement):this.toNodeList(document.body):a,a=this.s(a),a[0].scrollTop}show(a){return a=this.s(a),a[0].style.display="block",!0}hide(a){return a=this.s(a),a[0].style.display="none",!0}hasClass(a,b){return a=this.s(a),a[0].classList?a[0].classList.contains(b):!!a[0].className.match(new RegExp(`(\\s|^)${b}(\\s|$)`))}addClass(a,b){a=this.s(a),a[0].classList?a[0].classList.add(b):!this.hasClass(a,b)&&(a[0].className+=` ${b}`)}removeClass(a,b){if(a=this.s(a),a[0].classList)a[0].classList.remove(b);else if(this.hasClass(a,b)){const c=new RegExp(`(\\s|^)${b}(\\s|$)`);a[0].className=a[0].className.replace(c," ")}}toggleClass(a,b){a=this.s(a),this.hasClass(a,b)?this.removeClass(a,b):this.addClass(a,b)}css(a,b,c){if(a=this.s(a),"object"==typeof b)for(let c in b)a[0].style[c]=b[c];else a[0].style[b]=c}getStyle(a,b){return a=this.s(a),a[0].style[b]}fadeOut(a,b=0.1){a=this.s(a)[0],a.style.opacity=1,function c(){0>(a.style.opacity-=b)?a.style.display="none":requestAnimationFrame(c)}()}fadeIn(a,b=0.1,c){a=this.s(a)[0],a.style.opacity=0,a.style.display=c||"block",function c(){let d=parseFloat(a.style.opacity);1<(d+=b)||(a.style.opacity=d,requestAnimationFrame(c))}()}get fn(){return DisplayJS.prototype}dynamic(a,b=250){window.setInterval(a,b)}parent(a,b=0){a=this.s(a);let c=a[0];for(const d in this.range(b))c=c.parentNode;return this.toNodeList(c)}isNode(a){return"object"==typeof Node?a instanceof Node:a&&"object"==typeof a&&"number"==typeof a.nodeType&&"string"==typeof a.nodeName}isElement(a){return"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName}component(a,b){class component extends HTMLElement{constructor(){super(),b(this)}}customElements.define(a,component)}import(a,b){let c=document.createElement("script");const d=document.getElementsByTagName("script")[0];c.async=1,c.onload=c.onreadystatechange=(a,d)=>{(d||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c=void 0,!d&&b&&b())},c.src=a,d.parentNode.insertBefore(c,d)}sleep(a){for(const b=new Date().getTime()+a;new Date().getTime()a-f*(d||0)+f*(c||1)*e)}range(a){return this.arange(0,a,1)}linespace(a,b,c){return this.arange(a,b,(b-a)/c)}reshape(a,b){const c=[];for(let d=0;dc.concat(a),[])}drop(a,b){return 0{}){a=this.s(a),this.ajax(b,"GET","",(b)=>{try{a[0].innerHTML=b,c()}catch(a){c(a)}})}ajax(a,b,c,d,e="application/x-www-form-urlencoded; charset=UTF-8"){const f=new XMLHttpRequest;f.open(b,a,!0),f.setRequestHeader("Content-Type",e),f.onload=()=>{if(200<=f.status&&400>f.status){const a=f.responseText;d(a,f)}else console.error("DisplayJS error: The ajax request returned an error.")},f.onerror=()=>{console.error("DisplayJS error: The ajax request returned an error.")},f.send(c)}get(a,b,c=!1){this.ajax(a,"GET","",(a)=>{c?b(JSON.parse(a)):b(a)})}custom(a,b,c){const d=()=>{const c=document.querySelectorAll(`[${a}]`);for(let d=0;d{d()})):window.setInterval(()=>{d()},c):d()}live(a,b){const c={watch(a,b,c){const d=Object.getOwnPropertyDescriptor(a,b);if("undefined"==typeof d)throw new Error(`DisplayJS: Invalid descriptor for property: ${b}, object: ${a}`);if("function"!=typeof c)throw new Error(`DisplayJS: Invalid onPropertyChange handler: ${c}`);let e=a[b];Object.defineProperty(a,b,{enumerable:!0,configurable:!0,get(){return e},set(d){if(d!==e)return c(a,b,d,e),e=d}})},watchAll(a,b){if("function"!=typeof b)throw new Error(`DisplayJS: Invalid onPropertyChange handler: ${b}`);for(const c in a)this.watch(a,c,b)}};c.watchAll(a,(a,c,d,e)=>{b(a,c,d,e)})}time_ago(a){var b=Math.floor;switch(typeof a){case"number":break;case"string":a=+new Date(a);break;case"object":a.constructor===Date&&(a=a.getTime());break;default:a=+new Date;}const c=[[60,"seconds",1],[120,"1 minute ago","1 minute from now"],[3600,"minutes",60],[7200,"1 hour ago","1 hour from now"],[86400,"hours",3600],[172800,"Yesterday","Tomorrow"],[604800,"days",86400],[1209600,"Last week","Next week"],[2419200,"weeks",604800],[4838400,"Last month","Next month"],[29030400,"months",2419200],[58060800,"Last year","Next year"],[2903040000,"years",29030400],[5806080000,"Last century","Next century"],[58060800000,"centuries",2903040000]],d=this.math;let e=d.div(d.sub(+new Date,a),1e3),f="ago",g=1;if(0==e)return"Just now";0>e&&(e=Math.abs(e),f="from now",g=2);let h,j=0;for(;h=c[j++];)if(ethis.math.add(c,a))}multiply(a){return a.reduce((c,a)=>this.math.mul(c,a))}average(a){const b=this.sum(a),c=this.math.div(b,a.length);return c}median(a){a.sort((c,a)=>this.math.sub(c,a));const b=Math.floor(this.math.div(a.length,2));return a.length%2?a[b]:this.math.div(this.math.add(a[b-1],a[b]),2)}predict(a,b,c=!1){const d=this.math,e=this,f=Object.keys(a);for(var g=0;g=9007199254740991)throw"DisplayJS: The result is not a safe integer."},shiftComma(a,b){return this.toExponent(this.countDecimals([a]),-b)[0]},countResult(a,b){let c=a[0];for(let d=1;da.length)throw"DisplayJS: Set at least two numerical values.";for(const b in a){if(a[b]=parseFloat(a[b]),"number"!=typeof a[b]||isNaN(a[b]))throw"DisplayJS: Every Math argument must be of type number.";if(a[b]===Number.POSITIVE_INFINITY||a[b]===Number.NEGATIVE_INFINITY)throw"DisplayJS: Every Math argument must be a numerical value between positive and negative Infinity."}return a},countDecimals(a){const b=[];for(const c in a){let d=0;const e=a[c].toString().split("e"),f=e[0].indexOf(".");d-=-1===f?0:e[0].length-1-f,d+=isNaN(+e[1])?0:+e[1],e[0]=+e[0].replace(".",""),b.push({integer:e[0],comma:d})}return b}};return a}then(a,b){try{b(a())}catch(a){throw"DisplayJS: "+a}}copy(a){let b=document.createElement("textarea");b.style.position="absolute",b.style.left="-9999px",b.style.top="0",b.textContent=a,document.body.appendChild(b),b.focus(),b.setSelectionRange(0,b.value.length);try{document.execCommand("copy"),b.remove()}catch(b){window.prompt("Copy to clipboard: Ctrl+C, Enter",a)}}}"function"==typeof define&&define.amd?define(()=>new DisplayJS):"undefined"==typeof exports?"undefined"!=typeof global&&(global.DisplayJS=new DisplayJS):("undefined"!=typeof module&&module.exports&&(exports=module.exports=new DisplayJS),exports.DisplayJS=new DisplayJS); \ No newline at end of file +class DisplayJS{constructor(a){this.obj=a}var(a){const b=()=>{this.if(),this.else();const a=document.querySelectorAll("[var]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}render(a){this.var(a)}renderVariables(a){this.var(a)}xss(a){const b=//g,d=/'/g,e=/"/g;return a.toString().replace(b,"<").replace(c,">").replace(d,"'").replace(e,""")}xssURI(a){return encodeURI(a)}target(a=()=>{this.var()}){const b=(()=>{return document.addEventListener?(a,b,c)=>{a.addEventListener(b,c,!1)}:(a,b,c)=>{a.attachEvent(`on${b}`,c)}})(),c=this.obj;[].forEach.call(document.querySelectorAll("[target]"),(d)=>{b(d,"change",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"keydown",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"input",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"paste",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)})})}if(a){const b=()=>{const a=document.querySelectorAll("[if]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}else(a){const b=()=>{const a=document.querySelectorAll("[else]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}toNodeList(a){a.setAttribute("wrapNodeList","");const b=document.querySelectorAll("[wrapNodeList]");return a.removeAttribute("wrapNodeList"),b}repeat(a,b){function c(a){return function(c){return a.replace(/{([^{}]*)}/g,function(d,a){window.data=c;let b=eval(a);return b})}}a=this.s(a);const d=a[0].innerHTML;a[0].innerHTML="";for(var e=0;e{eval(d)})}}all(a,b){a=this.s(a),a.forEach((a)=>{b(this.toNodeList(a))})}text(a,b){return a=this.s(a),b?a[0].innerHTML=this.xss(b):a[0].innerHTML}html(a,b){return a=this.s(a),b?a[0].innerHTML=b:a[0].innerHTML}append(a,b){a=this.s(a),a[0].innerHTML+=b}after(a,b){a=this.s(a),a[0].insertAdjacentHTML("afterend",b)}before(a,b){a=this.s(a),a[0].insertAdjacentHTML("beforebegin",b)}clone(a){a[0].cloneNode(!0)}is(a,b){return a=this.s(a),b=this.s(b),a[0]===b[0]}select(a){return a instanceof NodeList?a:document.querySelectorAll(a)}single(a){return this.isElement(a)?a:document.querySelector(a)}s(a){return this.select(a)}empty(a){a=this.s(a),a[0].innerHTML=""}valEmpty(a){a=this.s(a),a[0].value=null}remove(a){a=this.s(a),a[0].parentNode.removeChild(a[0])}on(a,b,c){a=this.s(a),a[0].addEventListener(b,c)}ready(a){(document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?a():document.addEventListener("DOMContentLoaded",a)}scroll(a){window.addEventListener("scroll",a)}scrollTo(a,b){window.scroll(a,b)}scrollTop(a){return a=null==a?0==document.body.scrollTop?this.toNodeList(document.documentElement):this.toNodeList(document.body):a,a=this.s(a),a[0].scrollTop}show(a){return a=this.s(a),a[0].style.display="block",!0}hide(a){return a=this.s(a),a[0].style.display="none",!0}hasClass(a,b){return a=this.s(a),a[0].classList?a[0].classList.contains(b):!!a[0].className.match(new RegExp(`(\\s|^)${b}(\\s|$)`))}addClass(a,b){a=this.s(a),a[0].classList?a[0].classList.add(b):!this.hasClass(a,b)&&(a[0].className+=` ${b}`)}removeClass(a,b){if(a=this.s(a),a[0].classList)a[0].classList.remove(b);else if(this.hasClass(a,b)){const c=new RegExp(`(\\s|^)${b}(\\s|$)`);a[0].className=a[0].className.replace(c," ")}}toggleClass(a,b){a=this.s(a),this.hasClass(a,b)?this.removeClass(a,b):this.addClass(a,b)}css(a,b,c){if(a=this.s(a),"object"==typeof b)for(let c in b)a[0].style[c]=b[c];else a[0].style[b]=c}getStyle(a,b){return a=this.s(a),a[0].style[b]}fadeOut(a,b=0.1){a=this.s(a)[0],a.style.opacity=1,function c(){0>(a.style.opacity-=b)?a.style.display="none":requestAnimationFrame(c)}()}fadeIn(a,b=0.1,c){a=this.s(a)[0],a.style.opacity=0,a.style.display=c||"block",function c(){let d=parseFloat(a.style.opacity);1<(d+=b)||(a.style.opacity=d,requestAnimationFrame(c))}()}get fn(){return DisplayJS.prototype}dynamic(a,b=250){window.setInterval(a,b)}parent(a,b=0){a=this.s(a);let c=a[0];for(const d in this.range(b))c=c.parentNode;return this.toNodeList(c)}isNode(a){return"object"==typeof Node?a instanceof Node:a&&"object"==typeof a&&"number"==typeof a.nodeType&&"string"==typeof a.nodeName}isElement(a){return"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName}component(a,b){class component extends HTMLElement{constructor(){super(),b(this)}}customElements.define(a,component)}import(a,b){let c=document.createElement("script");const d=document.getElementsByTagName("script")[0];c.async=1,c.onload=c.onreadystatechange=(a,d)=>{(d||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c=void 0,!d&&b&&b())},c.src=a,d.parentNode.insertBefore(c,d)}sleep(a){for(const b=new Date().getTime()+a;new Date().getTime()a-f*(d||0)+f*(c||1)*e)}range(a){return this.arange(0,a,1)}linespace(a,b,c){return this.arange(a,b,(b-a)/c)}reshape(a,b){const c=[];for(let d=0;dc.concat(a),[])}drop(a,b){return 0{}){a=this.s(a),this.ajax(b,"GET","",(b)=>{try{a[0].innerHTML=b,c()}catch(a){c(a)}})}ajax(a,b,c,d,e="application/x-www-form-urlencoded; charset=UTF-8"){const f=new XMLHttpRequest;f.open(b,a,!0),f.setRequestHeader("Content-Type",e),f.onload=()=>{if(200<=f.status&&400>f.status){const a=f.responseText;d(a,f)}else console.error("DisplayJS error: The ajax request returned an error.")},f.onerror=()=>{console.error("DisplayJS error: The ajax request returned an error.")},f.send(c)}get(a,b,c=!1){this.ajax(a,"GET","",(a)=>{c?b(JSON.parse(a)):b(a)})}custom(a,b,c){const d=()=>{const c=document.querySelectorAll(`[${a}]`);for(let d=0;d{d()})):window.setInterval(()=>{d()},c):d()}live(a,b){const c={watch(a,b,c){const d=Object.getOwnPropertyDescriptor(a,b);if("undefined"==typeof d)throw new Error(`DisplayJS: Invalid descriptor for property: ${b}, object: ${a}`);if("function"!=typeof c)throw new Error(`DisplayJS: Invalid onPropertyChange handler: ${c}`);let e=a[b];Object.defineProperty(a,b,{enumerable:!0,configurable:!0,get(){return e},set(d){if(d!==e)return c(a,b,d,e),e=d}})},watchAll(a,b){if("function"!=typeof b)throw new Error(`DisplayJS: Invalid onPropertyChange handler: ${b}`);for(const c in a)this.watch(a,c,b)}};c.watchAll(a,(a,c,d,e)=>{b(a,c,d,e)})}time_ago(a){var b=Math.floor;switch(typeof a){case"number":break;case"string":a=+new Date(a);break;case"object":a.constructor===Date&&(a=a.getTime());break;default:a=+new Date;}const c=[[60,"seconds",1],[120,"1 minute ago","1 minute from now"],[3600,"minutes",60],[7200,"1 hour ago","1 hour from now"],[86400,"hours",3600],[172800,"Yesterday","Tomorrow"],[604800,"days",86400],[1209600,"Last week","Next week"],[2419200,"weeks",604800],[4838400,"Last month","Next month"],[29030400,"months",2419200],[58060800,"Last year","Next year"],[2903040000,"years",29030400],[5806080000,"Last century","Next century"],[58060800000,"centuries",2903040000]],d=this.math;let e=d.div(d.sub(+new Date,a),1e3),f="ago",g=1;if(0==e)return"Just now";0>e&&(e=Math.abs(e),f="from now",g=2);let h,j=0;for(;h=c[j++];)if(ethis.math.add(c,a))}multiply(a){return a.reduce((c,a)=>this.math.mul(c,a))}average(a){const b=this.sum(a),c=this.math.div(b,a.length);return c}median(a){a.sort((c,a)=>this.math.sub(c,a));const b=Math.floor(this.math.div(a.length,2));return a.length%2?a[b]:this.math.div(this.math.add(a[b-1],a[b]),2)}predict(a,b,c=!1){const d=this.math,e=this,f=Object.keys(a);for(var g=0;g=9007199254740991)throw"DisplayJS: The result is not a safe integer."},shiftComma(a,b){return this.toExponent(this.countDecimals([a]),-b)[0]},countResult(a,b){let c=a[0];for(let d=1;da.length)throw"DisplayJS: Set at least two numerical values.";for(const b in a){if(a[b]=parseFloat(a[b]),"number"!=typeof a[b]||isNaN(a[b]))throw"DisplayJS: Every Math argument must be of type number.";if(a[b]===Number.POSITIVE_INFINITY||a[b]===Number.NEGATIVE_INFINITY)throw"DisplayJS: Every Math argument must be a numerical value between positive and negative Infinity."}return a},countDecimals(a){const b=[];for(const c in a){let d=0;const e=a[c].toString().split("e"),f=e[0].indexOf(".");d-=-1===f?0:e[0].length-1-f,d+=isNaN(+e[1])?0:+e[1],e[0]=+e[0].replace(".",""),b.push({integer:e[0],comma:d})}return b}};return a}then(a,b){try{b(a())}catch(a){throw"DisplayJS: "+a}}copy(a){let b=document.createElement("textarea");b.style.position="absolute",b.style.left="-9999px",b.style.top="0",b.textContent=a,document.body.appendChild(b),b.focus(),b.setSelectionRange(0,b.value.length);try{document.execCommand("copy"),b.remove()}catch(b){window.prompt("Copy to clipboard: Ctrl+C, Enter",a)}}}"function"==typeof define&&define.amd?define(()=>new DisplayJS):"undefined"==typeof exports?"undefined"!=typeof global&&(global.DisplayJS=new DisplayJS):("undefined"!=typeof module&&module.exports&&(exports=module.exports=new DisplayJS),exports.DisplayJS=new DisplayJS); \ No newline at end of file diff --git a/dist/light/display.es6.js b/dist/light/display.es6.js index 55bbc31..40edab2 100644 --- a/dist/light/display.es6.js +++ b/dist/light/display.es6.js @@ -188,7 +188,7 @@ class DisplayJS { return list; } // custom repeat function - repeat(el, object, position="in") { + repeat(el, object) { el = this.s(el); const text = el[0].innerHTML; el[0].innerHTML = "" @@ -196,7 +196,7 @@ class DisplayJS { function interpolate(str) { return function interpolate(o) { return str.replace(/{([^{}]*)}/g, function(a, b) { - const data = o; + window["data"] = o; let r = eval(b) return r }); diff --git a/dist/light/display.es6.min.js b/dist/light/display.es6.min.js index ffdaaad..92bb6e6 100644 --- a/dist/light/display.es6.min.js +++ b/dist/light/display.es6.min.js @@ -1 +1 @@ -class DisplayJS{constructor(a){this.obj=a}var(a){const b=()=>{this.if(),this.else();const a=document.querySelectorAll("[var]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}render(a){this.var(a)}renderVariables(a){this.var(a)}xss(a){const b=//g,d=/'/g,e=/"/g;return a.toString().replace(b,"<").replace(c,">").replace(d,"'").replace(e,""")}xssURI(a){return encodeURI(a)}target(a=()=>{this.var()}){const b=(()=>{return document.addEventListener?(a,b,c)=>{a.addEventListener(b,c,!1)}:(a,b,c)=>{a.attachEvent(`on${b}`,c)}})(),c=this.obj;[].forEach.call(document.querySelectorAll("[target]"),(d)=>{b(d,"change",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"keydown",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"input",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"paste",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)})})}if(a){const b=()=>{const a=document.querySelectorAll("[if]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}else(a){const b=()=>{const a=document.querySelectorAll("[else]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}toNodeList(a){a.setAttribute("wrapNodeList","");const b=document.querySelectorAll("[wrapNodeList]");return a.removeAttribute("wrapNodeList"),b}repeat(a,b,c="in"){function d(a){return function(c){return a.replace(/{([^{}]*)}/g,function(d,a){const b=c;let e=eval(a);return e})}}a=this.s(a);const e=a[0].innerHTML;a[0].innerHTML="";for(var f=0;f{eval(d)})}}all(a,b){a=this.s(a),a.forEach((a)=>{b(this.toNodeList(a))})}text(a,b){return a=this.s(a),b?a[0].innerHTML=this.xss(b):a[0].innerHTML}html(a,b){return a=this.s(a),b?a[0].innerHTML=b:a[0].innerHTML}append(a,b){a=this.s(a),a[0].innerHTML+=b}after(a,b){a=this.s(a),a[0].insertAdjacentHTML("afterend",b)}before(a,b){a=this.s(a),a[0].insertAdjacentHTML("beforebegin",b)}clone(a){a[0].cloneNode(!0)}is(a,b){return a=this.s(a),b=this.s(b),a[0]===b[0]}select(a){return a instanceof NodeList?a:document.querySelectorAll(a)}single(a){return this.isElement(a)?a:document.querySelector(a)}s(a){return this.select(a)}empty(a){a=this.s(a),a[0].innerHTML=""}valEmpty(a){a=this.s(a),a[0].value=null}remove(a){a=this.s(a),a[0].parentNode.removeChild(a[0])}on(a,b,c){a=this.s(a),a[0].addEventListener(b,c)}ready(a){(document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?a():document.addEventListener("DOMContentLoaded",a)}scroll(a){window.addEventListener("scroll",a)}scrollTo(a,b){window.scroll(a,b)}scrollTop(a){return a=null==a?0==document.body.scrollTop?this.toNodeList(document.documentElement):this.toNodeList(document.body):a,a=this.s(a),a[0].scrollTop}show(a){return a=this.s(a),a[0].style.display="block",!0}hide(a){return a=this.s(a),a[0].style.display="none",!0}hasClass(a,b){return a=this.s(a),a[0].classList?a[0].classList.contains(b):!!a[0].className.match(new RegExp(`(\\s|^)${b}(\\s|$)`))}addClass(a,b){a=this.s(a),a[0].classList?a[0].classList.add(b):!this.hasClass(a,b)&&(a[0].className+=` ${b}`)}removeClass(a,b){if(a=this.s(a),a[0].classList)a[0].classList.remove(b);else if(this.hasClass(a,b)){const c=new RegExp(`(\\s|^)${b}(\\s|$)`);a[0].className=a[0].className.replace(c," ")}}toggleClass(a,b){a=this.s(a),this.hasClass(a,b)?this.removeClass(a,b):this.addClass(a,b)}css(a,b,c){if(a=this.s(a),"object"==typeof b)for(let c in b)a[0].style[c]=b[c];else a[0].style[b]=c}getStyle(a,b){return a=this.s(a),a[0].style[b]}fadeOut(a,b=0.1){a=this.s(a)[0],a.style.opacity=1,function c(){0>(a.style.opacity-=b)?a.style.display="none":requestAnimationFrame(c)}()}fadeIn(a,b=0.1,c){a=this.s(a)[0],a.style.opacity=0,a.style.display=c||"block",function c(){let d=parseFloat(a.style.opacity);1<(d+=b)||(a.style.opacity=d,requestAnimationFrame(c))}()}get fn(){return DisplayJS.prototype}dynamic(a,b=250){window.setInterval(a,b)}parent(a,b=0){a=this.s(a);let c=a[0];for(const d in this.range(b))c=c.parentNode;return this.toNodeList(c)}isNode(a){return"object"==typeof Node?a instanceof Node:a&&"object"==typeof a&&"number"==typeof a.nodeType&&"string"==typeof a.nodeName}isElement(a){return"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName}component(a,b){class component extends HTMLElement{constructor(){super(),b(this)}}customElements.define(a,component)}import(a,b){let c=document.createElement("script");const d=document.getElementsByTagName("script")[0];c.async=1,c.onload=c.onreadystatechange=(a,d)=>{(d||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c=void 0,!d&&b&&b())},c.src=a,d.parentNode.insertBefore(c,d)}sleep(a){for(const b=new Date().getTime()+a;new Date().getTime()a-f*(d||0)+f*(c||1)*e)}range(a){return this.arange(0,a,1)}linespace(a,b,c){return this.arange(a,b,(b-a)/c)}reshape(a,b){const c=[];for(let d=0;dc.concat(a),[])}drop(a,b){return 0new DisplayJS):"undefined"==typeof exports?"undefined"!=typeof global&&(global.DisplayJS=new DisplayJS):("undefined"!=typeof module&&module.exports&&(exports=module.exports=new DisplayJS),exports.DisplayJS=new DisplayJS); \ No newline at end of file +class DisplayJS{constructor(a){this.obj=a}var(a){const b=()=>{this.if(),this.else();const a=document.querySelectorAll("[var]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}render(a){this.var(a)}renderVariables(a){this.var(a)}xss(a){const b=//g,d=/'/g,e=/"/g;return a.toString().replace(b,"<").replace(c,">").replace(d,"'").replace(e,""")}xssURI(a){return encodeURI(a)}target(a=()=>{this.var()}){const b=(()=>{return document.addEventListener?(a,b,c)=>{a.addEventListener(b,c,!1)}:(a,b,c)=>{a.attachEvent(`on${b}`,c)}})(),c=this.obj;[].forEach.call(document.querySelectorAll("[target]"),(d)=>{b(d,"change",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"keydown",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"input",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)}),b(d,"paste",function(){const b=d.getAttribute("target");c[b]="checkbox"==this.type?this.checked:"select"==this.type?this.options[this.selectedIndex].value:this.value,a(d)})})}if(a){const b=()=>{const a=document.querySelectorAll("[if]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}else(a){const b=()=>{const a=document.querySelectorAll("[else]");for(let b=0;b{b()})):window.setInterval(()=>{b()},a):b()}toNodeList(a){a.setAttribute("wrapNodeList","");const b=document.querySelectorAll("[wrapNodeList]");return a.removeAttribute("wrapNodeList"),b}repeat(a,b){function c(a){return function(c){return a.replace(/{([^{}]*)}/g,function(d,a){window.data=c;let b=eval(a);return b})}}a=this.s(a);const d=a[0].innerHTML;a[0].innerHTML="";for(var e=0;e{eval(d)})}}all(a,b){a=this.s(a),a.forEach((a)=>{b(this.toNodeList(a))})}text(a,b){return a=this.s(a),b?a[0].innerHTML=this.xss(b):a[0].innerHTML}html(a,b){return a=this.s(a),b?a[0].innerHTML=b:a[0].innerHTML}append(a,b){a=this.s(a),a[0].innerHTML+=b}after(a,b){a=this.s(a),a[0].insertAdjacentHTML("afterend",b)}before(a,b){a=this.s(a),a[0].insertAdjacentHTML("beforebegin",b)}clone(a){a[0].cloneNode(!0)}is(a,b){return a=this.s(a),b=this.s(b),a[0]===b[0]}select(a){return a instanceof NodeList?a:document.querySelectorAll(a)}single(a){return this.isElement(a)?a:document.querySelector(a)}s(a){return this.select(a)}empty(a){a=this.s(a),a[0].innerHTML=""}valEmpty(a){a=this.s(a),a[0].value=null}remove(a){a=this.s(a),a[0].parentNode.removeChild(a[0])}on(a,b,c){a=this.s(a),a[0].addEventListener(b,c)}ready(a){(document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?a():document.addEventListener("DOMContentLoaded",a)}scroll(a){window.addEventListener("scroll",a)}scrollTo(a,b){window.scroll(a,b)}scrollTop(a){return a=null==a?0==document.body.scrollTop?this.toNodeList(document.documentElement):this.toNodeList(document.body):a,a=this.s(a),a[0].scrollTop}show(a){return a=this.s(a),a[0].style.display="block",!0}hide(a){return a=this.s(a),a[0].style.display="none",!0}hasClass(a,b){return a=this.s(a),a[0].classList?a[0].classList.contains(b):!!a[0].className.match(new RegExp(`(\\s|^)${b}(\\s|$)`))}addClass(a,b){a=this.s(a),a[0].classList?a[0].classList.add(b):!this.hasClass(a,b)&&(a[0].className+=` ${b}`)}removeClass(a,b){if(a=this.s(a),a[0].classList)a[0].classList.remove(b);else if(this.hasClass(a,b)){const c=new RegExp(`(\\s|^)${b}(\\s|$)`);a[0].className=a[0].className.replace(c," ")}}toggleClass(a,b){a=this.s(a),this.hasClass(a,b)?this.removeClass(a,b):this.addClass(a,b)}css(a,b,c){if(a=this.s(a),"object"==typeof b)for(let c in b)a[0].style[c]=b[c];else a[0].style[b]=c}getStyle(a,b){return a=this.s(a),a[0].style[b]}fadeOut(a,b=0.1){a=this.s(a)[0],a.style.opacity=1,function c(){0>(a.style.opacity-=b)?a.style.display="none":requestAnimationFrame(c)}()}fadeIn(a,b=0.1,c){a=this.s(a)[0],a.style.opacity=0,a.style.display=c||"block",function c(){let d=parseFloat(a.style.opacity);1<(d+=b)||(a.style.opacity=d,requestAnimationFrame(c))}()}get fn(){return DisplayJS.prototype}dynamic(a,b=250){window.setInterval(a,b)}parent(a,b=0){a=this.s(a);let c=a[0];for(const d in this.range(b))c=c.parentNode;return this.toNodeList(c)}isNode(a){return"object"==typeof Node?a instanceof Node:a&&"object"==typeof a&&"number"==typeof a.nodeType&&"string"==typeof a.nodeName}isElement(a){return"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName}component(a,b){class component extends HTMLElement{constructor(){super(),b(this)}}customElements.define(a,component)}import(a,b){let c=document.createElement("script");const d=document.getElementsByTagName("script")[0];c.async=1,c.onload=c.onreadystatechange=(a,d)=>{(d||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c=void 0,!d&&b&&b())},c.src=a,d.parentNode.insertBefore(c,d)}sleep(a){for(const b=new Date().getTime()+a;new Date().getTime()a-f*(d||0)+f*(c||1)*e)}range(a){return this.arange(0,a,1)}linespace(a,b,c){return this.arange(a,b,(b-a)/c)}reshape(a,b){const c=[];for(let d=0;dc.concat(a),[])}drop(a,b){return 0new DisplayJS):"undefined"==typeof exports?"undefined"!=typeof global&&(global.DisplayJS=new DisplayJS):("undefined"!=typeof module&&module.exports&&(exports=module.exports=new DisplayJS),exports.DisplayJS=new DisplayJS); \ No newline at end of file diff --git a/dist/light/display.js b/dist/light/display.js index 72f354f..6bf7c13 100644 --- a/dist/light/display.js +++ b/dist/light/display.js @@ -242,8 +242,6 @@ var DisplayJS = function () { }, { key: "repeat", value: function repeat(el, object) { - var position = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "in"; - el = this.s(el); var text = el[0].innerHTML; el[0].innerHTML = ""; @@ -251,7 +249,7 @@ var DisplayJS = function () { function interpolate(str) { return function interpolate(o) { return str.replace(/{([^{}]*)}/g, function (a, b) { - var data = o; + window["data"] = o; var r = eval(b); return r; }); diff --git a/dist/light/display.min.js b/dist/light/display.min.js index 5dda2d6..d0f3669 100644 --- a/dist/light/display.min.js +++ b/dist/light/display.min.js @@ -1 +1 @@ -"use strict";function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_createClass=function(){function e(e,t){for(var n=0;n/g,i=/'/g,o=/"/g;return e.toString().replace(t,"<").replace(n,">").replace(i,"'").replace(o,""")}},{key:"xssURI",value:function(e){return encodeURI(e)}},{key:"target",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){e.var()},n=document.addEventListener?function(e,t,n){e.addEventListener(t,n,!1)}:function(e,t,n){e.attachEvent("on"+t,n)},i=this.obj;[].forEach.call(document.querySelectorAll("[target]"),function(e){n(e,"change",function(){var n=e.getAttribute("target");"checkbox"==this.type?i[n]=this.checked:"select"==this.type?i[n]=this.options[this.selectedIndex].value:i[n]=this.value,t(e)}),n(e,"keydown",function(){var n=e.getAttribute("target");"checkbox"==this.type?i[n]=this.checked:"select"==this.type?i[n]=this.options[this.selectedIndex].value:i[n]=this.value,t(e)}),n(e,"input",function(){var n=e.getAttribute("target");"checkbox"==this.type?i[n]=this.checked:"select"==this.type?i[n]=this.options[this.selectedIndex].value:i[n]=this.value,t(e)}),n(e,"paste",function(){var n=e.getAttribute("target");"checkbox"==this.type?i[n]=this.checked:"select"==this.type?i[n]=this.options[this.selectedIndex].value:i[n]=this.value,t(e)})})}},{key:"if",value:function _if(push){var _this3=this,if_push=function if_push(){for(var elements=document.querySelectorAll("[if]"),i=0;i2&&void 0!==arguments[2]?arguments[2]:"in";el=this.s(el);var text=el[0].innerHTML;el[0].innerHTML="";for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:.1;(e=this.s(e)[0]).style.opacity=1,function n(){(e.style.opacity-=t)<0?e.style.display="none":requestAnimationFrame(n)}()}},{key:"fadeIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.1,n=arguments[2];(e=this.s(e)[0]).style.opacity=0,e.style.display=n||"block",function n(){var i=parseFloat(e.style.opacity);(i+=t)>1||(e.style.opacity=i,requestAnimationFrame(n))}()}},{key:"dynamic",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250;window.setInterval(e,t)}},{key:"parent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(e=this.s(e))[0];for(var i in this.range(t))n=n.parentNode;return this.toNodeList(n)}},{key:"isNode",value:function(e){return"object"===("undefined"==typeof Node?"undefined":_typeof(Node))?e instanceof Node:e&&"object"===(void 0===e?"undefined":_typeof(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}},{key:"isElement",value:function(e){return"object"===("undefined"==typeof HTMLElement?"undefined":_typeof(HTMLElement))?e instanceof HTMLElement:e&&"object"===(void 0===e?"undefined":_typeof(e))&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName}},{key:"component",value:function(e,t){var n=function(e){function n(){_classCallCheck(this,n);var e=_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).call(this));return t(e),e}return _inherits(n,HTMLElement),n}();customElements.define(e,n)}},{key:"import",value:function(e,t){var n=document.createElement("script"),i=document.getElementsByTagName("script")[0];n.async=1,n.onload=n.onreadystatechange=function(e,i){(i||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n=void 0,i||t&&t())},n.src=e,i.parentNode.insertBefore(n,i)}},{key:"sleep",value:function(e){for(var t=(new Date).getTime()+e;(new Date).getTime()0?e.slice(t,e.length):e.slice(0,e.length+t)}},{key:"isIn",value:function(e,t){return!!e.includes(t)}},{key:"rmFromArray",value:function(e,t){var n=[];for(var i in e)0==t(i)&&n.push(e[i]);return n}},{key:"fn",get:function(){return DisplayJS.prototype}}]),DisplayJS}();"function"==typeof define&&define.amd?define(function(){return new DisplayJS}):"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=new DisplayJS),exports.DisplayJS=new DisplayJS):"undefined"!=typeof global&&(global.DisplayJS=new DisplayJS); \ No newline at end of file +"use strict";function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_createClass=function(){function e(e,t){for(var n=0;n/g,i=/'/g,o=/"/g;return e.toString().replace(t,"<").replace(n,">").replace(i,"'").replace(o,""")}},{key:"xssURI",value:function(e){return encodeURI(e)}},{key:"target",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){e.var()},n=document.addEventListener?function(e,t,n){e.addEventListener(t,n,!1)}:function(e,t,n){e.attachEvent("on"+t,n)},i=this.obj;[].forEach.call(document.querySelectorAll("[target]"),function(e){n(e,"change",function(){var n=e.getAttribute("target");"checkbox"==this.type?i[n]=this.checked:"select"==this.type?i[n]=this.options[this.selectedIndex].value:i[n]=this.value,t(e)}),n(e,"keydown",function(){var n=e.getAttribute("target");"checkbox"==this.type?i[n]=this.checked:"select"==this.type?i[n]=this.options[this.selectedIndex].value:i[n]=this.value,t(e)}),n(e,"input",function(){var n=e.getAttribute("target");"checkbox"==this.type?i[n]=this.checked:"select"==this.type?i[n]=this.options[this.selectedIndex].value:i[n]=this.value,t(e)}),n(e,"paste",function(){var n=e.getAttribute("target");"checkbox"==this.type?i[n]=this.checked:"select"==this.type?i[n]=this.options[this.selectedIndex].value:i[n]=this.value,t(e)})})}},{key:"if",value:function _if(push){var _this3=this,if_push=function if_push(){for(var elements=document.querySelectorAll("[if]"),i=0;i1&&void 0!==arguments[1]?arguments[1]:.1;(e=this.s(e)[0]).style.opacity=1,function n(){(e.style.opacity-=t)<0?e.style.display="none":requestAnimationFrame(n)}()}},{key:"fadeIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.1,n=arguments[2];(e=this.s(e)[0]).style.opacity=0,e.style.display=n||"block",function n(){var i=parseFloat(e.style.opacity);(i+=t)>1||(e.style.opacity=i,requestAnimationFrame(n))}()}},{key:"dynamic",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250;window.setInterval(e,t)}},{key:"parent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(e=this.s(e))[0];for(var i in this.range(t))n=n.parentNode;return this.toNodeList(n)}},{key:"isNode",value:function(e){return"object"===("undefined"==typeof Node?"undefined":_typeof(Node))?e instanceof Node:e&&"object"===(void 0===e?"undefined":_typeof(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}},{key:"isElement",value:function(e){return"object"===("undefined"==typeof HTMLElement?"undefined":_typeof(HTMLElement))?e instanceof HTMLElement:e&&"object"===(void 0===e?"undefined":_typeof(e))&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName}},{key:"component",value:function(e,t){var n=function(e){function n(){_classCallCheck(this,n);var e=_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).call(this));return t(e),e}return _inherits(n,HTMLElement),n}();customElements.define(e,n)}},{key:"import",value:function(e,t){var n=document.createElement("script"),i=document.getElementsByTagName("script")[0];n.async=1,n.onload=n.onreadystatechange=function(e,i){(i||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n=void 0,i||t&&t())},n.src=e,i.parentNode.insertBefore(n,i)}},{key:"sleep",value:function(e){for(var t=(new Date).getTime()+e;(new Date).getTime()0?e.slice(t,e.length):e.slice(0,e.length+t)}},{key:"isIn",value:function(e,t){return!!e.includes(t)}},{key:"rmFromArray",value:function(e,t){var n=[];for(var i in e)0==t(i)&&n.push(e[i]);return n}},{key:"fn",get:function(){return DisplayJS.prototype}}]),DisplayJS}();"function"==typeof define&&define.amd?define(function(){return new DisplayJS}):"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=new DisplayJS),exports.DisplayJS=new DisplayJS):"undefined"!=typeof global&&(global.DisplayJS=new DisplayJS); \ No newline at end of file diff --git a/src/base.js b/src/base.js index 55bbc31..40edab2 100644 --- a/src/base.js +++ b/src/base.js @@ -188,7 +188,7 @@ class DisplayJS { return list; } // custom repeat function - repeat(el, object, position="in") { + repeat(el, object) { el = this.s(el); const text = el[0].innerHTML; el[0].innerHTML = "" @@ -196,7 +196,7 @@ class DisplayJS { function interpolate(str) { return function interpolate(o) { return str.replace(/{([^{}]*)}/g, function(a, b) { - const data = o; + window["data"] = o; let r = eval(b) return r });