Merge pull request 'feature/frontlog' (#10) from feature/frontlog into master
Reviewed-on: #10
This commit is contained in:
commit
0d3289a900
46
frontlog.css
Normal file
46
frontlog.css
Normal file
@ -0,0 +1,46 @@
|
||||
frontlog {
|
||||
position: fixed;
|
||||
min-width: 200px;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
flogelem {
|
||||
display:block;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
max-height: 0;
|
||||
margin-bottom: 0;
|
||||
padding: 0;
|
||||
opacity: 0;
|
||||
position: relative;
|
||||
bottom: 0;
|
||||
-webkit-transition: max-height 3s, margin-bottom 3s, padding 3s,opacity 3s, bottom 3s;
|
||||
-moz-transition: max-height 3s, margin-bottom 3s, padding 3s,opacity 3s, bottom 3s;
|
||||
transition: max-height 3s, margin-bottom 3s, padding 3s,opacity 3s, bottom 3s;
|
||||
}
|
||||
|
||||
.flshow {
|
||||
max-height: 200px!important;
|
||||
margin-bottom: 1em;
|
||||
padding: 4px;
|
||||
opacity: 1;
|
||||
}
|
||||
.flvanish {
|
||||
position: relative;
|
||||
bottom: 3em;
|
||||
max-height: 0 !important;
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
fltitle {
|
||||
display: block;
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
flogelem img {
|
||||
float: left;
|
||||
width: 25px;
|
||||
}
|
||||
68
frontlog.js
Normal file
68
frontlog.js
Normal file
@ -0,0 +1,68 @@
|
||||
let frontlogList = [];
|
||||
let frontlogMaxEl = document.body.dataset['frontlog']||3;
|
||||
let frontlog = document.createElement('frontlog');
|
||||
document.body.appendChild(frontlog);
|
||||
|
||||
let frontlogVanish = function(elem) {
|
||||
elem.classList.add('flvanish');
|
||||
setTimeout(function() {
|
||||
elem.remove();
|
||||
let elems = document.getElementsByTagName('flogelem');
|
||||
if(elems.length < frontlogMaxEl && frontlogList.length) {
|
||||
let p = frontlogList.shift();
|
||||
frontlogPipe(p.title,p.icon,p.msg,p.col,p.time);
|
||||
}
|
||||
},3100);
|
||||
}
|
||||
|
||||
let frontlogAdd = function(title,icon,msg,col,time) {
|
||||
let elems = document.getElementsByTagName('flogelem');
|
||||
if(elems.length < frontlogMaxEl) {
|
||||
frontlogPipe(title,icon,msg,col,time);
|
||||
}else{
|
||||
let pElem = {"title":title,"icon":icon,"msg":msg,"col":col,"time":time};
|
||||
frontlogList.push(pElem);
|
||||
}
|
||||
}
|
||||
|
||||
let frontlogPipe = function(title,icon,msg,col, time) {
|
||||
let elem = document.createElement('flogelem');
|
||||
{
|
||||
let elemid = 'fl_';
|
||||
{
|
||||
let ch = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let chl = ch.length;
|
||||
for ( let i = 0; i < 16; i++ ) {
|
||||
elemid += ch.charAt(Math.floor(Math.random() * chl));
|
||||
}
|
||||
}
|
||||
elem.id = elemid;
|
||||
let flicon = document.createElement('img');
|
||||
flicon.src = icon;
|
||||
elem.appendChild(flicon);
|
||||
|
||||
let fltitle = document.createElement('fltitle');
|
||||
fltitle.innerText = title;
|
||||
elem.appendChild(fltitle);
|
||||
|
||||
let flmsg = document.createElement('flmsg');
|
||||
flmsg.innerText = msg;
|
||||
elem.appendChild(flmsg);
|
||||
}
|
||||
|
||||
elem.style = 'border-color: '+col+';';
|
||||
elem.addEventListener('click',function(ev){
|
||||
let tg = ev.target;
|
||||
if(tg.tagName.toLowerCase() != 'flogelem') {
|
||||
tg = ev.target.parentNode;
|
||||
}
|
||||
frontlogVanish(tg);
|
||||
});
|
||||
setTimeout(function(){
|
||||
frontlogVanish(elem);
|
||||
},time*1000)
|
||||
frontlog.appendChild(elem);
|
||||
setTimeout(function(){
|
||||
elem.classList.add('flshow');
|
||||
},10);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user