From 2bbf64f27d9708d94688affd0539289002e3dfa4 Mon Sep 17 00:00:00 2001 From: Serubin Date: Fri, 28 Jul 2017 21:28:54 -0400 Subject: [PATCH 01/13] Change Navigation drawer to close on page change --- resources/js/Init.js | 3 +++ resources/js/Theme.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/resources/js/Init.js b/resources/js/Init.js index 717aa1d..0e5e6d2 100644 --- a/resources/js/Init.js +++ b/resources/js/Init.js @@ -159,6 +159,9 @@ function Init(){ current_conversation = null; + if(!full_theme && $side_menu.css("margin-left") == "0px") + $("#logo").click(); + var sectionFunc = window[page.ucFirst()]; // Get function if(typeof sectionFunc != "function") // Exec function return setPage(PAGE_LIST); diff --git a/resources/js/Theme.js b/resources/js/Theme.js index 0258922..d39d407 100644 --- a/resources/js/Theme.js +++ b/resources/js/Theme.js @@ -16,6 +16,8 @@ */ var globalColor, globalColorDark, globalColorAccent, textClass; + +var full_theme = true; /** * Enables initial theme @@ -240,6 +242,8 @@ function loadMiniVersion() { $outside_sidemenu.fadeIn(500); } }); + + full_theme = false; } function loadFullVersion() { @@ -255,5 +259,8 @@ function loadFullVersion() { $logo_image.removeClass(hasColoredToolbar() ? "icon_menu_toggle_dark" : "icon_menu_toggle"); $logo_image.addClass(hasColoredToolbar() ? "icon_logo_dark" : "icon_logo"); $logo_image.css("margin-top", "2px"); + + + full_theme = true; } From 6a50db7e70da8e70b2b95fdc74281582934bf596 Mon Sep 17 00:00:00 2001 From: Serubin Date: Fri, 28 Jul 2017 21:29:25 -0400 Subject: [PATCH 02/13] Update color scheme --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 20cbbc1..dab70e9 100644 --- a/index.html +++ b/index.html @@ -38,7 +38,7 @@ - + From 090514e0565fc0bc6a86453505494d231928f91f Mon Sep 17 00:00:00 2001 From: Serubin Date: Fri, 28 Jul 2017 21:30:07 -0400 Subject: [PATCH 03/13] Update login page. Update dark theme --- pages/login.html | 2 +- resources/css/themed-dark.css | 2 +- resources/css/v2_theme.css | 6 ++++++ resources/images/vector/archive-dark.svg | 4 ++++ resources/images/vector/blacklist-dark.svg | 4 ++++ resources/images/vector/inbox-dark.svg | 4 ++++ resources/images/vector/scheduled_messages-dark.svg | 4 ++++ resources/js/Login.js | 10 +++++----- 8 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 resources/images/vector/archive-dark.svg create mode 100644 resources/images/vector/blacklist-dark.svg create mode 100644 resources/images/vector/inbox-dark.svg create mode 100644 resources/images/vector/scheduled_messages-dark.svg diff --git a/pages/login.html b/pages/login.html index 860129a..2dcfdb9 100644 --- a/pages/login.html +++ b/pages/login.html @@ -15,7 +15,7 @@ limitations under the License. --> -
+

Pulse

diff --git a/resources/css/themed-dark.css b/resources/css/themed-dark.css index 7e0c974..081d243 100644 --- a/resources/css/themed-dark.css +++ b/resources/css/themed-dark.css @@ -1,4 +1,4 @@ -.conversation-card.mdl-card, .sent, .message { +.conversation-card.mdl-card, #login-pane .mdl-card, .sent, .message { background: #202B30; } diff --git a/resources/css/v2_theme.css b/resources/css/v2_theme.css index e3b81db..4c38122 100644 --- a/resources/css/v2_theme.css +++ b/resources/css/v2_theme.css @@ -272,6 +272,12 @@ a { margin-right: 18px; } +#login-pane { + left: calc(50% - 330px/2); + width: 330px; + margin: 5em auto; +} + @media (min-width:950px) { #content { width: 680px; diff --git a/resources/images/vector/archive-dark.svg b/resources/images/vector/archive-dark.svg new file mode 100644 index 0000000..fd70cee --- /dev/null +++ b/resources/images/vector/archive-dark.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/images/vector/blacklist-dark.svg b/resources/images/vector/blacklist-dark.svg new file mode 100644 index 0000000..dad82e0 --- /dev/null +++ b/resources/images/vector/blacklist-dark.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/images/vector/inbox-dark.svg b/resources/images/vector/inbox-dark.svg new file mode 100644 index 0000000..7ea6c74 --- /dev/null +++ b/resources/images/vector/inbox-dark.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/images/vector/scheduled_messages-dark.svg b/resources/images/vector/scheduled_messages-dark.svg new file mode 100644 index 0000000..a3630f8 --- /dev/null +++ b/resources/images/vector/scheduled_messages-dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/js/Login.js b/resources/js/Login.js index a5cb21c..15c7e59 100644 --- a/resources/js/Login.js +++ b/resources/js/Login.js @@ -21,14 +21,14 @@ function Login() { var $username = $("#username"); var $password = $("#password"); var $login = $("#login"); - var $navd_title = $("#nav-drawer-title"); - var $navd_subtitle = $("#nav-drawer-subtitle"); + var $toolbar = $("#toolbar"); + var $toolbar_title = $("#toolbar-title"); function constructor() { - - $navd_title.html("Pulse"); - $navd_subtitle.html("Please login"); + // Set page title + document.title = "Pulse"; + $toolbar_title.html("Login"); $parent.on('click', '#login', do_login); From 707b3aee99a139f318b452b14767c328d68e7907 Mon Sep 17 00:00:00 2001 From: Serubin Date: Fri, 28 Jul 2017 21:49:49 -0400 Subject: [PATCH 04/13] Update setting page to update when refreshed --- resources/js/Settings.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/js/Settings.js b/resources/js/Settings.js index ce517dd..628b17b 100644 --- a/resources/js/Settings.js +++ b/resources/js/Settings.js @@ -215,9 +215,16 @@ function Settings(data, $elem) { * Updates settings success */ function updateSettings(data, status) { + prev_base_theme = localStorage.getItem("base_theme"); + localStorage.setItem("global_color_theme", data.global_color_theme); localStorage.setItem("base_theme", data.base_theme); localStorage.setItem("rounder_bubbles", data.rounder_bubbles + ""); + + if(prev_base_theme != data.base_theme) + window.location = window.location.href; + + constructor(); } constructor(); From 59866784f2837515f50d4c14002924b07046a235 Mon Sep 17 00:00:00 2001 From: Serubin Date: Fri, 28 Jul 2017 23:02:28 -0400 Subject: [PATCH 05/13] Fix scroll scroll to bottom when looking at thread --- resources/js/Init.js | 2 ++ resources/js/Thread.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/js/Init.js b/resources/js/Init.js index 0e5e6d2..0be716f 100644 --- a/resources/js/Init.js +++ b/resources/js/Init.js @@ -27,6 +27,7 @@ var $content; var $insert; var $back_btn; var $more_btn; +var snackbarContainer; var account_id = localStorage.getItem("account_id"); var page; @@ -50,6 +51,7 @@ function Init(){ var $content = $("#content"); var $toolbar = $("#toolbar"); var $toolbar_title = $("#toolbar-title"); + var snackbarContainer = document.querySelector('#snackbar'); var $inserted = null; var color = "#2196F3"; diff --git a/resources/js/Thread.js b/resources/js/Thread.js index d88ed7c..e1faa81 100644 --- a/resources/js/Thread.js +++ b/resources/js/Thread.js @@ -584,9 +584,10 @@ function Thread(data) { // Show scroll to bottom snackbar - don't interupt scrolling if (current_size != conversations[conversation_id].length && !initial_load) { - var scroll_top = $body.scrollTop() || $document.scrollTop(); + var scroll_top = ($body.scrollTop() || $document.scrollTop()) + $document.height(); + // If near bottom - if (!(($document.height() - 400) > scroll_top)) { + if (!(($body.height() - 400) > scroll_top) && $msg_list.height() > $document.height()) { scrollToBottom(250) return } From ea0018a8ab48a1011d4d710810d5d83e79dae66e Mon Sep 17 00:00:00 2001 From: Serubin Date: Sun, 30 Jul 2017 20:49:27 -0400 Subject: [PATCH 06/13] Standardize titles --- resources/js/Conversations.js | 2 +- resources/js/Init.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/js/Conversations.js b/resources/js/Conversations.js index d694957..c9eafb6 100644 --- a/resources/js/Conversations.js +++ b/resources/js/Conversations.js @@ -72,7 +72,7 @@ function Conversations(data, elem, page, small) { } // Set page title - document.title = "Pulse"; + document.title = "Pulse - Conversations"; $toolbar_title.html("Conversations"); if(archive) diff --git a/resources/js/Init.js b/resources/js/Init.js index 0be716f..3a6907a 100644 --- a/resources/js/Init.js +++ b/resources/js/Init.js @@ -119,8 +119,8 @@ function Init(){ var data; // Url data // Set page title - document.title = "Pulse - Settings"; - $toolbar_title.html("Settings"); + document.title = "Pulse"; + $toolbar_title.html("Pulse"); if(typeof url != "string") From ec5848efe27226950f21993fefb6fcc32553de94 Mon Sep 17 00:00:00 2001 From: Serubin Date: Sun, 30 Jul 2017 20:51:12 -0400 Subject: [PATCH 07/13] Add comments to several functions --- resources/js/Helper.js | 83 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/resources/js/Helper.js b/resources/js/Helper.js index 808c3ce..4bca7d6 100644 --- a/resources/js/Helper.js +++ b/resources/js/Helper.js @@ -196,6 +196,13 @@ function showConfirmDialog(message, func) { }); } +/** + * entityEncode + * Removes characters "<", ">", "\n" and replaces with transfer/html safe items + * + * @param string - unencoded string + * @return encoded string + */ function entityEncode(string) { while (string.indexOf("<") !== -1) { string = string.replace("<", "<"); @@ -209,6 +216,35 @@ function entityEncode(string) { return string; } +/** + * entityDecode + * Removes html/transfer safe characters with original characters + * + * @param string - encoded string + * @return unencoded string + */ +function entityDecode(string) { + while (string.indexOf("<") !== -1) { + string = string.replace("<", "<"); + } + + while (string.indexOf(">") !== -1) { + string = string.replace(">", ">"); + } + + string = string.replace('
', "\n"); + return string; +} + +/** + * CompareTimestamps + * Checks if timestamp is within 15 minutes of each other. + * + * @param date + * @param nextDate + * + * @return date || null + */ function compareTimestamps(date, nextDate) { if (nextDate.getTime() > date.getTime() + (1000 * 60 * 15)) { return date.toLocaleString(); @@ -217,6 +253,13 @@ function compareTimestamps(date, nextDate) { } } +/** + * isReceived + * is message type recieved or sent + * + * @param type - message type (int) + * @return boolean + */ function isReceived(type) { return type == 0 || type == 6; } @@ -235,25 +278,63 @@ function scrollToBottom(speed) { $window.animate({"scrollTop": $document.scrollHeight}, speed); } +/** + * allowNotification + * Checks if user is allowing notifications to be triggered + * + * @return boolean + */ function allowNotification() { var notification_toggle = localStorage.getItem("notifications"); return typeof notification_toggle !== "undefined" && notification_toggle === "yes"; } +/** + * logout + * Removes all local keys / account data. + * Redirect once done + */ +function logout() { + + // Remove account info + account_id = null; + localStorage.removeItem("account_id"); + localStorage.removeItem("hash"); + localStorage.removeItem("salt"); + localStorage.removeItem("phone_number"); + localStorage.removeItem("name"); + + window.location.replace("/" ); // redirect +} + /** * Contains element * @param element value +* +* @return boolean */ Array.prototype.contains = function(element) { return this.indexOf(element) > -1 ? true : false } - +/** + * ucFirst + * Upper case first letter of string. + * + * @return string + */ String.prototype.ucFirst = function() { return this.charAt(0).toUpperCase() + this.slice(1); } +/** + * size + * Gets size of js object + * + * @param object + * @return size + */ Object.size = function(obj) { return Object.keys(obj).length; } From cf237155361d1929d25f9de572c7c18b18515c80 Mon Sep 17 00:00:00 2001 From: Serubin Date: Sun, 30 Jul 2017 20:52:04 -0400 Subject: [PATCH 08/13] Update snippet/encoding handling --- resources/js/Conversations.js | 3 +++ resources/js/Notifier.js | 2 +- resources/js/Thread.js | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/js/Conversations.js b/resources/js/Conversations.js index c9eafb6..275afa1 100644 --- a/resources/js/Conversations.js +++ b/resources/js/Conversations.js @@ -153,6 +153,9 @@ function Conversations(data, elem, page, small) { convo.color = toColor(convo.color); convo.color_dark = toColor(convo.color_dark); convo.color_accent = toColor(convo.color_accent); + + // Match and remove all iterations of "
" + convo.snippet = convo.snippet.split(/
/g).join(""); $conv_el = $("#"+ convo.device_id); diff --git a/resources/js/Notifier.js b/resources/js/Notifier.js index 0374739..137aad9 100644 --- a/resources/js/Notifier.js +++ b/resources/js/Notifier.js @@ -176,7 +176,7 @@ function Notifier() { var snippet = data.snippet || data.data; var options = { - body: snippet, + body: entityDecode(snippet), icon: "/resources/images/vector/pulse.svg", } diff --git a/resources/js/Thread.js b/resources/js/Thread.js index e1faa81..5f5625b 100644 --- a/resources/js/Thread.js +++ b/resources/js/Thread.js @@ -677,6 +677,10 @@ function Thread(data) { if(sent) snippet = "You: " + snippet; + if(typeof snippet != "undefined") // If exists. Quick fix + // Match and remove all iterations of "
" + snippet = snippet.split(/
/g).join(""); + $el.find(".conversation-snippet").html(snippet); $el.find("span").removeClass("bold"); From 2013b43246ed242628fd3254c9a20b34243e79bc Mon Sep 17 00:00:00 2001 From: Serubin Date: Sun, 30 Jul 2017 20:54:12 -0400 Subject: [PATCH 09/13] Remove old/uncessary code/comments --- resources/js/Helper.js | 28 ---------------------------- resources/js/Init.js | 5 +++++ resources/js/Thread.js | 1 - 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/resources/js/Helper.js b/resources/js/Helper.js index 4bca7d6..55382e6 100644 --- a/resources/js/Helper.js +++ b/resources/js/Helper.js @@ -15,34 +15,6 @@ * limitations under the License. */ - -/** - * Enables initial theme - */ -function enableTheme() { - setGlobalColor(); - - var baseTheme = getBaseTheme(); - if (baseTheme === "dark" || (baseTheme === "day_night" && isNight()) || baseTheme === "black") { - textClass = "mdl-color-text--white"; - $('head').append(''); - $('.mdl-color-text--grey-900').addClass(textClass).removeClass('mdl-color-text--grey-900'); - - if (baseTheme === "black") { - $('head').append(''); - } - } else { - textClass = "mdl-color-text--grey-900"; - } - - $(".empty").css("background-color", globalColor); - $(".mdl-layout__header").css("background-color", globalColor); - $(".mdl-color--primary").css("background-color", globalColor); - $("#nav-drawer-title").css("background-color", globalColorDark); - $("#nav-drawer-subtitle").css("background-color", globalColorDark); - $("#compose").css("background-color", globalColorAccent); -} - function decrypt(data) { if (data == null) { return ""; diff --git a/resources/js/Init.js b/resources/js/Init.js index 3a6907a..ae26bfd 100644 --- a/resources/js/Init.js +++ b/resources/js/Init.js @@ -69,6 +69,11 @@ function Init(){ function constructor() { + $( document ).ajaxError(function( event, jqxhr, settings, thrownError ) { + if (thrownError === "Unauthorized") + logout(); + }); + Nav(); notifier = new Notifier(); diff --git a/resources/js/Thread.js b/resources/js/Thread.js index 5f5625b..5992ca2 100644 --- a/resources/js/Thread.js +++ b/resources/js/Thread.js @@ -527,7 +527,6 @@ function Thread(data) { msg_is_mms = true; } - // TODO do like date wrapper - also color message to contact? if ((message.message_from != null && message.message_from.length) != 0 && message.message_type == 0 ) { From 8f9bbf903024cd606bc8b6280f5f45441254a113 Mon Sep 17 00:00:00 2001 From: Serubin Date: Sun, 30 Jul 2017 20:57:32 -0400 Subject: [PATCH 10/13] Add conditional for allowing notifications --- resources/js/Notifier.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/js/Notifier.js b/resources/js/Notifier.js index 137aad9..6473e81 100644 --- a/resources/js/Notifier.js +++ b/resources/js/Notifier.js @@ -170,6 +170,10 @@ function Notifier() { function sendNotification(conversation_id, data) { + + if(!allowNotification()) // Ignore if notifications are disallowed + return; + last_notification[conversation_id] = data.timestamp; var title = data.title || localStorage.getItem(conversation_id + "title"); From 4a17d2c922dc92cf100c7b5f11c5a1ae3fb7614d Mon Sep 17 00:00:00 2001 From: Serubin Date: Sun, 30 Jul 2017 20:57:43 -0400 Subject: [PATCH 11/13] Fix default color value --- resources/js/Theme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/Theme.js b/resources/js/Theme.js index d39d407..a3c994f 100644 --- a/resources/js/Theme.js +++ b/resources/js/Theme.js @@ -49,7 +49,7 @@ function enableTheme() { $(".icon_logo").addClass("icon_logo_dark").removeClass("icon_logo"); $(".icon_menu_toggle").addClass("icon_menu_toggle_dark").removeClass("icon_menu_toggle"); - var color = hasGlobalTheme() ? globalColor : "#009688"; + var color = hasGlobalTheme() ? globalColor : "#2196F3"; $("#toolbar").css("background-color", color); } else { From 518cace61ae9a8e554c47471c68e68f87e0d9337 Mon Sep 17 00:00:00 2001 From: Serubin Date: Sun, 30 Jul 2017 23:30:35 -0400 Subject: [PATCH 12/13] Add letter-icons to conversation lists --- resources/js/Conversations.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/resources/js/Conversations.js b/resources/js/Conversations.js index 275afa1..5e6b2d5 100644 --- a/resources/js/Conversations.js +++ b/resources/js/Conversations.js @@ -169,6 +169,7 @@ function Conversations(data, elem, page, small) { $icon = "" + "" + + "" + convo.title.substr(0,1) + "" + ""; $text_wrap = $("

").addClass("conversation-text"); @@ -191,10 +192,7 @@ function Conversations(data, elem, page, small) { $snippet.addClass("conversation-snippet-small"); $icon = "" + "" - + ""; - } else { - $icon = "" - + "" + + "" + convo.title.substr(0,1) + "" + ""; } From 94289185c638a7467da7f92aa6c6c46d9e0576a9 Mon Sep 17 00:00:00 2001 From: Serubin Date: Sun, 30 Jul 2017 23:45:35 -0400 Subject: [PATCH 13/13] Update mini/full theme handling --- resources/js/Theme.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/resources/js/Theme.js b/resources/js/Theme.js index 0c2758f..6004d00 100644 --- a/resources/js/Theme.js +++ b/resources/js/Theme.js @@ -44,21 +44,21 @@ function enableTheme() { if (hasColoredToolbar()) { - $(".material-icons").addClass("material-icons-white"); - $("#toolbar-title").css("color", "white"); - $(".icon_logo").addClass("icon_logo_dark").removeClass("icon_logo"); - $(".icon_menu_toggle").addClass("icon_menu_toggle_dark").removeClass("icon_menu_toggle"); + $(".material-icons").addClass("material-icons-white"); + $("#toolbar-title").css("color", "white"); + $(".icon_logo").addClass("icon_logo_dark").removeClass("icon_logo"); + $(".icon_menu_toggle").addClass("icon_menu_toggle_dark").removeClass("icon_menu_toggle"); - var color = hasGlobalTheme() ? globalColor : "#2196F3"; - $("#toolbar").css("background-color", color); + var color = hasGlobalTheme() ? globalColor : "#2196F3"; + $("#toolbar").css("background-color", color); } else { - $("#toolbar").css("background-color", "#fafafa"); - $("#toolbar-title").css("color", "#666666"); - $(".material-icons").removeClass("material-icons-white"); - $(".icon_logo_dark").addClass("icon_logo").removeClass("icon_logo_dark"); - $(".icon_menu_toggle_dark").addClass("icon_menu_toggle").removeClass("icon_menu_toggle_dark"); + $("#toolbar").css("background-color", "#fafafa"); + $("#toolbar-title").css("color", "#666666"); + $(".material-icons").removeClass("material-icons-white"); + $(".icon_logo_dark").addClass("icon_logo").removeClass("icon_logo_dark"); + $(".icon_menu_toggle_dark").addClass("icon_menu_toggle").removeClass("icon_menu_toggle_dark"); } @@ -233,7 +233,7 @@ function loadMiniVersion() { var $outside_sidemenu = $("#outside-side-menu"); if ($sidemenu.css("margin-left") == "0px") { - $html.removeClass("side-menu_show"); + $html.removeClass("side-menu_show"); $sidemenu.css("margin-left", "-269px"); $outside_sidemenu.fadeOut(500); } else { @@ -250,9 +250,11 @@ function loadFullVersion() { $("html").removeClass("side-menu_show"); $("#content").css("margin-left", SIDE_MENU_WIDTH + "px"); - $("#logo").show(); + $("#logo").off(); + $("#side-menu").css("margin-left", "0px"); $("#side-menu_toggle").hide(); + $("#outside-side-menu").hide() $("#side-menu_toggle").off(); var $logo_image = $("#logo-image");