Skip to content

Commit

Permalink
Improve notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceK33z committed Dec 12, 2016
1 parent e813e8b commit c4a1c9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
font-size: 20px;
padding: 10px;
border-radius: 4px;
z-index: 1000;
z-index: 999000;
}

.movieo-to-plex-warning {
Expand Down
15 changes: 13 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@ function init() {
}
}

let notificationTimeout;

function showNotification(state, text) {
const el = document.createElement('div')
if (notificationTimeout) {
clearTimeout(notificationTimeout);
notificationTimeout = null;
}
const existingEl = document.querySelector('.movieo-to-plex-notification');
if (existingEl) {
document.body.removeChild(existingEl);
}

const el = document.createElement('div');
el.classList.add('movieo-to-plex-notification');
if (state === 'warning') {
el.classList.add('movieo-to-plex-warning');
}
el.innerHTML = text;
document.body.appendChild(el);
setTimeout(() => {
notificationTimeout = setTimeout(() => {
document.body.removeChild(el);
}, 5000);
}
Expand Down

0 comments on commit c4a1c9d

Please sign in to comment.