Skip to content

Commit

Permalink
ui-toast: hide countdown if infinite
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Oct 16, 2024
1 parent 48147c0 commit 22dfc6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions copyparty/web/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ html {
position: absolute;
height: 1px;
top: 1px;
right: 1%;
width: 99%;
right: 1px;
left: 1px;
animation: toastt var(--tmtime) steps(var(--tmstep)) forwards;
transform-origin: right;
}
Expand Down
23 changes: 14 additions & 9 deletions copyparty/web/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1527,21 +1527,26 @@ var toast = (function () {
if (sec)
te = setTimeout(r.hide, sec * 1000);

var tb = ebi('toastt');
if (same && delta < 1000 && tb) {
tb.style.animation = 'none';
tb.offsetHeight;
tb.style.animation = null;
if (same && delta < 1000) {
var tb = ebi('toastt');
if (tb) {
tb.style.animation = 'none';
tb.offsetHeight;
tb.style.animation = null;
}
return;
}

if (txt.indexOf('<body>') + 1)
txt = txt.slice(0, txt.indexOf('<')) + ' [...]';

setcvar('--tmtime', sec + 's');
setcvar('--tmstep', sec * 15);

obj.innerHTML = '<div id="toastt"></div><a href="#" id="toastc">x</a><div id="toastb">' + lf2br(txt) + '</div>';
var html = '';
if (sec) {
setcvar('--tmtime', sec + 's');
setcvar('--tmstep', sec * 15);
html += '<div id="toastt"></div>';
}
obj.innerHTML = html + '<a href="#" id="toastc">x</a><div id="toastb">' + lf2br(txt) + '</div>';
obj.className = cl;
sec += obj.offsetWidth;
obj.className += ' vis';
Expand Down

0 comments on commit 22dfc6e

Please sign in to comment.