diff --git a/css/glowingbear.css b/css/glowingbear.css index 312ef04..62a10fb 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -708,6 +708,30 @@ img.emojione { width: auto; } +#toast { + position: fixed; + left: 50%; + bottom: 50px; + width: 250px; + margin-left: -125px; + + text-align: center; + border-radius: 3px; + padding: 10px 15px; + z-index: 100; + animation: fadein 0.5s, fadeout 0.5s 4.5s; +} + +@keyframes fadein { + from { bottom: 0; opacity: 0; } + to { bottom: 50px; opacity: 1; } +} + +@keyframes fadeout { + from { bottom: 50px; opacity: 1; } + to { bottom: 0; opacity: 0; } +} + .glyphicon-spin { -webkit-animation: spin 1000ms infinite linear; animation: spin 1000ms infinite linear; diff --git a/css/themes/base16-default.css b/css/themes/base16-default.css index b30a08a..2324240 100644 --- a/css/themes/base16-default.css +++ b/css/themes/base16-default.css @@ -423,6 +423,10 @@ button.close:hover { color: var(--base01); } +#toast { + background-color: var(--base01); +} + /****************************/ /* Weechat colors and style */ /****************************/ diff --git a/css/themes/blue.css b/css/themes/blue.css index c093a43..cb666bc 100644 --- a/css/themes/blue.css +++ b/css/themes/blue.css @@ -134,6 +134,13 @@ input[type=text], input[type=password], #sendMessage, .badge, .btn-send, .btn-se border: 1px solid #363943; } +#toast { + background-color: #283244; + border: 1px solid; + border-color: rgb(29, 94, 152); + border-radius: 0px; +} + .horizontal-line { -webkit-box-shadow: rgba(255, 255, 255, 0.07) 0 1px 0; -moz-box-shadow: rgba(255, 255, 255, 0.07) 0 1px 0; diff --git a/css/themes/dark.css b/css/themes/dark.css index b6d1a08..4d845fe 100644 --- a/css/themes/dark.css +++ b/css/themes/dark.css @@ -2126,6 +2126,10 @@ code { color: #fff; } +#toast { + background-color: #333; +} + /* */ /* Mobile layout */ /* */ diff --git a/css/themes/light.css b/css/themes/light.css index 31a2368..900404d 100644 --- a/css/themes/light.css +++ b/css/themes/light.css @@ -2092,6 +2092,10 @@ input[type=text].is-invalid{ font-weight: bold; } +#toast { + background-color: #ddd; +} + /* */ /* Mobile layout */ /* */ diff --git a/js/inputbar.js b/js/inputbar.js index ceb2265..656a4a7 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -217,6 +217,18 @@ weechat.directive('inputBar', function() { // Extract nick from bufferline prefix var nick = prefix[prefix.length - 1].text; + // Check whether the user is still online + var buffer = models.getBuffer(bufferline.buffer); + var is_online = buffer.queryNicklist(nick); + if (!is_online) { + // show a toast that the user left + var toast = document.createElement('div'); + toast.id = "toast"; + toast.innerHTML = nick + " has left the room"; + document.body.appendChild(toast); + setTimeout(function() { document.body.removeChild(toast); }, 5000); + } + var newValue = $scope.command || ''; // can be undefined, in that case, use the empty string var addColon = newValue.length === 0; if (newValue.length > 0) { diff --git a/js/models.js b/js/models.js index 469bdaf..1ebc411 100644 --- a/js/models.js +++ b/js/models.js @@ -308,6 +308,19 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo return nicklist.hasOwnProperty('root'); }; + // Check whether a particular nick is in the nicklist + var queryNicklist = function(nick) { + for (var groupIdx in nicklist) { + var nicks = nicklist[groupIdx].nicks; + for (var nickIdx in nicks) { + if (nicks[nickIdx].name === nick) { + return true; + } + } + } + return false; + }; + /* Clear all our buffer lines */ var clear = function() { while(lines.length > 0) { @@ -353,6 +366,7 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo isNicklistEmpty: isNicklistEmpty, nicklistRequested: nicklistRequested, pinned: pinned, + queryNicklist: queryNicklist, }; };