aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
Diffstat (limited to 'view/js')
-rw-r--r--view/js/autocomplete.js43
-rw-r--r--view/js/main.js77
-rw-r--r--view/js/mod_help.js6
3 files changed, 114 insertions, 12 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 01def9900..be632a07e 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -60,7 +60,7 @@ function contact_format(item) {
var desc = ((item.label) ? item.nick + ' ' + item.label : item.nick);
if(typeof desc === 'undefined') desc = '';
if(desc) desc = ' ('+desc+')';
- return "<div class='{0} dropdown-item dropdown-notification clearfix' title='{4}'><img class='menu-img-2' src='{1}'><span class='contactname'>{2}</span><span class='dropdown-sub-text'>{3}</span></div>".format(item.taggable, item.photo, item.name, desc, item.link);
+ return "<div class='{0} dropdown-item dropdown-notification clearfix' title='{4}'><img class='menu-img-2' src='{1}'><span class='contactname'>{2}</span><span class='dropdown-sub-text'>{3}</span></div>".format(item.taggable, item.photo, item.name, desc, typeof(item.link) !== 'undefined' ? item.link : desc.replace('(','').replace(')',''));
}
else
return "<div>" + item.text + "</div>";
@@ -74,6 +74,10 @@ function bbco_format(item) {
return "<div class='dropdown-item'>" + item + "</div>";
}
+function tag_format(item) {
+ return "<div class='dropdown-item'>" + '#' + item.text + "</div>";
+}
+
function editor_replace(item) {
if(typeof item.replace !== 'undefined') {
return '$1$2' + item.replace;
@@ -194,7 +198,7 @@ function string2bb(element) {
// Autocomplete forums
forums = {
- match: /(^|\s)(\!)([^ \n]+)$/,
+ match: /(^|\s)(\!\!*)([^ \n]+)$/,
index: 3,
search: function(term, callback) { contact_search(term, callback, backend_url, 'f', extra_channels, spinelement=false); },
replace: editor_replace,
@@ -202,6 +206,17 @@ function string2bb(element) {
};
+ // Autocomplete hashtags
+ tags = {
+ match: /(^|\s)(\#)([^ \n]{2,})$/,
+ index: 3,
+ search: function(term, callback) { $.getJSON('/hashtags/' + '$f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.toLowerCase().indexOf(term.toLowerCase()) === 0 ? entry : null; })); }); },
+ replace: function(item) { return "$1$2" + item.text + ' '; },
+ context: function(text) { return text.toLowerCase(); },
+ template: tag_format
+ };
+
+
smilies = {
match: /(^|\s)(:[a-z_:]{2,})$/,
index: 2,
@@ -211,7 +226,7 @@ function string2bb(element) {
template: smiley_format
};
this.attr('autocomplete','off');
- this.textcomplete([contacts,forums,smilies], {className:'acpopup', zIndex:1020});
+ this.textcomplete([contacts,forums,smilies,tags], {className:'acpopup', zIndex:1020});
};
})( jQuery );
@@ -228,8 +243,28 @@ function string2bb(element) {
replace: basic_replace,
template: contact_format,
};
+
+ // Autocomplete forums
+ forums = {
+ match: /(^\!)([^\n]{3,})$/,
+ index: 2,
+ search: function(term, callback) { contact_search(term, callback, backend_url, 'f', [], spinelement='#nav-search-spinner'); },
+ replace: basic_replace,
+ template: contact_format
+ };
+
+ // Autocomplete hashtags
+ tags = {
+ match: /(^\#)([^ \n]{3,})$/,
+ index: 2,
+ search: function(term, callback) { $.getJSON('/hashtags/' + '$f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.toLowerCase().indexOf(term.toLowerCase()) === 0 ? entry : null; })); }); },
+ replace: function(item) { return "$1" + item.text + ' '; },
+ context: function(text) { return text.toLowerCase(); },
+ template: tag_format
+ };
+
this.attr('autocomplete', 'off');
- var a = this.textcomplete([contacts], {className:'acpopup', maxCount:100, zIndex: 1020, appendTo:'nav'});
+ var a = this.textcomplete([contacts,forums,tags], {className:'acpopup', maxCount:100, zIndex: 1020, appendTo:'nav'});
a.on('textComplete:select', function(e, value, strategy) { submit_form(this); });
};
})( jQuery );
diff --git a/view/js/main.js b/view/js/main.js
index 98a756fff..acb9b462f 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -25,13 +25,14 @@ var liveRecurse = 0;
var savedTitle = '';
var initialLoad = true;
-// Clear the session storage if we switch channel or log out
+// Clear the session and local storage if we switch channel or log out
var cache_uid = '';
if(sessionStorage.getItem('uid') !== null) {
cache_uid = sessionStorage.getItem('uid');
}
if(cache_uid !== localUser.toString()) {
sessionStorage.clear();
+ localStorage.clear();
sessionStorage.setItem('uid', localUser.toString());
}
@@ -166,6 +167,7 @@ function handle_comment_form(e) {
$('#' + commentElm).addClass('expanded').removeAttr('placeholder');
$('#' + commentElm).attr('tabindex','9');
$('#' + submitElm).attr('tabindex','10');
+
form.find(':not(:visible)').show();
}
@@ -185,6 +187,37 @@ function handle_comment_form(e) {
form.find(':not(.comment-edit-text)').hide();
}
});
+
+ var commentSaveTimer = null;
+ var emptyCommentElm = form.find('.comment-edit-text').attr('id');
+ var convId = emptyCommentElm.replace('comment-edit-text-','');
+ $(document).on('focusout','#' + emptyCommentElm,function(e){
+ if(commentSaveTimer)
+ clearTimeout(commentSaveTimer);
+ commentSaveChanges(convId,true);
+ commentSaveTimer = null;
+ });
+
+ $(document).on('focusin','#' + emptyCommentElm,function(e){
+ commentSaveTimer = setTimeout(function () {
+ commentSaveChanges(convId,false);
+ },10000);
+ });
+
+ function commentSaveChanges(convId,isFinal = false) {
+ if(auto_save_draft) {
+ tmp = $('#' + emptyCommentElm).val();
+ if(tmp) {
+ localStorage.setItem("comment_body-" + convId, tmp);
+ }
+ else {
+ localStorage.removeItem("comment_body-" + convId);
+ }
+ if( !isFinal) {
+ commentSaveTimer = setTimeout(commentSaveChanges,10000,convId);
+ }
+ }
+ }
}
function commentClose(obj, id) {
@@ -436,6 +469,14 @@ function handleNotifications(data) {
$('.notifications-btn-icon').removeClass('fa-exclamation-triangle');
$('.notifications-btn-icon').addClass('fa-exclamation-circle');
}
+ if(data.all_events_today) {
+ $('.all_events-update').removeClass('badge-secondary');
+ $('.all_events-update').addClass('badge-danger');
+ }
+ else {
+ $('.all_events-update').removeClass('badge-danger');
+ $('.all_events-update').addClass('badge-secondary');
+ }
$.each(data, function(index, item) {
//do not process those
@@ -557,8 +598,10 @@ function updateConvItems(mode,data) {
$('.thread-wrapper.toplevel_item',data).each(function() {
var ident = $(this).attr('id');
-
+ var convId = ident.replace('thread-wrapper-','');
var commentWrap = $('#'+ident+' .collapsed-comments').attr('id');
+
+
var itmId = 0;
var isVisible = false;
@@ -569,6 +612,9 @@ function updateConvItems(mode,data) {
if($('#collapsed-comments-'+itmId).is(':visible'))
isVisible = true;
+
+
+
// insert the content according to the mode and first_page
// and whether or not the content exists already (overwrite it)
@@ -590,6 +636,24 @@ function updateConvItems(mode,data) {
if(isVisible)
showHideComments(itmId);
+ var commentBody = localStorage.getItem("comment_body-" + convId);
+
+ if(commentBody) {
+ var commentElm = $('#comment-edit-text-' + convId);
+ if(auto_save_draft) {
+ if($(commentElm).val() === '') {
+ $('#comment-edit-form-' + convId).show();
+ $(commentElm).addClass("expanded");
+ openMenu("comment-tools-" + convId);
+ $(commentElm).val(commentBody);
+ }
+ } else {
+ localStorage.removeItem("comment_body-" + convId);
+ }
+ }
+
+
+
// trigger the autotime function on all newly created content
$("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
@@ -1032,18 +1096,21 @@ function dostar(ident) {
if(data.result == 1) {
$('#starred-' + ident).addClass('starred');
$('#starred-' + ident).removeClass('unstarred');
- $('#starred-' + ident).addClass('fa-star-full');
+ $('#starred-' + ident).addClass('fa-star');
$('#starred-' + ident).removeClass('fa-star-o');
$('#star-' + ident).addClass('hidden');
$('#unstar-' + ident).removeClass('hidden');
+ var btn_tpl = '<div class="btn-group" id="star-button-' + ident + '"><button type="button" class="btn btn-outline-secondary btn-sm wall-item-like" onclick="dostar(' + ident + ');"><i class="fa fa-star"></i></button></div>'
+ $('#wall-item-tools-left-' + ident).prepend(btn_tpl);
}
else {
$('#starred-' + ident).addClass('unstarred');
$('#starred-' + ident).removeClass('starred');
$('#starred-' + ident).addClass('fa-star-o');
- $('#starred-' + ident).removeClass('fa-star-full');
+ $('#starred-' + ident).removeClass('fa-star');
$('#star-' + ident).removeClass('hidden');
$('#unstar-' + ident).addClass('hidden');
+ $('#star-button-' + ident).remove();
}
$('#like-rotator-' + ident).hide();
});
@@ -1098,6 +1165,7 @@ function post_comment(id) {
$("#comment-edit-form-" + id).serialize(),
function(data) {
if(data.success) {
+ localStorage.removeItem("comment_body-" + id);
$("#comment-edit-preview-" + id).hide();
$("#comment-edit-wrapper-" + id).hide();
$("#comment-edit-text-" + id).val('');
@@ -1422,7 +1490,6 @@ function b2h(s) {
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
- // FIXME - add zid()
rep(/\[zrl=([^\]]+)\](.*?)\[\/zrl\]/gi,"<a href=\"$1" + '?f=&zid=' + zid + "\">$2</a>");
rep(/\[zrl\](.*?)\[\/zrl\]/gi,"<a href=\"$1" + '?f=&zid=' + zid + "\">$1</a>");
rep(/\[zmg=(.*?)x(.*?)\](.*?)\[\/zmg\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3" + '?f=&zid=' + zid + "\" />");
diff --git a/view/js/mod_help.js b/view/js/mod_help.js
index 8ee89dd61..107845c04 100644
--- a/view/js/mod_help.js
+++ b/view/js/mod_help.js
@@ -21,7 +21,7 @@ $(document).ready(function () {
var pageName = url.href.split('/').pop().split('#').shift().split('?').shift();
var linkName = $(this).attr('href').split('/').pop();
if (pageName === linkName) {
- var tocUl = $(this).closest('a').append('<ul>').find('ul');
+ var tocUl = $(this).closest('a').after('<ul>').next('ul');
tocUl.removeClass(); // Classes are automatically added to <ul> elements by something else
tocUl.toc({content: "#doco-content", headings: "h3"});
tocUl.addClass('toc-content');
@@ -53,7 +53,7 @@ $(document).ready(function () {
.removeClass('selected-doco-nav')
.eq(i).addClass('selected-doco-nav');
if (typeof ($('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]) !== 'undefined') {
- window.history.pushState({}, '', location.href.split('#')[0] + '#' + $('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]);
+ window.history.replaceState({}, '', location.href.split('#')[0] + '#' + $('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]);
}
}
});
@@ -100,7 +100,7 @@ $(document).ready(function () {
}
// Update the address bar to reflect the loaded language
- window.history.pushState({}, '', '/' + pathParts.join('/'));
+ window.history.replaceState({}, '', '/' + pathParts.join('/'));
// Highlight the language in the language selector that is currently viewed
$('.lang-selector').find('.lang-choice:contains("' + help_language + '")').addClass('active');