From 17fdeb9e1fa24178f4450f4f71e83768e876628e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 9 Jun 2021 11:06:12 +0200 Subject: Fix email local part validation --- view/js/mod_register.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/mod_register.js b/view/js/mod_register.js index 1fc5ad2fa..4f00ededb 100644 --- a/view/js/mod_register.js +++ b/view/js/mod_register.js @@ -3,7 +3,7 @@ $(document).ready(function() { typeof(window.tao) == 'undefined' ? window.tao = {} : ''; tao.zar = { vsn: '2.0.0', form: {}, msg: {} }; tao.zar.patano = /^d[0-9]{5,10}$/; - tao.zar.patema = /^[a-z0-9.-]{1,64}@[a-z0-9.-]{2,32}\.[a-z]{2,12}$/; + tao.zar.patema = /^([^@\s]{1,64})@[a-z0-9.-]{2,32}\.[a-z]{2,12}$/; $('.register_date').each( function () { var date = new Date($(this).data('utc')); -- cgit v1.2.3 From 2c198ed89ac1821b4483db7942b737b63858a574 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 9 Jun 2021 12:53:55 +0200 Subject: Remove unnecessary parentheses --- view/js/mod_register.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/mod_register.js b/view/js/mod_register.js index 4f00ededb..f54dd2570 100644 --- a/view/js/mod_register.js +++ b/view/js/mod_register.js @@ -3,7 +3,7 @@ $(document).ready(function() { typeof(window.tao) == 'undefined' ? window.tao = {} : ''; tao.zar = { vsn: '2.0.0', form: {}, msg: {} }; tao.zar.patano = /^d[0-9]{5,10}$/; - tao.zar.patema = /^([^@\s]{1,64})@[a-z0-9.-]{2,32}\.[a-z]{2,12}$/; + tao.zar.patema = /^[^@\s]{1,64}@[a-z0-9.-]{2,32}\.[a-z]{2,12}$/; $('.register_date').each( function () { var date = new Date($(this).data('utc')); -- cgit v1.2.3 From b55676d08914d58927b5503a1bfa283397cd6d44 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 17 Jun 2021 07:33:45 +0000 Subject: New landing page HQ with separate views for direct messages, public/limited messages and starred messages if the feature is enabled --- view/js/autocomplete.js | 15 +- view/js/main.js | 439 +++++++----------------------------------------- view/js/mod_hq.js | 26 ++- 3 files changed, 87 insertions(+), 393 deletions(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index c45c47518..f20c45982 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -162,8 +162,8 @@ function string2bb(element) { if (typeof extra_channels === 'undefined') extra_channels = false; // Autocomplete contacts - contacts = { - match: /(^|\s)(@\!*)([^ \n]{3,})$/, + channels = { + match: /(^(?=[^\!]{2})|\s)(@)([^ \n]{3,})$/, index: 3, cache: true, search: function(term, callback) { contact_search(term, callback, backend_url, 'c', extra_channels, spinelement=false); }, @@ -171,6 +171,15 @@ function string2bb(element) { template: contact_format }; + contacts = { + match: /(^|\s)(@\!)([^ \n]{3,})$/, + index: 3, + cache: true, + search: function(term, callback) { contact_search(term, callback, backend_url, 'm', extra_channels, spinelement=false); }, + replace: editor_replace, + template: contact_format + }; + // Autocomplete hashtags tags = { match: /(^|\s)(\#)([^ \n]{2,})$/, @@ -202,7 +211,7 @@ function string2bb(element) { maxCount: 100 } }); - textcomplete.register([contacts,smilies,tags]); + textcomplete.register([channels,contacts,smilies,tags]); }); }; })( jQuery ); diff --git a/view/js/main.js b/view/js/main.js index b1cba33af..a3f238a45 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -26,13 +26,6 @@ var followUpPageLoad = false; var window_needs_alert = true; var expanded_items = []; -var sse_bs_active = false; -var sse_offset = 0; -var sse_type; -var sse_partial_result = false; -var sse_rmids = []; -var sse_fallback_interval; - var page_cache = {}; // take care of tab/window reloads on channel change @@ -93,7 +86,7 @@ $(document).ready(function() { if (tao.zin.syslc == '') { $('.zinlcx').append(tao.zin.axim); $.ajax({ - type: 'POST', url: 'lang', + type: 'POST', url: 'lang', data: { zinlc: '??' } }).done( function(re) { tao.zin.re = JSON.parse(re); @@ -117,7 +110,7 @@ $(document).ready(function() { tao.zin.me = e.target.id.substr(5); $('#right_aside_wrapper').append(tao.zin.axim); $.ajax({ - type: 'POST', url: 'lang', + type: 'POST', url: 'lang', data: { zinlc: tao.zin.me } }).done( function(re) { tao.zin.re = JSON.parse(re); @@ -161,110 +154,59 @@ $(document).ready(function() { jQuery.timeago.settings.allowFuture = true; - if(sse_enabled) { - if(typeof(window.SharedWorker) === 'undefined') { - // notifications with multiple tabs open will not work very well in this scenario - var evtSource = new EventSource('/sse'); - - evtSource.addEventListener('notifications', function(e) { - var obj = JSON.parse(e.data); - sse_handleNotifications(obj, false, false); - }, false); + $(document).on('click', '.notification, .message', function(e) { + let b64mid = $(this).data('b64mid'); + let notify_id = $(this).data('notify_id'); + let path = $(this)[0].pathname.split('/')[1]; + let stateObj = { b64mid: b64mid }; + let singlethread_modules = ['display', 'hq', 'dm']; + let redirect_modules = ['display', 'notify']; - document.addEventListener('visibilitychange', function() { - if (!document.hidden) { - sse_offset = 0; - sse_bs_init(); - } - }, false); + if(! b64mid && ! notify_id) + return; + if(redirect_modules.indexOf(path) !== -1) { + path = 'hq'; } - else { - var myWorker = new SharedWorker('/view/js/sse_worker.js', localUser); - myWorker.port.onmessage = function(e) { - obj = e.data; - console.log(obj); - sse_handleNotifications(obj, false, false); - } - - myWorker.onerror = function(e) { - myWorker.port.close(); - } + if(notify_id != null) { + $.ajax({ + type: 'post', + url: 'notify', + data: { + 'notify_id' : notify_id + }, + async: ((module !== path) ? false : true) + }); + } - myWorker.port.start(); + if (module !== path) { + e.preventDefault(); + window.location.href = path + '/' + b64mid; } - } - else { - if (!document.hidden) - sse_fallback_interval = setInterval(sse_fallback, updateInterval); + else { - document.addEventListener('visibilitychange', function() { - if (document.hidden) { - clearInterval(sse_fallback_interval); - } - else { - sse_offset = 0; - sse_bs_init(); - sse_fallback_interval = setInterval(sse_fallback, updateInterval); + if (singlethread_modules.indexOf(module) !== -1) { + history.pushState(stateObj, '', module + '/' + b64mid); + $('.message').removeClass('active'); + $('[data-b64mid="' + b64mid + '"].message').addClass('active'); } - }, false); - } - - $('.notification-link').on('click', { replace: true, followup: false }, sse_bs_notifications); - - $('.notification-filter').on('keypress', function(e) { - if(e.which == 13) { // enter - this.blur(); - sse_offset = 0; - $("#nav-" + sse_type + "-menu").html(''); - $("#nav-" + sse_type + "-loading").show(); - - var cn_val = $('#cn-' + sse_type + '-input').length ? $('#cn-' + sse_type + '-input').val().toString().toLowerCase() : ''; + if (b64mid) { - $.get('/sse_bs/' + sse_type + '/' + sse_offset + '?nquery=' + encodeURIComponent(cn_val), function(obj) { - console.log('sse: bootstraping ' + sse_type); - console.log(obj); + e.preventDefault(); - sse_bs_active = false; - sse_partial_result = true; - sse_offset = obj[sse_type].offset; - if(sse_offset < 0) - $("#nav-" + sse_type + "-loading").hide(); - - sse_handleNotifications(obj, true, false); - - }); + if(! page_load) { + prepareLiveUpdate(b64mid, notify_id); + } + } } }); - $('.notifications-textinput-clear').on('click', function(e) { - if(! sse_partial_result) - return; - - $("#nav-" + sse_type + "-menu").html(''); - $("#nav-" + sse_type + "-loading").show(); - $.get('/sse_bs/' + sse_type, function(obj) { - console.log('sse: bootstraping ' + sse_type); - console.log(obj); - - sse_bs_active = false; - sse_partial_result = false; - sse_offset = obj[sse_type].offset; - if(sse_offset < 0) - $("#nav-" + sse_type + "-loading").hide(); - - sse_handleNotifications(obj, true, false); - - }); - }); - - $('.notification-content').on('scroll', function() { - if(this.scrollTop > this.scrollHeight - this.clientHeight - (this.scrollHeight/7)) { - sse_bs_notifications(sse_type, false, true); - } - }); + window.onpopstate = function(e) { + if(e.state !== null && e.state.b64mid !== bParam_mid) + prepareLiveUpdate(e.state.b64mid, ''); + }; //mod_mail only $(".mail-conv-detail .autotime").timeago(); @@ -967,6 +909,20 @@ function updateInit() { } } +function prepareLiveUpdate(b64mid, notify_id) { + $(document).scrollTop(0); + $('.thread-wrapper').remove(); + bParam_mid = b64mid; + mode = 'replace'; + page_load = true; + if (module == 'hq') { + liveUpdate(notify_id); + } + if (module == 'display'|| module == 'dm') { + liveUpdate(); + } +} + function liveUpdate(notify_id) { if(typeof profile_uid === 'undefined') profile_uid = false; /* Should probably be unified with channelId defined in head.tpl */ @@ -1052,7 +1008,7 @@ function liveUpdate(notify_id) { if(typeof notify_id !== 'undefined' && notify_id !== 'undefined') { $.post( - "hq", + "notify", { "notify_id" : notify_id } @@ -1760,288 +1716,6 @@ function zid(s) { return s; } -function sse_bs_init() { - if(sessionStorage.getItem('notification_open') !== null || typeof sse_type !== 'undefined' ) { - if(typeof sse_type === 'undefined') - sse_type = sessionStorage.getItem('notification_open'); - - $("#nav-" + sse_type + "-sub").addClass('show'); - sse_bs_notifications(sse_type, true, false); - } - else { - sse_bs_counts(); - } -} - -function sse_bs_counts() { - if(sse_bs_active) - return; - - sse_bs_active = true; - - $.ajax({ - type: 'post', - url: '/sse_bs', - data: { sse_rmids } - }).done( function(obj) { - console.log(obj); - sse_bs_active = false; - sse_rmids = []; - sse_handleNotifications(obj, true, false); - }); -} - -function sse_bs_notifications(e, replace, followup) { - - if(sse_bs_active) - return; - - - var manual = false; - - if(typeof replace === 'undefined') - replace = e.data.replace; - - if(typeof followup === 'undefined') - followup = e.data.followup; - - if(typeof e === 'string') { - sse_type = e; - } - else { - manual = true; - sse_offset = 0; - sse_type = e.target.dataset.sse_type; - } - - if(typeof sse_type === 'undefined') - return; - - if(followup || !manual || !($('#nav-' + sse_type + '-sub').hasClass('collapse') && $('#nav-' + sse_type + '-sub').hasClass('show'))) { - - if(sse_offset >= 0) { - $("#nav-" + sse_type + "-loading").show(); - } - - sessionStorage.setItem('notification_open', sse_type); - if(sse_offset !== -1 || replace) { - - var cn_val = (($('#cn-' + sse_type + '-input').length && sse_partial_result) ? $('#cn-' + sse_type + '-input').val().toString().toLowerCase() : ''); - - $("#nav-" + sse_type + "-loading").show(); - - sse_bs_active = true; - - $.ajax({ - type: 'post', - url: '/sse_bs/' + sse_type + '/' + sse_offset, - nquery: encodeURIComponent(cn_val), - data: { sse_rmids } - }).done(function(obj) { - console.log('sse: bootstraping ' + sse_type); - console.log(obj); - sse_bs_active = false; - sse_rmids = []; - $("#nav-" + sse_type + "-loading").hide(); - sse_offset = obj[sse_type].offset; - sse_handleNotifications(obj, replace, followup); - }); - } - else - $("#nav-" + sse_type + "-loading").hide(); - - } - else { - sessionStorage.removeItem('notification_open'); - } -} - -function sse_handleNotifications(obj, replace, followup) { - - var primary_notifications = ['dm', 'home', 'intros', 'register', 'notify', 'files']; - var secondary_notifications = ['network', 'forums', 'all_events', 'pubs']; - var all_notifications = primary_notifications.concat(secondary_notifications); - - all_notifications.forEach(function(type, index) { - if(typeof obj[type] === typeof undefined) - return true; - - if(obj[type].count) { - $('.' + type + '-button').fadeIn(); - if(replace || followup) - $('.' + type + '-update').html(Number(obj[type].count)); - else - $('.' + type + '-update').html(Number(obj[type].count) + Number($('.' + type + '-update').html())); - } - else { - $('.' + type + '-update').html('0'); - $('.' + type + '-button').fadeOut(function() { - sse_setNotificationsStatus(); - }); - } - if(obj[type].notifications.length) - sse_handleNotificationsItems(type, obj[type].notifications, replace, followup); - }); - - sse_setNotificationsStatus(); - - // notice and info - $.jGrowl.defaults.closerTemplate = '
[ ' + aStr.closeAll + ']
'; - - if(obj.notice) { - $(obj.notice.notifications).each(function() { - $.jGrowl(this, { sticky: true, theme: 'notice' }); - }); - } - - if(obj.info) { - $(obj.info.notifications).each(function(){ - $.jGrowl(this, { sticky: false, theme: 'info', life: 10000 }); - }); - } - - // load more notifications if visible notifications count becomes low - if(sse_type && sse_offset != -1 && $('#nav-' + sse_type + '-menu').children().length <= 20) { - sse_offset = 0; - sse_bs_notifications(sse_type, false, true); - } - - -} - -function sse_handleNotificationsItems(notifyType, data, replace, followup) { - - var notifications_tpl = ((notifyType == 'forums') ? decodeURIComponent($("#nav-notifications-forums-template[rel=template]").html().replace('data-src', 'src')) : decodeURIComponent($("#nav-notifications-template[rel=template]").html().replace('data-src', 'src'))); - var notify_menu = $("#nav-" + notifyType + "-menu"); - var notify_loading = $("#nav-" + notifyType + "-loading"); - var notify_count = $("." + notifyType + "-update"); - - if(replace && !followup) { - notify_menu.html(''); - notify_loading.hide(); - } - - $(data).each(function() { - - // do not add a notification if it is already present - if($('#nav-' + notifyType + '-menu .notification[data-b64mid=\'' + this.b64mid + '\']').length) - return true; - - html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.addr,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum, encodeURIComponent(this.mids), this.body); - notify_menu.append(html); - }); - - if(!replace && !followup) { - $("#nav-" + notifyType + "-menu .notification").sort(function(a,b) { - a = new Date(a.dataset.when); - b = new Date(b.dataset.when); - return a > b ? -1 : a < b ? 1 : 0; - }).appendTo('#nav-' + notifyType + '-menu'); - } - - $(document.body).trigger("sticky_kit:recalc"); - $("#nav-" + notifyType + "-menu .notifications-autotime").timeago(); - - if($('#tt-' + notifyType + '-only').hasClass('active')) - $('#nav-' + notifyType + '-menu [data-thread_top=false]').addClass('tt-filter-active'); - - if($('#cn-' + notifyType + '-input').length) { - var filter = $('#cn-' + notifyType + '-input').val().toString().toLowerCase(); - if(filter) { - filter = filter.indexOf('%') == 0 ? filter.substring(1) : filter; - - $('#nav-' + notifyType + '-menu .notification').each(function(i, el) { - var cn = $(el).data('contact_name').toString().toLowerCase(); - var ca = $(el).data('contact_addr').toString().toLowerCase(); - if(cn.indexOf(filter) === -1 && ca.indexOf(filter) === -1) - $(el).addClass('cn-filter-active'); - else - $(el).removeClass('cn-filter-active'); - }); - } - } -} - -function sse_updateNotifications(type, mid) { - - if(type === 'pubs') - return true; - - if(type === 'notify' && (mid !== bParam_mid || sse_type !== 'notify')) - return true; -/* - var count = Number($('.' + type + '-update').html()); - - count--; - - if(count < 1) { - $('.' + type + '-update').html(count); - $('.' + type + '-button').fadeOut(function() { - sse_setNotificationsStatus(); - }); - } - else { - $('.' + type + '-update').html(count); - } -*/ - - $('#nav-' + type + '-menu .notification[data-b64mid=\'' + mid + '\']').fadeOut(function() { - this.remove(); - }); - -} - -function sse_setNotificationsStatus() { - var primary_notifications = ['dm', 'home', 'intros', 'register', 'notify', 'files']; - var secondary_notifications = ['network', 'forums', 'all_events', 'pubs']; - var all_notifications = primary_notifications.concat(secondary_notifications); - - var primary_available = false; - var any_available = false; - - all_notifications.forEach(function(type, index) { - if($('.' + type + '-button').css('display') == 'block') { - any_available = true; - if(primary_notifications.indexOf(type) > -1) - primary_available = true; - } - }); - - if(primary_available) { - $('.notifications-btn-icon').removeClass('fa-exclamation-circle'); - $('.notifications-btn-icon').addClass('fa-exclamation-triangle'); - } - else { - $('.notifications-btn-icon').removeClass('fa-exclamation-triangle'); - $('.notifications-btn-icon').addClass('fa-exclamation-circle'); - } - - if(any_available) { - $('.notifications-btn').css('opacity', 1); - $('#no_notifications').hide(); - $('#notifications').show(); - } - else { - $('.notifications-btn').css('opacity', 0.5); - $('#navbar-collapse-1').removeClass('show'); - $('#no_notifications').show(); - $('#notifications').hide(); - } - -} - -function sse_fallback() { - $.get('/sse', function(obj) { - if(! obj) - return; - - console.log('sse fallback'); - console.log(obj); - - sse_handleNotifications(obj, false, false); - }); -} - function makeid(length) { var result = ''; var characters = 'abcdef0123456789'; @@ -2051,3 +1725,4 @@ function makeid(length) { } return result; } + diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js index b321382bd..ddcde4fcd 100644 --- a/view/js/mod_hq.js +++ b/view/js/mod_hq.js @@ -1,10 +1,20 @@ -$(document).on('click', '#jot-toggle', function(e) { - e.preventDefault(); - e.stopPropagation(); - - $(this).toggleClass('active'); - $(window).scrollTop(0); - $('#jot-popup').toggle(); - $('#profile-jot-text').focus(); +$(document).ready(function() { + + $(document).on('click', '#jot-toggle', function(e) { + e.preventDefault(); + e.stopPropagation(); + $(window).scrollTop(0); + $('#jot-popup').toggle(); + $('#profile-jot-text').focus(); + + }); + + $(document).on('click', '#notes-toggle', function(e) { + e.preventDefault(); + e.stopPropagation(); + $(window).scrollTop(0); + $('#personal-notes').toggleClass('d-none'); + $('#note-text').focus(); + }); }); -- cgit v1.2.3 From c268bc327a9c82acf05999039b0b3ab7191646eb Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 17 Jun 2021 10:14:23 +0000 Subject: fix issues with browser back button and minor cleanup --- view/js/main.js | 6 +++++- view/js/mod_hq.js | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index a3f238a45..78bd790cd 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -204,8 +204,12 @@ $(document).ready(function() { }); window.onpopstate = function(e) { - if(e.state !== null && e.state.b64mid !== bParam_mid) + if(e.state !== null && e.state.b64mid !== bParam_mid) { prepareLiveUpdate(e.state.b64mid, ''); + $('.message').removeClass('active'); + $('[data-b64mid="' + e.state.b64mid + '"].message').addClass('active'); + } + }; //mod_mail only diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js index ddcde4fcd..0a3939913 100644 --- a/view/js/mod_hq.js +++ b/view/js/mod_hq.js @@ -1,20 +1,13 @@ $(document).ready(function() { $(document).on('click', '#jot-toggle', function(e) { - e.preventDefault(); - e.stopPropagation(); $(window).scrollTop(0); $('#jot-popup').toggle(); - $('#profile-jot-text').focus(); - }); $(document).on('click', '#notes-toggle', function(e) { - e.preventDefault(); - e.stopPropagation(); $(window).scrollTop(0); $('#personal-notes').toggleClass('d-none'); - $('#note-text').focus(); }); }); -- cgit v1.2.3 From ec22ca75536e4c85b7a2721154a9d4e7148b2ffc Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 18 Jun 2021 09:58:00 +0000 Subject: css and js fixes --- view/js/mod_hq.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'view/js') diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js index 0a3939913..362045412 100644 --- a/view/js/mod_hq.js +++ b/view/js/mod_hq.js @@ -3,11 +3,13 @@ $(document).ready(function() { $(document).on('click', '#jot-toggle', function(e) { $(window).scrollTop(0); $('#jot-popup').toggle(); + $('#profile-jot-text').focus(); }); $(document).on('click', '#notes-toggle', function(e) { $(window).scrollTop(0); $('#personal-notes').toggleClass('d-none'); + $('#note-text').focus(); }); }); -- cgit v1.2.3 From 6e91bee0ba605b938bddf0570e747d6d7be1c712 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 23 Jun 2021 15:52:04 +0000 Subject: some work on streamlining mod photos --- view/js/mod_photos.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'view/js') diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js index af675e31c..41b8ed560 100644 --- a/view/js/mod_photos.js +++ b/view/js/mod_photos.js @@ -8,11 +8,12 @@ $(document).ready(function() { UploadInit(); } - $("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) { - $("#photo-edit-newtag").val('@' + data.name); - }); - + //$("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) { + //$("#photo-edit-newtag").val('@' + data.name); + //}); + $(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1"); + $('textarea').editor_autocomplete(baseurl+"/acl"); $('textarea').bbco_autocomplete('bbcode'); showHideBodyTextarea(); @@ -70,12 +71,12 @@ function UploadInit() { progress: function(e,data) { - // there will only be one file, the one we are looking for + // there will only be one file, the one we are looking for $(data.files).each( function() { var idx = this.count; - // Dynamically update the percentage complete displayed in the file upload list + // Dynamically update the percentage complete displayed in the file upload list $('#upload-progress-' + idx).html(Math.round(data.loaded / data.total * 100) + '%'); $('#upload-progress-bar-' + idx).css('background-size', Math.round(data.loaded / data.total * 100) + '%'); @@ -283,7 +284,7 @@ function UploadFile(file, idx) { $('#upload-progress-' + idx).html('ERROR'); }); - // POST to the entire cloud path + // POST to the entire cloud path xhr.open('post', $('#photos-upload-form').attr( 'action' ), true); var formfields = $("#photos-upload-form").serializeArray(); -- cgit v1.2.3 From 167db22e15c72c32cd67ce1a2b242dc4527e0b64 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 24 Jun 2021 19:31:19 +0000 Subject: slightly refactor for desktop notifications and fix minor issues --- view/js/main.js | 26 ++++++++++++++++++++++++++ view/js/mod_hq.js | 7 +++++-- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 78bd790cd..a286d53bf 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1730,3 +1730,29 @@ function makeid(length) { return result; } +function push_notification_request(e) { + if (!('Notification' in window)) { + alert('This browser does not support push notifications'); + } + else if (Notification.permission !== 'granted') { + Notification.requestPermission(function(permission) { + if(permission === 'granted') { + $(e.target).closest('button').hide(); + } + }); + } +} + + +function push_notification(body, title) { + let options = { + body: body, + icon: '/images/hz-64.png', + silent: false + } + + let n = new Notification(title, options); + n.onclick = function (event) { + setTimeout(n.close.bind(n), 300); + } +} diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js index 362045412..7583a4ddd 100644 --- a/view/js/mod_hq.js +++ b/view/js/mod_hq.js @@ -1,15 +1,18 @@ $(document).ready(function() { - $(document).on('click', '#jot-toggle', function(e) { + $(document).on('click', '.jot-toggle', function(e) { $(window).scrollTop(0); $('#jot-popup').toggle(); $('#profile-jot-text').focus(); }); - $(document).on('click', '#notes-toggle', function(e) { + $(document).on('click', '.notes-toggle', function(e) { $(window).scrollTop(0); $('#personal-notes').toggleClass('d-none'); $('#note-text').focus(); }); + $(document).on('hz:handleNetworkNotificationsItems', function(e, obj) { + push_notification(obj.message, obj.name); + }); }); -- cgit v1.2.3 From d42a998e49ca42696022316a8a527c39fc2fdf57 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 25 Jun 2021 06:24:46 +0000 Subject: strip html tags from notification message --- view/js/mod_hq.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js index 7583a4ddd..87d9f1ef3 100644 --- a/view/js/mod_hq.js +++ b/view/js/mod_hq.js @@ -13,6 +13,7 @@ $(document).ready(function() { }); $(document).on('hz:handleNetworkNotificationsItems', function(e, obj) { - push_notification(obj.message, obj.name); + push_notification($('

' + obj.message + '

').text(), obj.name); }); + }); -- cgit v1.2.3 From 4f328740dc5f2492b33ee2953e8bad2b84b98243 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 25 Jun 2021 10:53:37 +0000 Subject: more work on notifications --- view/js/main.js | 9 +++++---- view/js/mod_hq.js | 6 +++++- view/js/mod_settings.js | 8 +++++++- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index a286d53bf..9ab66833c 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1737,22 +1737,23 @@ function push_notification_request(e) { else if (Notification.permission !== 'granted') { Notification.requestPermission(function(permission) { if(permission === 'granted') { - $(e.target).closest('button').hide(); + $(e.target).closest('div').hide(); } }); } } -function push_notification(body, title) { +function push_notification(title, body, href) { let options = { body: body, + data: href, icon: '/images/hz-64.png', silent: false } let n = new Notification(title, options); - n.onclick = function (event) { - setTimeout(n.close.bind(n), 300); + n.onclick = function (e) { + window.location.href = e.target.data; } } diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js index 87d9f1ef3..48fbf1f9b 100644 --- a/view/js/mod_hq.js +++ b/view/js/mod_hq.js @@ -13,7 +13,11 @@ $(document).ready(function() { }); $(document).on('hz:handleNetworkNotificationsItems', function(e, obj) { - push_notification($('

' + obj.message + '

').text(), obj.name); + push_notification( + obj.name, + $('

' + obj.message + '

').text(), + baseurl + '/hq/' + obj.b64mid + ); }); }); diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js index d3392c748..3e91dac9a 100644 --- a/view/js/mod_settings.js +++ b/view/js/mod_settings.js @@ -24,8 +24,14 @@ $(document).ready(function() { loadPermcat(permName); }); + if (Notification.permission !== 'granted') { + $('#desktop-notifications-info').show(); + } - + $('#desktop-notifications-request').on('click', function(e) { + e.preventDefault(); + push_notification_request(e); + }); }); -- cgit v1.2.3 From 652d083766a4a0b11151fe1f196a49da533d6349 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 29 Jun 2021 07:49:19 +0000 Subject: implement removing of notifications/preview-messages of deleted items --- view/js/main.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 9ab66833c..9ef81b72c 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1274,7 +1274,7 @@ function dopin(id) { }); } -function dropItem(url, object) { +function dropItem(url, object, b64mid) { var confirm = confirmDelete(); if(confirm) { var id = url.split('/')[2]; @@ -1286,11 +1286,18 @@ function dropItem(url, object) { $('body').css('cursor', 'auto'); }); - if($('#wall-item-pinned-' + id).length) + if($('#wall-item-pinned-' + id).length) { $.post('pin/pin', { 'id' : id }); + } + + if (typeof b64mid !== typeof undefined) { + $('[data-b64mid=\'' + b64mid + '\']').fadeOut(function() { + this.remove(); + }); + } return true; - } + } else { return false; } -- cgit v1.2.3 From 197d15b7de34c670934cfe873e7c67233e090009 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 29 Jun 2021 09:53:40 +0000 Subject: only remove elements after the delete has happened --- view/js/main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 9ef81b72c..f427df8ad 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1284,18 +1284,18 @@ function dropItem(url, object, b64mid) { $.get(url, function() { $(object + ', #pinned-wrapper-' + id).remove(); $('body').css('cursor', 'auto'); + + if (typeof b64mid !== typeof undefined) { + $('[data-b64mid=\'' + b64mid + '\']').fadeOut(function() { + this.remove(); + }); + } }); if($('#wall-item-pinned-' + id).length) { $.post('pin/pin', { 'id' : id }); } - if (typeof b64mid !== typeof undefined) { - $('[data-b64mid=\'' + b64mid + '\']').fadeOut(function() { - this.remove(); - }); - } - return true; } else { -- cgit v1.2.3 From d45df824edaf6f05ca33df31ece56846809685d0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 5 Jul 2021 10:42:36 +0200 Subject: redbasic: close left aside if hq control button is clicked --- view/js/mod_hq.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'view/js') diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js index 48fbf1f9b..ad77e0af0 100644 --- a/view/js/mod_hq.js +++ b/view/js/mod_hq.js @@ -2,12 +2,14 @@ $(document).ready(function() { $(document).on('click', '.jot-toggle', function(e) { $(window).scrollTop(0); + $(document).trigger('hz:hqControlsClickAction'); $('#jot-popup').toggle(); $('#profile-jot-text').focus(); }); $(document).on('click', '.notes-toggle', function(e) { $(window).scrollTop(0); + $(document).trigger('hz:hqControlsClickAction'); $('#personal-notes').toggleClass('d-none'); $('#note-text').focus(); }); -- cgit v1.2.3 From 62606bf006c83c7a7ad44121feebedd81cd43a79 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 16 Jul 2021 11:42:54 +0200 Subject: photo upload: always show the textarea so that text and tags can be added even if no status post is sent --- view/js/mod_photos.js | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'view/js') diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js index 41b8ed560..1ce410a1b 100644 --- a/view/js/mod_photos.js +++ b/view/js/mod_photos.js @@ -8,24 +8,11 @@ $(document).ready(function() { UploadInit(); } - //$("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) { - //$("#photo-edit-newtag").val('@' + data.name); - //}); - $(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1"); $('textarea').editor_autocomplete(baseurl+"/acl"); $('textarea').bbco_autocomplete('bbcode'); - showHideBodyTextarea(); - }); -function showHideBodyTextarea() { - if( $('#id_visible').is(':checked')) - $('#body-textarea').slideDown(); - else - $('#body-textarea').slideUp(); -} - // initialize function UploadInit() { -- cgit v1.2.3 From 4f15c0880557ce880a6b119ac244a57258d50e60 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 16 Jul 2021 13:48:35 +0200 Subject: more work on moving notifications handling from main.js to the notifications widget --- view/js/main.js | 50 +++++++++----------------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index f427df8ad..f5d7e7fde 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -548,8 +548,10 @@ function markRead(notifType) { $('#nav-' + notifType + '-menu').html(''); $('#nav-' + notifType + '-sub').removeClass('show'); sessionStorage.removeItem('notification_open'); - sse_setNotificationsStatus(); + $(document).trigger('hz:sse_setNotificationsStatus'); }); + + } function markItemRead(itemId) { @@ -717,52 +719,18 @@ function updateConvItems(mode,data) { } } - // take care of the notifications count updates - var nmids = $(this).data('b64mids'); - - nmids.forEach(function(nmid, index) { - - sse_rmids.push(nmid); - - if($('.notification[data-b64mid=\'' + nmid + '\']').length) { - $('.notification[data-b64mid=\'' + nmid + '\']').each(function() { - var n = this.parentElement.id.split('-'); - return sse_updateNotifications(n[1], nmid); - }); - } - - // special handling for forum notifications - $('.notification-forum').filter(function() { - var fmids = decodeURIComponent($(this).data('b64mids')); - var n = this.parentElement.id.split('-'); - if(fmids.indexOf(nmid) > -1) { - var fcount = Number($('.' + n[1] + '-update').html()); - fcount--; - $('.' + n[1] + '-update').html(fcount); - if(fcount < 1) - $('.' + n[1] + '-button').fadeOut(); - - var count = Number($(this).find('.badge-secondary').html()); - count--; - $(this).find('.badge-secondary').html(count); - if(count < 1) - $(this).remove(); - } - }); - - - }); - - sse_setNotificationsStatus(); + $(document).trigger('hz:sse_setNotificationsStatus', [$(this).data('b64mids')]); }); $(window).scrollTop(scroll_position); if(followUpPageLoad) - sse_bs_counts(); + $(document).trigger('hz:sse_bs_counts'); + else - sse_bs_init(); + $(document).trigger('hz:sse_bs_init'); + if(commentBusy) { commentBusy = false; @@ -902,7 +870,7 @@ function updateInit() { liveUpdate(); } else { - sse_bs_init(); + $(document).trigger('hz:sse_bs_init'); } if($('#live-photos').length || $('#live-cards').length || $('#live-articles').length ) { -- cgit v1.2.3 From 95fb66b4332452e4cb0c45e6cceb3d77656e8b30 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 16 Jul 2021 13:53:32 +0200 Subject: code style --- view/js/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index f5d7e7fde..9f794c2ea 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -725,12 +725,12 @@ function updateConvItems(mode,data) { $(window).scrollTop(scroll_position); - if(followUpPageLoad) + if(followUpPageLoad) { $(document).trigger('hz:sse_bs_counts'); - - else + } + else { $(document).trigger('hz:sse_bs_init'); - + } if(commentBusy) { commentBusy = false; -- cgit v1.2.3