litespeed.js
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -38,13 +38,3 @@ | ||
function set(name,value,days){let date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));let expires=(0<days)?'expires='+date.toUTCString():'expires=0';document.cookie=name+"="+value+";"+expires+";path=/";return this;} | ||
return{'get':get,'set':set}},true,false,false);Object.path=function(object,path,value){path=path.split('.');while(path.length>1){if(undefined===object){return null;} | ||
object=object[path.shift()];} | ||
if(undefined!==value){return object[path.shift()]=value;} | ||
if(undefined===object){return null;} | ||
return object[path.shift()];};if(!Array.prototype.includes){Array.prototype.includes=function(searchElement){'use strict';if(this==null){throw new TypeError('Array.prototype.includes called on null or undefined');} | ||
var O=Object(this);var len=parseInt(O.length,10)||0;if(len===0){return false;} | ||
var n=parseInt(arguments[1],10)||0;var k;if(n>=0){k=n;}else{k=len+n;if(k<0){k=0;}} | ||
var currentElement;while(k<len){currentElement=O[k];if(searchElement===currentElement||(searchElement!==searchElement&¤tElement!==currentElement)){return true;} | ||
k++;} | ||
return false;};} | ||
window.ls.container.set('view',function(http,container){let stock={};let execute=function(view,node,container){container.set('element',node,true,false,false);container.resolve(view.controller);if(true!==view.repeat){node.removeAttribute(view.selector);}};let parse=function(node,skip){if(node.attributes&&skip!==true){let attrs=[];let attrsLen=node.attributes.length;for(let x=0;x<attrsLen;x++){attrs.push(node.attributes[x].nodeName);} | ||
return{'get':get,'set':set}},true,false,false);window.ls.container.set('view',function(http,container){let stock={};let execute=function(view,node,container){container.set('element',node,true,false,false);container.resolve(view.controller);if(true!==view.repeat){node.removeAttribute(view.selector);}};let parse=function(node,skip){if(node.attributes&&skip!==true){let attrs=[];let attrsLen=node.attributes.length;for(let x=0;x<attrsLen;x++){attrs.push(node.attributes[x].nodeName);} | ||
if(1!==node.nodeType){return;} | ||
@@ -81,5 +71,4 @@ if(attrs&&attrsLen){for(let x=0;x<attrsLen;x++){if(node.$lsSkip===true){break;} | ||
return value.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/\"/g,'"').replace(/\'/g,''').replace(/\//g,'/');});window.ls=window.ls||{};window.ls.container.set('window',window,true,false,false).set('document',window.document,true,false,false).set('element',window.document,true,false,false);window.ls.run=function(window){try{this.view.render(window.document);} | ||
catch(error){let handler=window.ls.container.resolve(this.error);handler(error);}};window.ls.error=function(){return function(error){console.error('ls-error',error.message,error.stack,error.toString());}};window.ls.router=window.ls.container.get('router');window.ls.view=window.ls.container.get('view');window.ls.filter=window.ls.container.get('filter');window.ls.container.get('view').add({selector:'data-ls-router',controller:function(element,window,document,view,router){let firstFromServer=(element.getAttribute('data-first-from-server')==='true');let scope={selector:'data-ls-scope',template:false,repeat:true,controller:function(){},state:true};let scopeElement=document.createElement('div');let init=function(route){window.scrollTo(0,0);if(window.document.body.scrollTo){window.document.body.scrollTo(0,0);} | ||
catch(error){let handler=window.ls.container.resolve(this.error);handler(error);}};window.ls.error=function(){return function(error){console.error('ls-error',error.message,error.stack,error.toString());}};window.ls.router=window.ls.container.get('router');window.ls.view=window.ls.container.get('view');window.ls.filter=window.ls.container.get('filter');window.ls.container.get('view').add({selector:'data-ls-router',controller:function(element,window,document,view,router){let firstFromServer=(element.getAttribute('data-first-from-server')==='true');let scope={selector:'data-ls-scope',template:false,repeat:true,controller:function(){},};let scopeElement=document.createElement('div');let init=function(route){window.scrollTo(0,0);if(window.document.body.scrollTo){window.document.body.scrollTo(0,0);} | ||
router.reset();if(null===route){return;} | ||
scope.protected=(undefined!==route.view.protected)?route.view.protected:false;if(scope.protected&&(null===router.getPrevious())){throw new Error('CSRF protection');} | ||
scope.template=(undefined!==route.view.template)?route.view.template:null;scope.controller=(undefined!==route.view.controller)?route.view.controller:function(){};document.dispatchEvent(new CustomEvent('state-change'));if(firstFromServer&&null===router.getPrevious()){scope.template='';} | ||
@@ -98,4 +87,3 @@ else if(null!==router.getPrevious()){view.render(element);} | ||
window.history.pushState({},'Unknown',target.href);} | ||
init(route);return true;});window.addEventListener('popstate',function(){let route=router.match(window.location);if(router.getPrevious()&&router.getPrevious().view&&(router.getPrevious().view.scope!==route.view.scope)){window.location.reload();return false;} | ||
init(route);});init(router.match(window.location));}});window.ls.container.get('view').add({selector:'data-ls-attrs',controller:function(element,expression,container,$as,$prefix){let attrs=element.getAttribute('data-ls-attrs').trim().split(',');let paths=[];let check=function(){for(let i=0;i<attrs.length;i++){let attr=attrs[i].split('=');let key=(attr[0])?expression.parse(attr[0],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());let value=(attr[1])?expression.parse(attr[1],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());if(!key){return null;} | ||
init(route);return true;});window.addEventListener('popstate',function(){init(router.match(window.location));});window.addEventListener('hashchange',function(){init(router.match(window.location));});init(router.match(window.location));}});window.ls.container.get('view').add({selector:'data-ls-attrs',controller:function(element,expression,container,$as,$prefix){let attrs=element.getAttribute('data-ls-attrs').trim().split(',');let paths=[];let check=function(){for(let i=0;i<attrs.length;i++){let attr=attrs[i].split('=');let key=(attr[0])?expression.parse(attr[0],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());let value=(attr[1])?expression.parse(attr[1],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());if(!key){return null;} | ||
element.setAttribute(key,value);}};check();for(let i=0;i<paths.length;i++){container.bind(element,paths[i],check);}}});window.ls.container.get('view').add({selector:'data-ls-bind',controller:function(element,expression,container,$prefix,$as){let echo=function(value,bind=true){if(element.tagName==='INPUT'||element.tagName==='SELECT'||element.tagName==='BUTTON'||element.tagName==='TEXTAREA'){let type=element.getAttribute('type');if('radio'===type){if(value.toString()===element.value){element.setAttribute('checked','checked');} | ||
@@ -102,0 +90,0 @@ else{element.removeAttribute('checked');}} |
@@ -38,13 +38,3 @@ | ||
function set(name,value,days){let date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));let expires=(0<days)?'expires='+date.toUTCString():'expires=0';document.cookie=name+"="+value+";"+expires+";path=/";return this;} | ||
return{'get':get,'set':set}},true,false,false);Object.path=function(object,path,value){path=path.split('.');while(path.length>1){if(undefined===object){return null;} | ||
object=object[path.shift()];} | ||
if(undefined!==value){return object[path.shift()]=value;} | ||
if(undefined===object){return null;} | ||
return object[path.shift()];};if(!Array.prototype.includes){Array.prototype.includes=function(searchElement){'use strict';if(this==null){throw new TypeError('Array.prototype.includes called on null or undefined');} | ||
var O=Object(this);var len=parseInt(O.length,10)||0;if(len===0){return false;} | ||
var n=parseInt(arguments[1],10)||0;var k;if(n>=0){k=n;}else{k=len+n;if(k<0){k=0;}} | ||
var currentElement;while(k<len){currentElement=O[k];if(searchElement===currentElement||(searchElement!==searchElement&¤tElement!==currentElement)){return true;} | ||
k++;} | ||
return false;};} | ||
window.ls.container.set('view',function(http,container){let stock={};let execute=function(view,node,container){container.set('element',node,true,false,false);container.resolve(view.controller);if(true!==view.repeat){node.removeAttribute(view.selector);}};let parse=function(node,skip){if(node.attributes&&skip!==true){let attrs=[];let attrsLen=node.attributes.length;for(let x=0;x<attrsLen;x++){attrs.push(node.attributes[x].nodeName);} | ||
return{'get':get,'set':set}},true,false,false);window.ls.container.set('view',function(http,container){let stock={};let execute=function(view,node,container){container.set('element',node,true,false,false);container.resolve(view.controller);if(true!==view.repeat){node.removeAttribute(view.selector);}};let parse=function(node,skip){if(node.attributes&&skip!==true){let attrs=[];let attrsLen=node.attributes.length;for(let x=0;x<attrsLen;x++){attrs.push(node.attributes[x].nodeName);} | ||
if(1!==node.nodeType){return;} | ||
@@ -98,5 +88,4 @@ if(attrs&&attrsLen){for(let x=0;x<attrsLen;x++){if(node.$lsSkip===true){break;} | ||
return value.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/\"/g,'"').replace(/\'/g,''').replace(/\//g,'/');});window.ls=window.ls||{};window.ls.container.set('window',window,true,false,false).set('document',window.document,true,false,false).set('element',window.document,true,false,false);window.ls.run=function(window){try{this.view.render(window.document);} | ||
catch(error){let handler=window.ls.container.resolve(this.error);handler(error);}};window.ls.error=function(){return function(error){console.error('ls-error',error.message,error.stack,error.toString());}};window.ls.router=window.ls.container.get('router');window.ls.view=window.ls.container.get('view');window.ls.filter=window.ls.container.get('filter');window.ls.container.get('view').add({selector:'data-ls-router',controller:function(element,window,document,view,router){let firstFromServer=(element.getAttribute('data-first-from-server')==='true');let scope={selector:'data-ls-scope',template:false,repeat:true,controller:function(){},state:true};let scopeElement=document.createElement('div');let init=function(route){window.scrollTo(0,0);if(window.document.body.scrollTo){window.document.body.scrollTo(0,0);} | ||
catch(error){let handler=window.ls.container.resolve(this.error);handler(error);}};window.ls.error=function(){return function(error){console.error('ls-error',error.message,error.stack,error.toString());}};window.ls.router=window.ls.container.get('router');window.ls.view=window.ls.container.get('view');window.ls.filter=window.ls.container.get('filter');window.ls.container.get('view').add({selector:'data-ls-router',controller:function(element,window,document,view,router){let firstFromServer=(element.getAttribute('data-first-from-server')==='true');let scope={selector:'data-ls-scope',template:false,repeat:true,controller:function(){},};let scopeElement=document.createElement('div');let init=function(route){window.scrollTo(0,0);if(window.document.body.scrollTo){window.document.body.scrollTo(0,0);} | ||
router.reset();if(null===route){return;} | ||
scope.protected=(undefined!==route.view.protected)?route.view.protected:false;if(scope.protected&&(null===router.getPrevious())){throw new Error('CSRF protection');} | ||
scope.template=(undefined!==route.view.template)?route.view.template:null;scope.controller=(undefined!==route.view.controller)?route.view.controller:function(){};document.dispatchEvent(new CustomEvent('state-change'));if(firstFromServer&&null===router.getPrevious()){scope.template='';} | ||
@@ -115,4 +104,3 @@ else if(null!==router.getPrevious()){view.render(element);} | ||
window.history.pushState({},'Unknown',target.href);} | ||
init(route);return true;});window.addEventListener('popstate',function(){let route=router.match(window.location);if(router.getPrevious()&&router.getPrevious().view&&(router.getPrevious().view.scope!==route.view.scope)){window.location.reload();return false;} | ||
init(route);});init(router.match(window.location));}});window.ls.container.get('view').add({selector:'data-ls-attrs',controller:function(element,expression,container,$as,$prefix){let attrs=element.getAttribute('data-ls-attrs').trim().split(',');let paths=[];let check=function(){for(let i=0;i<attrs.length;i++){let attr=attrs[i].split('=');let key=(attr[0])?expression.parse(attr[0],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());let value=(attr[1])?expression.parse(attr[1],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());if(!key){return null;} | ||
init(route);return true;});window.addEventListener('popstate',function(){init(router.match(window.location));});window.addEventListener('hashchange',function(){init(router.match(window.location));});init(router.match(window.location));}});window.ls.container.get('view').add({selector:'data-ls-attrs',controller:function(element,expression,container,$as,$prefix){let attrs=element.getAttribute('data-ls-attrs').trim().split(',');let paths=[];let check=function(){for(let i=0;i<attrs.length;i++){let attr=attrs[i].split('=');let key=(attr[0])?expression.parse(attr[0],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());let value=(attr[1])?expression.parse(attr[1],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());if(!key){return null;} | ||
element.setAttribute(key,value);}};check();for(let i=0;i<paths.length;i++){container.bind(element,paths[i],check);}}});window.ls.container.get('view').add({selector:'data-ls-if',controller:function(element,expression,container,$as,$prefix){let result='';let syntax=element.getAttribute('data-ls-if')||'';let debug=element.getAttribute('data-debug')||false;let paths=[];let check=function(){if(debug){console.info('debug-ls-if',expression.parse(syntax,'undefined',$as,$prefix));} | ||
@@ -119,0 +107,0 @@ try{result=!!(eval(expression.parse(syntax,'undefined',$as,$prefix).replace(/(\r\n|\n|\r)/gm,' ')));} |
@@ -38,13 +38,3 @@ | ||
function set(name,value,days){let date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));let expires=(0<days)?'expires='+date.toUTCString():'expires=0';document.cookie=name+"="+value+";"+expires+";path=/";return this;} | ||
return{'get':get,'set':set}},true,false,false);Object.path=function(object,path,value){path=path.split('.');while(path.length>1){if(undefined===object){return null;} | ||
object=object[path.shift()];} | ||
if(undefined!==value){return object[path.shift()]=value;} | ||
if(undefined===object){return null;} | ||
return object[path.shift()];};if(!Array.prototype.includes){Array.prototype.includes=function(searchElement){'use strict';if(this==null){throw new TypeError('Array.prototype.includes called on null or undefined');} | ||
var O=Object(this);var len=parseInt(O.length,10)||0;if(len===0){return false;} | ||
var n=parseInt(arguments[1],10)||0;var k;if(n>=0){k=n;}else{k=len+n;if(k<0){k=0;}} | ||
var currentElement;while(k<len){currentElement=O[k];if(searchElement===currentElement||(searchElement!==searchElement&¤tElement!==currentElement)){return true;} | ||
k++;} | ||
return false;};} | ||
window.ls.container.set('view',function(http,container){let stock={};let execute=function(view,node,container){container.set('element',node,true,false,false);container.resolve(view.controller);if(true!==view.repeat){node.removeAttribute(view.selector);}};let parse=function(node,skip){if(node.attributes&&skip!==true){let attrs=[];let attrsLen=node.attributes.length;for(let x=0;x<attrsLen;x++){attrs.push(node.attributes[x].nodeName);} | ||
return{'get':get,'set':set}},true,false,false);window.ls.container.set('view',function(http,container){let stock={};let execute=function(view,node,container){container.set('element',node,true,false,false);container.resolve(view.controller);if(true!==view.repeat){node.removeAttribute(view.selector);}};let parse=function(node,skip){if(node.attributes&&skip!==true){let attrs=[];let attrsLen=node.attributes.length;for(let x=0;x<attrsLen;x++){attrs.push(node.attributes[x].nodeName);} | ||
if(1!==node.nodeType){return;} | ||
@@ -81,5 +71,4 @@ if(attrs&&attrsLen){for(let x=0;x<attrsLen;x++){if(node.$lsSkip===true){break;} | ||
return value.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/\"/g,'"').replace(/\'/g,''').replace(/\//g,'/');});window.ls=window.ls||{};window.ls.container.set('window',window,true,false,false).set('document',window.document,true,false,false).set('element',window.document,true,false,false);window.ls.run=function(window){try{this.view.render(window.document);} | ||
catch(error){let handler=window.ls.container.resolve(this.error);handler(error);}};window.ls.error=function(){return function(error){console.error('ls-error',error.message,error.stack,error.toString());}};window.ls.router=window.ls.container.get('router');window.ls.view=window.ls.container.get('view');window.ls.filter=window.ls.container.get('filter');window.ls.container.get('view').add({selector:'data-ls-router',controller:function(element,window,document,view,router){let firstFromServer=(element.getAttribute('data-first-from-server')==='true');let scope={selector:'data-ls-scope',template:false,repeat:true,controller:function(){},state:true};let scopeElement=document.createElement('div');let init=function(route){window.scrollTo(0,0);if(window.document.body.scrollTo){window.document.body.scrollTo(0,0);} | ||
catch(error){let handler=window.ls.container.resolve(this.error);handler(error);}};window.ls.error=function(){return function(error){console.error('ls-error',error.message,error.stack,error.toString());}};window.ls.router=window.ls.container.get('router');window.ls.view=window.ls.container.get('view');window.ls.filter=window.ls.container.get('filter');window.ls.container.get('view').add({selector:'data-ls-router',controller:function(element,window,document,view,router){let firstFromServer=(element.getAttribute('data-first-from-server')==='true');let scope={selector:'data-ls-scope',template:false,repeat:true,controller:function(){},};let scopeElement=document.createElement('div');let init=function(route){window.scrollTo(0,0);if(window.document.body.scrollTo){window.document.body.scrollTo(0,0);} | ||
router.reset();if(null===route){return;} | ||
scope.protected=(undefined!==route.view.protected)?route.view.protected:false;if(scope.protected&&(null===router.getPrevious())){throw new Error('CSRF protection');} | ||
scope.template=(undefined!==route.view.template)?route.view.template:null;scope.controller=(undefined!==route.view.controller)?route.view.controller:function(){};document.dispatchEvent(new CustomEvent('state-change'));if(firstFromServer&&null===router.getPrevious()){scope.template='';} | ||
@@ -98,4 +87,3 @@ else if(null!==router.getPrevious()){view.render(element);} | ||
window.history.pushState({},'Unknown',target.href);} | ||
init(route);return true;});window.addEventListener('popstate',function(){let route=router.match(window.location);if(router.getPrevious()&&router.getPrevious().view&&(router.getPrevious().view.scope!==route.view.scope)){window.location.reload();return false;} | ||
init(route);});init(router.match(window.location));}});window.ls.container.get('view').add({selector:'data-ls-attrs',controller:function(element,expression,container,$as,$prefix){let attrs=element.getAttribute('data-ls-attrs').trim().split(',');let paths=[];let check=function(){for(let i=0;i<attrs.length;i++){let attr=attrs[i].split('=');let key=(attr[0])?expression.parse(attr[0],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());let value=(attr[1])?expression.parse(attr[1],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());if(!key){return null;} | ||
init(route);return true;});window.addEventListener('popstate',function(){init(router.match(window.location));});window.addEventListener('hashchange',function(){init(router.match(window.location));});init(router.match(window.location));}});window.ls.container.get('view').add({selector:'data-ls-attrs',controller:function(element,expression,container,$as,$prefix){let attrs=element.getAttribute('data-ls-attrs').trim().split(',');let paths=[];let check=function(){for(let i=0;i<attrs.length;i++){let attr=attrs[i].split('=');let key=(attr[0])?expression.parse(attr[0],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());let value=(attr[1])?expression.parse(attr[1],null,$as,$prefix):null;paths=paths.concat(expression.getPaths());if(!key){return null;} | ||
element.setAttribute(key,value);}};check();for(let i=0;i<paths.length;i++){container.bind(element,paths[i],check);}}});window.ls.container.get('view').add({selector:'data-ls-bind',controller:function(element,expression,container,$prefix,$as){let echo=function(value,bind=true){if(element.tagName==='INPUT'||element.tagName==='SELECT'||element.tagName==='BUTTON'||element.tagName==='TEXTAREA'){let type=element.getAttribute('type');if('radio'===type){if(value.toString()===element.value){element.setAttribute('checked','checked');} | ||
@@ -102,0 +90,0 @@ else{element.removeAttribute('checked');}} |
@@ -16,3 +16,2 @@ // Include gulp | ||
'src/services/cookie.js', | ||
'src/services/object.js', | ||
'src/services/view.js', | ||
@@ -41,3 +40,2 @@ 'src/services/router.js', | ||
'src/services/cookie.js', | ||
'src/services/object.js', | ||
'src/services/view.js', | ||
@@ -44,0 +42,0 @@ 'src/services/deprecated/form.js', |
{ | ||
"name": "litespeed.js", | ||
"version": "v0.2.8", | ||
"version": "v0.2.9", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "main": "gulpfile.js", |
@@ -28,3 +28,3 @@ <p> | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/litespeed.js@v0.2.8"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/litespeed.js@v0.2.9"></script> | ||
``` | ||
@@ -31,0 +31,0 @@ |
@@ -10,3 +10,2 @@ window.ls.container.get('view').add({ | ||
controller: function() {}, | ||
state: true | ||
}; | ||
@@ -27,9 +26,2 @@ let scopeElement = document.createElement('div'); | ||
// Merge | ||
scope.protected = (undefined !== route.view.protected) ? route.view.protected : false; | ||
if(scope.protected && (null === router.getPrevious())) { // Avoid protected link to be used for CSRF attacks | ||
throw new Error('CSRF protection'); | ||
} | ||
scope.template = (undefined !== route.view.template) ? route.view.template : null; | ||
@@ -119,10 +111,7 @@ scope.controller = (undefined !== route.view.controller) ? route.view.controller : function() {}; | ||
window.addEventListener('popstate', function() { // Handle back button behavior | ||
let route = router.match(window.location); | ||
init(router.match(window.location)); | ||
}); | ||
if(router.getPrevious() && router.getPrevious().view && (router.getPrevious().view.scope !== route.view.scope)) { | ||
window.location.reload(); | ||
return false; | ||
} | ||
init(route); | ||
window.addEventListener('hashchange', function() { // Handle hash behavior | ||
init(router.match(window.location)); | ||
}); | ||
@@ -129,0 +118,0 @@ |
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
320608
77
2490