From 69ef7cf1680cebed3512e918de30c09ac9ce0be4 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 May 2021 08:42:08 +0000 Subject: remove more mail leftovers --- view/js/main.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 6c418b213..a20c82593 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1446,24 +1446,6 @@ function preview_post() { return true; } -function preview_mail() { - $("#mail-preview").val("1"); - $("#mail-preview-content").show(); - $.post( - "mail", - $("#prvmail-form").serialize(), - function(data) { - if(data.preview) { - $("#mail-preview-content").html(data.preview); - $("#mail-preview-content" + " a").click(function() { return false; }); - } - }, - "json" - ); - $("#mail-preview").val("0"); - return true; -} - function bin2hex(s) { // Converts the binary representation of data to hex // @@ -1817,7 +1799,7 @@ function sse_bs_notifications(e, replace, followup) { function sse_handleNotifications(obj, replace, followup) { - var primary_notifications = ['dm', 'home', 'intros', 'register', 'mail', 'notify', 'files']; + 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); @@ -1951,7 +1933,7 @@ function sse_updateNotifications(type, mid) { } function sse_setNotificationsStatus() { - var primary_notifications = ['dm', 'home', 'intros', 'register', 'mail', 'notify', 'files']; + 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); -- cgit v1.2.3 From 19bb96121b852d9bb3eb879cd7fe903e77805c4a Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 May 2021 09:58:18 +0000 Subject: move mark notifications read code to mod notifications --- view/js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index a20c82593..0897fbd21 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -537,7 +537,7 @@ function closeMenu(theID) { } function markRead(notifType) { - $.get('ping?f=&markRead='+notifType); + $.get('notifications?f=&markRead='+notifType); $('.' + notifType + '-button').fadeOut(function() { $("." + notifType + "-update").html('0'); $('#nav-' + notifType + '-menu').html(''); @@ -548,7 +548,7 @@ function markRead(notifType) { } function markItemRead(itemId) { - $.get('ping?f=&markItemRead='+itemId); + $.get('notifications?f=&markItemRead='+itemId); $('.unseen-wall-indicator-'+itemId).remove(); } -- cgit v1.2.3 From 25497336bba4ffc8fc702bfc5126e66130bd9cbc Mon Sep 17 00:00:00 2001 From: Hilmar Runge Date: Sat, 5 Jun 2021 07:51:38 +0000 Subject: Changed behavior in the user interaction of the languages selection. Now works... --- view/js/main.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 6c418b213..11e0f812c 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -78,6 +78,65 @@ $(document).ready(function() { } }); + // @hilmar |-> + if ( typeof(window.tao) == 'undefined' ) { + window.tao = {}; + } + if ( typeof(window.tao.zin) == 'undefined' ) { + tao.zin = { syslc: '', syslcs: {}, htm: '', me: '', debug: '' }; + tao.zin.axim = '
'; + $('.navbar-app[href*="/lang"]').attr({"data-toggle": "dropdown", "aria-expand": "true", "id": "zintog"}) + .removeAttr('href').addClass('zinlcx zinlcxp dropdown dropdown-toggle'); + $('.dropdown-item[href*="/lang"]').addClass('zinlcxmi zinlcx').removeAttr('href').css('cursor','pointer'); + } + $('.zinlcx').on('click', function(e) { + if (tao.zin.syslc == '') { + $('.zinlcx').append(tao.zin.axim); + $.ajax({ + type: 'POST', url: 'lang', + data: { zinlc: '??' } + }).done( function(re) { + tao.zin.re = JSON.parse(re); + tao.zin.syslc = tao.zin.re.lc; + tao.zin.syslcs = tao.zin.re.lcs; + tao.zin.htm = '
    '; + $.each( tao.zin.syslcs, function( k, v ) { + tao.zin.htm += '
  • ' + k + ' ' + v + '
  • '; + }); + tao.zin.htm += '
'; + $('.zinpax').remove(); + $('.zinlcx').append(tao.zin.htm); + $('.zinlcxp > ul').addClass('dropdown dropdown-menu dropdown-menu-right').css('left','-16em'); + }); + return false; + } else { + if (e.target.id == '') { + // noop click on lang again + return false; + } + tao.zin.me = e.target.id.substr(5); + $('#right_aside_wrapper').append(tao.zin.axim); + $.ajax({ + type: 'POST', url: 'lang', + data: { zinlc: tao.zin.me } + }).done( function(re) { + tao.zin.re = JSON.parse(re); + location.reload(true); + }); + } + }); + $('#zintog').on('click', function() { + $('.zinlcs').toggle(); + }); + $('#dropdown-menu').on('shown.bs.dropdown', function() { + tao.zin.debug += 'e,'; + //$('.zinlcs').removeAttr('display'); + }) + .on('mouseleave', function() { + $(this).trigger('click'); + }); + // @hilmar <-| + var tf = new Function('n', 's', 'var k = s.split("/")['+aStr['plural_func']+']; return (k ? k : s);'); jQuery.timeago.settings.strings = { -- 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/main.js | 439 ++++++++------------------------------------------------ 1 file changed, 57 insertions(+), 382 deletions(-) (limited to 'view/js/main.js') 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; } + -- 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 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'view/js/main.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 -- cgit v1.2.3