diff --git a/site/interface/site/index.html b/site/interface/site/index.html index acc459e..12dee80 100644 --- a/site/interface/site/index.html +++ b/site/interface/site/index.html @@ -6,12 +6,15 @@ Chat + +
+

CHAT

diff --git a/site/interface/site/main.js b/site/interface/site/main.js index 1cecbda..f097f48 100644 --- a/site/interface/site/main.js +++ b/site/interface/site/main.js @@ -6,12 +6,24 @@ /* By: edbernar { liveChat(); }); + + + +document.addEventListener("keydown", (e) => { + if (e.key === "/") + createNotification.info("Hello"); + if (e.key === "*") + createNotification.success("Hello"); + if (e.key === "-") + createNotification.error("Hello"); +}); \ No newline at end of file diff --git a/site/interface/site/notification/main.js b/site/interface/site/notification/main.js new file mode 100644 index 0000000..d6a2abf --- /dev/null +++ b/site/interface/site/notification/main.js @@ -0,0 +1,78 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.js :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: edbernar { + newNotification.style.opacity = 1; + }, 100); + setTimeout(() => { + setTimeout(() => { + divNotification.removeChild(newNotification); + }, 99); + newNotification.style.animation = "slideOut 0.11s"; + }, timer); +} + +class notification +{ + timer = 2000; + + constructor() {} + + info(message, action=null) + { + console.log("New info notification: " + message); + newNotification("info", this.timer); + } + + success(message, action=null) + { + console.log("New success notification: " + message); + newNotification("success", this.timer); + } + + warning(message, action=null) + { + console.log("New warning notification: " + message); + newNotification("warning", this.timer); + } + + error(message, action=null) + { + console.log("New error notification: " + message); + newNotification("error", this.timer); + } +} + +const createNotification = new notification(); + +export { createNotification }; \ No newline at end of file diff --git a/site/interface/site/style/notification.css b/site/interface/site/style/notification.css new file mode 100644 index 0000000..2ea1e49 --- /dev/null +++ b/site/interface/site/style/notification.css @@ -0,0 +1,57 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* notification.css :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: edbernar { + status = 1; console.log('Connected'); if (token) sendRequest("login", {"type": "byToken", "token": token}); - }; socket.onmessage = (event) => { @@ -57,12 +59,15 @@ socket.onmessage = (event) => { }; socket.onclose = () => { + status = 0; console.log('Disconnected'); }; function sendRequest(type, content) { let coc = null; + if (status === 0) + return ; if (content instanceof Object) coc = JSON.stringify(content); else