From 3fd55d3389e5d1d496a62bbb7ee95234c304ca8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20L=2E=20=C5=A0ijanec?= Date: Sun, 5 Apr 2020 20:23:30 +0200 Subject: chats.js not done yet --- css/bubbles.css | 94 ++++++++++++ css/styles.css | 20 ++- img/avatars/asijanec.png | Bin 389 -> 82 bytes js/chats.js | 373 +++++++++++++++++++++++++++++++++++++++++++++++ js/gsec.js | 18 ++- js/lang/bundle.js | 26 +++- js/messaging.js | 2 +- js/setup-storage.js | 3 +- pages/about.html | 1 + pages/absences.html | 1 + pages/chats.html | 104 +++++++++++++ pages/grades.html | 3 +- pages/gradings.html | 3 +- pages/meals.html | 3 +- pages/messaging.html | 5 +- pages/settings.html | 3 +- pages/teachers.html | 3 +- pages/timetable.html | 3 +- sw.js | 8 +- 19 files changed, 647 insertions(+), 26 deletions(-) create mode 100644 css/bubbles.css create mode 100644 js/chats.js create mode 100644 pages/chats.html diff --git a/css/bubbles.css b/css/bubbles.css new file mode 100644 index 0000000..8a19ff1 --- /dev/null +++ b/css/bubbles.css @@ -0,0 +1,94 @@ +/* obviously stolen, source https://codepen.io/swards/pen/gxQmbj */ +.chat { + width: 100%; + border-left: solid 1px #EEE; + border-right: solid 1px #EEE; + /* border-bottom: solid 1px #EEE; */ + display: flex; + flex-direction: column; + padding: 10px; +} + +.messages { + margin-top: 30px; + display: flex; + flex-direction: column; +} + +.message { + border-radius: 20px; + padding: 8px 15px; + margin-top: 5px; + margin-bottom: 5px; + display: inline-block; +} + +.yours { + align-items: flex-start; +} + +.yours .message { + margin-right: 25%; + background-color: #eee; + position: relative; +} + +.yours .message.last:before { + content: ""; + position: absolute; + z-index: 0; + bottom: 0; + left: -7px; + height: 20px; + width: 20px; + background: #eee; + border-bottom-right-radius: 15px; +} +.yours .message.last:after { + content: ""; + position: absolute; + z-index: 1; + bottom: 0; + left: -10px; + width: 10px; + height: 20px; + background: white; + border-bottom-right-radius: 10px; +} + +.mine { + align-items: flex-end; +} + +.mine .message { + color: white; + margin-left: 25%; + background: linear-gradient(to bottom, var(--color-primary) 0%, var(--color-secondary) 100%); + background-attachment: fixed; + position: relative; +} + +.mine .message.last:before { + content: ""; + position: absolute; + z-index: 0; + bottom: 0; + right: -8px; + height: 20px; + width: 20px; + background: linear-gradient(to bottom, var(--color-primary) 0%, var(--color-secondary) 100%); + background-attachment: fixed; + border-bottom-left-radius: 15px; +} + +.mine .message.last:after { + content: ""; + position: absolute; + z-index: 1; + bottom: 0; + right: -10px; + width: 10px; + height: 20px; + background: white; + border-bottom-left-radius: 10px; +} \ No newline at end of file diff --git a/css/styles.css b/css/styles.css index 8ad12a0..a06c906 100644 --- a/css/styles.css +++ b/css/styles.css @@ -28,8 +28,12 @@ body { } nav { - background: var(--color-primary); - border-bottom: 10px solid var(--color-accent); + background: var(--color-primary); + border-bottom: 10px solid var(--color-accent); + position: sticky; + left: 0; + top: 0; + z-index: 69; /* choose a number, any number */ } .hidden { @@ -147,4 +151,14 @@ a.collection-item { .input-field textarea:not([readonly]):focus { border-bottom: 1px solid var(--color-primary) !important; box-shadow: 0 1px 0 0 var(--color-primary) !important; -} \ No newline at end of file +} + +.chat-sticky-input { + position: fixed; + left: 0; + bottom: 0; + width: 100%; + background-color: white; + text-align: center; + z-index: 60; +} diff --git a/img/avatars/asijanec.png b/img/avatars/asijanec.png index 34d0e3e..ccae7d0 100644 Binary files a/img/avatars/asijanec.png and b/img/avatars/asijanec.png differ diff --git a/js/chats.js b/js/chats.js new file mode 100644 index 0000000..73dc791 --- /dev/null +++ b/js/chats.js @@ -0,0 +1,373 @@ +const API_ENDPOINT = "https://gimb.tk/test.php"; +const DIRECTORY_URL = "/directory.json"; +// "Global" object for name directory +var directory = null; +var currentlyChattingWith = null; // msgid +var sogovornik = null; // name +var firstPageOfMessages = null; // so we can test if new messages ever arrive + +async function checkLogin() { + localforage.getItem("logged_in").then(function (value) { + // This code runs once the value has been loaded + // from the offline store. + if (value !== true) { + window.location.replace("/index.html"); + } + }).catch(function (err) { + // This code runs if there were any errors + console.log(err); + }); +} +function getKeyByValue(object, value) { + return Object.keys(object).find(key => object[key] === value); +} +// -----------HTML HELPERS----------- +function htmlEncode(value) { + // Create a in-memory element, set its inner text (which is automatically encoded) + // Then grab the encoded contents back out. The element never exists on the DOM. + return $(" + + +
+ +
+ + + + + \ No newline at end of file diff --git a/pages/grades.html b/pages/grades.html index 878ccd2..0c7e161 100644 --- a/pages/grades.html +++ b/pages/grades.html @@ -54,7 +54,8 @@
  • supervisor_accountteachers
  • query_builderabsences
  • messagemessaging
  • -
  • fastfoodmeals
  • +
  • chatchat
  • +
  • fastfoodmeals
  • infoabout
  • exit_to_applogout
  • diff --git a/pages/gradings.html b/pages/gradings.html index d18670e..72a809a 100644 --- a/pages/gradings.html +++ b/pages/gradings.html @@ -61,7 +61,8 @@
  • supervisor_accountteachers
  • query_builderabsences
  • messagemessaging
  • -
  • fastfoodmeals
  • +
  • chatchat
  • +
  • fastfoodmeals
  • infoabout
  • exit_to_applogout
  • diff --git a/pages/meals.html b/pages/meals.html index 0aae59e..00d150c 100644 --- a/pages/meals.html +++ b/pages/meals.html @@ -54,7 +54,8 @@
  • supervisor_accountteachers
  • query_builderabsences
  • messagemessaging
  • -
  • fastfoodmeals
  • +
  • chatchat
  • +
  • fastfoodmeals
  • infoabout
  • exit_to_applogout
  • diff --git a/pages/messaging.html b/pages/messaging.html index 99f12db..6fbf2db 100644 --- a/pages/messaging.html +++ b/pages/messaging.html @@ -52,6 +52,7 @@
  • query_builderabsences
  • messagemessaging
  • fastfoodmeals
  • +
  • chatchat
  • infoabout
  • exit_to_applogout
  • @@ -138,9 +139,5 @@

    - - - - diff --git a/pages/settings.html b/pages/settings.html index 9d8aaa6..9cde7ac 100644 --- a/pages/settings.html +++ b/pages/settings.html @@ -51,7 +51,8 @@
  • supervisor_accountteachers
  • query_builderabsences
  • messagemessaging
  • -
  • fastfoodmeals
  • +
  • chatchat
  • +
  • fastfoodmeals
  • infoabout
  • exit_to_applogout
  • diff --git a/pages/teachers.html b/pages/teachers.html index e68f512..55a9a92 100644 --- a/pages/teachers.html +++ b/pages/teachers.html @@ -54,7 +54,8 @@
  • supervisor_accountteachers
  • query_builderabsences
  • messagemessaging
  • -
  • fastfoodmeals
  • +
  • chatchat
  • +
  • fastfoodmeals
  • infoabout
  • exit_to_applogout
  • diff --git a/pages/timetable.html b/pages/timetable.html index 3bdb4fa..b7ce913 100644 --- a/pages/timetable.html +++ b/pages/timetable.html @@ -63,7 +63,8 @@
  • supervisor_accountteachers
  • query_builderabsences
  • messagemessaging
  • -
  • fastfoodmeals
  • +
  • chatchat
  • +
  • fastfoodmeals
  • infoabout
  • exit_to_applogout
  • diff --git a/sw.js b/sw.js index f217f03..2e75d02 100644 --- a/sw.js +++ b/sw.js @@ -77,7 +77,11 @@ const assets = [ "/index.html", "/login.html", "/logout.html", - "/favicon.png" + "/favicon.png", + + "/pages/chats.html", + "/js/chats.js", + "/css/bubbles.css" ]; importScripts("/js/lib/localforage.min.js"); @@ -137,4 +141,4 @@ self.addEventListener("fetch", (evt) => { evt.respondWith(caches.match(evt.request).then((cache_res) => { return cache_res || fetch(evt.request); })) -}); +}); \ No newline at end of file -- cgit v1.2.3