Limited alerts to max of 5
This commit is contained in:
parent
8a8ceef67b
commit
5b94d3dc51
5
public/dist/scripts/app-all.js
vendored
5
public/dist/scripts/app-all.js
vendored
|
@ -2397,8 +2397,9 @@ children[prop]=template.cloneNode(true);element.appendChild(children[prop]);(ind
|
|||
container.set('$index',originalIndex,true,false);container.set('$prefix',originalPrefix,true,false);container.set('$as',originalAs,true,false);element.dispatchEvent(new Event('looped'));};let template=(element.children.length===1)?element.children[0]:window.document.createElement('li');echo();container.bind(element,expr+'.length',echo);let path=(expr+'.length').split('.');while(path.length){container.bind(element,path.join('.'),echo);path.pop();}}});window.ls.container.get('view').add({selector:'data-ls-template',template:false,repeat:true,controller:function(element,view,http,expression,document){let template=expression.parse(element.getAttribute('data-ls-template'));let type=element.getAttribute('data-type')||'url';element.innerHTML='';if('script'===type){let inlineTemplate=document.getElementById(template);if(inlineTemplate&&inlineTemplate.innerHTML){element.innerHTML=inlineTemplate.innerHTML;element.dispatchEvent(new CustomEvent('template-loaded',{bubbles:true,cancelable:false}));}
|
||||
else{element.innerHTML='<span style="color: red">Missing template "'+template+'"</span>';}
|
||||
return;}
|
||||
http.get(template).then(function(element){return function(data){element.innerHTML=data;view.render(element);element.dispatchEvent(new CustomEvent('template-loaded',{bubbles:true,cancelable:false}));}}(element),function(){throw new Error('Failed loading template');});}});window.ls.error=function(){return function(error){console.error("ERROR-APP",error);};};window.addEventListener("error",function(event){console.error("ERROR-EVENT:",event.error.message,event.error.stack);});document.addEventListener("logout",function(){window.location="/auth/signin";});document.addEventListener("http-get-401",function(){document.dispatchEvent(new CustomEvent("logout"));},true);(function(window){"use strict";window.ls.container.set('alerts',function(window){return{list:[],counter:0,add:function(message,time){var scope=this;message.id=this.counter++;scope.list.unshift(message);if(time>0){window.setTimeout(function(message){return function(){scope.remove(message.id)}}(message),time);}
|
||||
return message.id;},remove:function(id){let scope=this;for(let index=0;index<scope.list.length;index++){let obj=scope.list[index];if(obj.id===parseInt(id)){if(typeof obj.callback==="function"){obj.callback();}
|
||||
http.get(template).then(function(element){return function(data){element.innerHTML=data;view.render(element);element.dispatchEvent(new CustomEvent('template-loaded',{bubbles:true,cancelable:false}));}}(element),function(){throw new Error('Failed loading template');});}});window.ls.error=function(){return function(error){console.error("ERROR-APP",error);};};window.addEventListener("error",function(event){console.error("ERROR-EVENT:",event.error.message,event.error.stack);});document.addEventListener("logout",function(){window.location="/auth/signin";});document.addEventListener("http-get-401",function(){document.dispatchEvent(new CustomEvent("logout"));},true);(function(window){"use strict";window.ls.container.set('alerts',function(window){return{list:[],ids:0,counter:0,max:5,add:function(message,time){var scope=this;message.id=scope.ids++;scope.counter++;scope.list.unshift(message);if(scope.counter>scope.max){scope.list.pop();scope.counter--;}
|
||||
if(time>0){window.setTimeout(function(message){return function(){scope.remove(message.id)}}(message),time);}
|
||||
return message.id;},remove:function(id){let scope=this;for(let index=0;index<scope.list.length;index++){let obj=scope.list[index];if(obj.id===parseInt(id)){scope.counter--;if(typeof obj.callback==="function"){obj.callback();}
|
||||
scope.list.splice(index,1);};}}};},true,true);})(window);(function(window){"use strict";window.ls.container.set('console',function(window){var sdk=new window.Appwrite();sdk.setEndpoint(APP_ENV.API).setProject('console').setLocale(APP_ENV.LOCALE);return sdk;},true);})(window);(function(window){"use strict";window.ls.container.set('date',function(){function format(format,timestamp){var jsdate,f
|
||||
var txtWords=['Sun','Mon','Tues','Wednes','Thurs','Fri','Satur','January','February','March','April','May','June','July','August','September','October','November','December']
|
||||
var formatChr=/\\?(.?)/gi
|
||||
|
|
5
public/dist/scripts/app.js
vendored
5
public/dist/scripts/app.js
vendored
|
@ -123,8 +123,9 @@ children[prop]=template.cloneNode(true);element.appendChild(children[prop]);(ind
|
|||
container.set('$index',originalIndex,true,false);container.set('$prefix',originalPrefix,true,false);container.set('$as',originalAs,true,false);element.dispatchEvent(new Event('looped'));};let template=(element.children.length===1)?element.children[0]:window.document.createElement('li');echo();container.bind(element,expr+'.length',echo);let path=(expr+'.length').split('.');while(path.length){container.bind(element,path.join('.'),echo);path.pop();}}});window.ls.container.get('view').add({selector:'data-ls-template',template:false,repeat:true,controller:function(element,view,http,expression,document){let template=expression.parse(element.getAttribute('data-ls-template'));let type=element.getAttribute('data-type')||'url';element.innerHTML='';if('script'===type){let inlineTemplate=document.getElementById(template);if(inlineTemplate&&inlineTemplate.innerHTML){element.innerHTML=inlineTemplate.innerHTML;element.dispatchEvent(new CustomEvent('template-loaded',{bubbles:true,cancelable:false}));}
|
||||
else{element.innerHTML='<span style="color: red">Missing template "'+template+'"</span>';}
|
||||
return;}
|
||||
http.get(template).then(function(element){return function(data){element.innerHTML=data;view.render(element);element.dispatchEvent(new CustomEvent('template-loaded',{bubbles:true,cancelable:false}));}}(element),function(){throw new Error('Failed loading template');});}});window.ls.error=function(){return function(error){console.error("ERROR-APP",error);};};window.addEventListener("error",function(event){console.error("ERROR-EVENT:",event.error.message,event.error.stack);});document.addEventListener("logout",function(){window.location="/auth/signin";});document.addEventListener("http-get-401",function(){document.dispatchEvent(new CustomEvent("logout"));},true);(function(window){"use strict";window.ls.container.set('alerts',function(window){return{list:[],counter:0,add:function(message,time){var scope=this;message.id=this.counter++;scope.list.unshift(message);if(time>0){window.setTimeout(function(message){return function(){scope.remove(message.id)}}(message),time);}
|
||||
return message.id;},remove:function(id){let scope=this;for(let index=0;index<scope.list.length;index++){let obj=scope.list[index];if(obj.id===parseInt(id)){if(typeof obj.callback==="function"){obj.callback();}
|
||||
http.get(template).then(function(element){return function(data){element.innerHTML=data;view.render(element);element.dispatchEvent(new CustomEvent('template-loaded',{bubbles:true,cancelable:false}));}}(element),function(){throw new Error('Failed loading template');});}});window.ls.error=function(){return function(error){console.error("ERROR-APP",error);};};window.addEventListener("error",function(event){console.error("ERROR-EVENT:",event.error.message,event.error.stack);});document.addEventListener("logout",function(){window.location="/auth/signin";});document.addEventListener("http-get-401",function(){document.dispatchEvent(new CustomEvent("logout"));},true);(function(window){"use strict";window.ls.container.set('alerts',function(window){return{list:[],ids:0,counter:0,max:5,add:function(message,time){var scope=this;message.id=scope.ids++;scope.counter++;scope.list.unshift(message);if(scope.counter>scope.max){scope.list.pop();scope.counter--;}
|
||||
if(time>0){window.setTimeout(function(message){return function(){scope.remove(message.id)}}(message),time);}
|
||||
return message.id;},remove:function(id){let scope=this;for(let index=0;index<scope.list.length;index++){let obj=scope.list[index];if(obj.id===parseInt(id)){scope.counter--;if(typeof obj.callback==="function"){obj.callback();}
|
||||
scope.list.splice(index,1);};}}};},true,true);})(window);(function(window){"use strict";window.ls.container.set('console',function(window){var sdk=new window.Appwrite();sdk.setEndpoint(APP_ENV.API).setProject('console').setLocale(APP_ENV.LOCALE);return sdk;},true);})(window);(function(window){"use strict";window.ls.container.set('date',function(){function format(format,timestamp){var jsdate,f
|
||||
var txtWords=['Sun','Mon','Tues','Wednes','Thurs','Fri','Satur','January','February','March','April','May','June','July','August','September','October','November','December']
|
||||
var formatChr=/\\?(.?)/gi
|
||||
|
|
|
@ -4,13 +4,22 @@
|
|||
window.ls.container.set('alerts', function (window) {
|
||||
return {
|
||||
list: [],
|
||||
ids: 0,
|
||||
counter: 0,
|
||||
max: 5,
|
||||
add: function (message, time) {
|
||||
var scope = this;
|
||||
|
||||
message.id = this.counter++;
|
||||
message.id = scope.ids++;
|
||||
|
||||
scope.counter++;
|
||||
|
||||
scope.list.unshift(message);
|
||||
|
||||
if(scope.counter > scope.max) {
|
||||
scope.list.pop();
|
||||
scope.counter--;
|
||||
}
|
||||
|
||||
if (time > 0) { // When 0 alert is unlimited in time
|
||||
window.setTimeout(function (message) {
|
||||
|
@ -20,6 +29,7 @@
|
|||
}(message), time);
|
||||
}
|
||||
|
||||
|
||||
return message.id;
|
||||
},
|
||||
remove: function (id) {
|
||||
|
@ -29,11 +39,14 @@
|
|||
let obj = scope.list[index];
|
||||
|
||||
if (obj.id === parseInt(id)) {
|
||||
scope.counter--;
|
||||
|
||||
if (typeof obj.callback === "function") {
|
||||
obj.callback();
|
||||
}
|
||||
|
||||
scope.list.splice(index, 1);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue