2021-08-28 00:37:32 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let src = null;
|
|
|
|
let prev = null;
|
|
|
|
let livetime = null;
|
|
|
|
let msie = false;
|
|
|
|
let stopped = false;
|
|
|
|
let totStopped = false;
|
|
|
|
let timer = null;
|
2021-08-24 04:44:37 +00:00
|
|
|
let alertstimer = null;
|
2021-08-10 21:37:00 +00:00
|
|
|
let pr = 0;
|
|
|
|
let liking = 0;
|
|
|
|
let in_progress = false;
|
|
|
|
let langSelect = false;
|
|
|
|
let commentBusy = false;
|
|
|
|
let last_popup_menu = null;
|
|
|
|
let last_popup_button = null;
|
|
|
|
let scroll_next = false;
|
|
|
|
let next_page = 1;
|
|
|
|
let page_load = true;
|
|
|
|
let loadingPage = true;
|
|
|
|
let pageHasMoreContent = true;
|
|
|
|
let divmore_height = 400;
|
|
|
|
let last_filestorage_id = null;
|
|
|
|
let mediaPlaying = false;
|
|
|
|
let contentHeightDiff = 0;
|
|
|
|
let liveRecurse = 0;
|
|
|
|
let savedTitle = '';
|
|
|
|
let initialLoad = true;
|
|
|
|
let cached_data = [];
|
2021-08-11 02:25:23 +00:00
|
|
|
let mode = '';
|
|
|
|
let update_url = '';
|
|
|
|
let update_mode = '';
|
|
|
|
let orgHeight = 0;
|
2018-01-24 10:16:51 +00:00
|
|
|
|
2019-01-14 00:08:26 +00:00
|
|
|
$.ajaxPrefilter(function( options, original_Options, jqXHR ) {
|
|
|
|
options.async = true;
|
|
|
|
});
|
2021-08-27 05:15:24 +00:00
|
|
|
$.ajaxSetup({cache: false});
|
2019-01-14 00:08:26 +00:00
|
|
|
|
2021-08-16 21:21:42 +00:00
|
|
|
if ('serviceWorker' in navigator) {
|
2021-08-22 21:22:47 +00:00
|
|
|
navigator.serviceWorker.register('/ServiceWorker.js', { scope: '/' }).then(function(registration) {
|
2021-08-23 01:41:24 +00:00
|
|
|
console.log('Service worker registered. scope is', registration.scope);
|
|
|
|
}).catch(function(error) {
|
|
|
|
console.log('Service worker registration failed because ' + error);
|
2021-08-22 21:22:47 +00:00
|
|
|
});
|
2021-08-16 21:21:42 +00:00
|
|
|
}
|
|
|
|
|
2018-04-11 10:37:25 +00:00
|
|
|
// Clear the session and local storage if we switch channel or log out
|
2021-08-10 21:37:00 +00:00
|
|
|
let cache_uid = '';
|
2018-01-24 10:16:51 +00:00
|
|
|
if(sessionStorage.getItem('uid') !== null) {
|
|
|
|
cache_uid = sessionStorage.getItem('uid');
|
|
|
|
}
|
|
|
|
if(cache_uid !== localUser.toString()) {
|
|
|
|
sessionStorage.clear();
|
2018-04-11 10:37:25 +00:00
|
|
|
localStorage.clear();
|
2018-01-24 10:16:51 +00:00
|
|
|
sessionStorage.setItem('uid', localUser.toString());
|
|
|
|
}
|
2017-11-28 10:15:19 +00:00
|
|
|
|
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let region = 0;
|
2020-02-22 05:15:06 +00:00
|
|
|
|
2017-11-28 10:15:19 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
$(document).on('click focus', '.comment-edit-form', handle_comment_form);
|
|
|
|
|
|
|
|
jQuery.timeago.settings.strings = {
|
|
|
|
prefixAgo : aStr['t01'],
|
|
|
|
prefixFromNow : aStr['t02'],
|
|
|
|
suffixAgo : aStr['t03'],
|
|
|
|
suffixFromNow : aStr['t04'],
|
|
|
|
seconds : aStr['t05'],
|
|
|
|
minute : aStr['t06'],
|
|
|
|
minutes : aStr['t07'],
|
|
|
|
hour : aStr['t08'],
|
|
|
|
hours : aStr['t09'],
|
|
|
|
day : aStr['t10'],
|
|
|
|
days : aStr['t11'],
|
|
|
|
month : aStr['t12'],
|
|
|
|
months : aStr['t13'],
|
|
|
|
year : aStr['t14'],
|
|
|
|
years : aStr['t15'],
|
|
|
|
wordSeparator : aStr['t16'],
|
|
|
|
numbers : aStr['t17'],
|
|
|
|
};
|
|
|
|
|
2020-05-03 22:22:37 +00:00
|
|
|
jQuery.timeago.settings.allowFuture = true;
|
2018-07-13 09:00:37 +00:00
|
|
|
|
2017-11-28 10:15:19 +00:00
|
|
|
savedTitle = document.title;
|
|
|
|
|
2017-11-29 07:34:47 +00:00
|
|
|
updateInit();
|
2021-08-24 04:44:37 +00:00
|
|
|
alertsUpdate();
|
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
$('a.notification-link').click(function(e){
|
2021-08-10 21:37:00 +00:00
|
|
|
let notifyType = $(this).data('type');
|
2018-01-24 10:16:51 +00:00
|
|
|
|
2018-01-24 21:46:36 +00:00
|
|
|
if(! $('#nav-' + notifyType + '-sub').hasClass('show')) {
|
2018-01-24 10:16:51 +00:00
|
|
|
loadNotificationItems(notifyType);
|
2018-01-26 10:44:24 +00:00
|
|
|
sessionStorage.setItem('notification_open', notifyType);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sessionStorage.removeItem('notification_open');
|
2018-01-24 10:16:51 +00:00
|
|
|
}
|
2017-11-28 10:15:19 +00:00
|
|
|
});
|
|
|
|
|
2018-01-26 10:44:24 +00:00
|
|
|
if(sessionStorage.getItem('notification_open') !== null) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let notifyType = sessionStorage.getItem('notification_open');
|
2018-01-26 10:44:24 +00:00
|
|
|
$('#nav-' + notifyType + '-sub').addClass('show');
|
|
|
|
loadNotificationItems(notifyType);
|
|
|
|
}
|
|
|
|
|
2021-09-07 06:32:54 +00:00
|
|
|
|
|
|
|
$(document).on('z:handleNetWorkNotificationsItems', function(e, obj) {
|
|
|
|
|
|
|
|
// push_notification(
|
|
|
|
// obj.name,
|
|
|
|
// $('<p>' + obj.message + '</p>').text(),
|
|
|
|
// obj.b64mid
|
|
|
|
// );
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-28 10:15:19 +00:00
|
|
|
// Allow folks to stop the ajax page updates with the pause/break key
|
|
|
|
$(document).keydown(function(event) {
|
|
|
|
if(event.keyCode == '8') {
|
2021-08-10 21:37:00 +00:00
|
|
|
let target = event.target || event.srcElement;
|
2017-11-28 10:15:19 +00:00
|
|
|
if (!/input|textarea/i.test(target.nodeName)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) {
|
|
|
|
event.preventDefault();
|
|
|
|
if(stopped === false) {
|
|
|
|
stopped = true;
|
|
|
|
if (event.ctrlKey) {
|
|
|
|
totStopped = true;
|
|
|
|
}
|
2019-08-26 00:35:14 +00:00
|
|
|
$('#pause').html('<i class="fa fa-pause fa-fw"></i>');
|
2017-11-28 10:15:19 +00:00
|
|
|
} else {
|
|
|
|
unpause();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!totStopped) {
|
|
|
|
unpause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let e = document.getElementById('content-complete');
|
2017-11-28 10:15:19 +00:00
|
|
|
if(e)
|
2018-01-24 10:16:51 +00:00
|
|
|
pageHasMoreContent = false;
|
|
|
|
|
|
|
|
initialLoad = false;
|
2017-11-28 10:15:19 +00:00
|
|
|
|
|
|
|
});
|
2010-07-08 14:03:25 +00:00
|
|
|
|
2018-01-10 10:34:37 +00:00
|
|
|
function datasrc2src(selector) {
|
|
|
|
$(selector).each(function(i, el) {
|
|
|
|
$(el).attr("src", $(el).data("src"));
|
|
|
|
$(el).removeAttr("data-src");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-29 07:34:47 +00:00
|
|
|
function confirmDelete() {
|
|
|
|
return confirm(aStr.delitem);
|
|
|
|
}
|
2014-06-05 15:53:06 +00:00
|
|
|
|
2019-12-06 03:07:55 +00:00
|
|
|
function getSelectedText() {
|
2021-08-10 21:37:00 +00:00
|
|
|
let selectedText = '';
|
2019-12-06 03:07:55 +00:00
|
|
|
|
|
|
|
// window.getSelection
|
|
|
|
if (window.getSelection) {
|
|
|
|
selectedText = window.getSelection();
|
|
|
|
}
|
|
|
|
// document.getSelection
|
|
|
|
else if (document.getSelection) {
|
|
|
|
selectedText = document.getSelection();
|
|
|
|
}
|
|
|
|
// document.selection
|
|
|
|
else if (document.selection) {
|
|
|
|
selectedText = document.selection.createRange().text;
|
|
|
|
} else return;
|
|
|
|
return selectedText;
|
|
|
|
}
|
|
|
|
|
2019-12-09 00:13:52 +00:00
|
|
|
function commentCancel(commentId) {
|
|
|
|
$("#comment-edit-text-" + commentId).val('');
|
2019-12-12 22:17:16 +00:00
|
|
|
localStorage.removeItem("comment_body-" + commentId);
|
2019-12-09 00:13:52 +00:00
|
|
|
}
|
2019-12-06 03:07:55 +00:00
|
|
|
|
2017-08-28 21:42:17 +00:00
|
|
|
function handle_comment_form(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
//handle eventual expanded forms
|
2021-08-10 21:37:00 +00:00
|
|
|
let expanded = $('.comment-edit-text.expanded');
|
|
|
|
let i = 0;
|
2017-08-28 21:42:17 +00:00
|
|
|
|
|
|
|
if(expanded.length) {
|
|
|
|
expanded.each(function() {
|
2021-08-10 21:37:00 +00:00
|
|
|
let ex_form = $(expanded[i].form);
|
|
|
|
let ex_fields = ex_form.find(':input[type=text], textarea');
|
|
|
|
let ex_fields_empty = true;
|
2017-08-28 21:42:17 +00:00
|
|
|
|
|
|
|
ex_fields.each(function() {
|
|
|
|
if($(this).val() != '')
|
|
|
|
ex_fields_empty = false;
|
|
|
|
});
|
|
|
|
if(ex_fields_empty) {
|
|
|
|
ex_form.find('.comment-edit-text').removeClass('expanded').attr('placeholder', aStr.comment);
|
|
|
|
ex_form.find(':not(.comment-edit-text)').hide();
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle clicked form
|
2021-08-10 21:37:00 +00:00
|
|
|
let form = $(this);
|
|
|
|
let fields = form.find(':input[type=text], textarea');
|
|
|
|
let fields_empty = true;
|
2021-08-13 02:34:35 +00:00
|
|
|
let commentElm = false;
|
|
|
|
|
2017-08-28 21:42:17 +00:00
|
|
|
if(form.find('.comment-edit-text').length) {
|
2021-08-13 02:34:35 +00:00
|
|
|
commentElm = form.find('.comment-edit-text').attr('id');
|
2021-08-10 21:37:00 +00:00
|
|
|
let commentId = commentElm.replace('comment-edit-text-','');
|
|
|
|
let submitElm = commentElm.replace(/text/,'submit');
|
2017-11-07 01:08:48 +00:00
|
|
|
|
|
|
|
$('#' + commentElm).addClass('expanded').removeAttr('placeholder');
|
|
|
|
$('#' + commentElm).attr('tabindex','9');
|
|
|
|
$('#' + submitElm).attr('tabindex','10');
|
2018-04-08 18:18:10 +00:00
|
|
|
|
2017-08-28 21:42:17 +00:00
|
|
|
form.find(':not(:visible)').show();
|
2020-05-15 00:45:56 +00:00
|
|
|
commentAuthors(commentId);
|
2017-08-28 21:42:17 +00:00
|
|
|
}
|
|
|
|
|
2019-12-09 00:13:52 +00:00
|
|
|
|
2017-08-28 21:42:17 +00:00
|
|
|
// handle click outside of form (close empty forms)
|
|
|
|
$(document).on('click', function(e) {
|
|
|
|
fields.each(function() {
|
|
|
|
if($(this).val() != '')
|
|
|
|
fields_empty = false;
|
|
|
|
});
|
|
|
|
if(fields_empty) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let emptyCommentElm = form.find('.comment-edit-text').attr('id');
|
|
|
|
let emptySubmitElm = commentElm.replace(/text/,'submit');
|
2017-11-07 01:08:48 +00:00
|
|
|
|
|
|
|
$('#' + emptyCommentElm).removeClass('expanded').attr('placeholder', aStr.comment);
|
|
|
|
$('#' + emptyCommentElm).removeAttr('tabindex');
|
|
|
|
$('#' + emptySubmitElm).removeAttr('tabindex');
|
2017-08-28 21:42:17 +00:00
|
|
|
form.find(':not(.comment-edit-text)').hide();
|
|
|
|
}
|
|
|
|
});
|
2018-04-08 18:18:10 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let commentSaveTimer = null;
|
|
|
|
let emptyCommentElm = form.find('.comment-edit-text').attr('id');
|
|
|
|
let convId = emptyCommentElm.replace('comment-edit-text-','');
|
2018-10-11 03:24:28 +00:00
|
|
|
|
2018-04-08 18:18:10 +00:00
|
|
|
$(document).on('focusout','#' + emptyCommentElm,function(e){
|
|
|
|
if(commentSaveTimer)
|
|
|
|
clearTimeout(commentSaveTimer);
|
2018-04-13 04:44:06 +00:00
|
|
|
commentSaveChanges(convId,true);
|
2018-04-08 18:18:10 +00:00
|
|
|
commentSaveTimer = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('focusin','#' + emptyCommentElm,function(e){
|
|
|
|
commentSaveTimer = setTimeout(function () {
|
2018-04-13 04:44:06 +00:00
|
|
|
commentSaveChanges(convId,false);
|
2018-04-08 18:18:10 +00:00
|
|
|
},10000);
|
|
|
|
});
|
|
|
|
|
2018-04-13 04:44:06 +00:00
|
|
|
function commentSaveChanges(convId,isFinal = false) {
|
2018-04-08 23:44:21 +00:00
|
|
|
if(auto_save_draft) {
|
2018-04-13 05:24:25 +00:00
|
|
|
tmp = $('#' + emptyCommentElm).val();
|
|
|
|
if(tmp) {
|
|
|
|
localStorage.setItem("comment_body-" + convId, tmp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
localStorage.removeItem("comment_body-" + convId);
|
|
|
|
}
|
2018-04-08 23:44:21 +00:00
|
|
|
if( !isFinal) {
|
2018-04-13 04:44:06 +00:00
|
|
|
commentSaveTimer = setTimeout(commentSaveChanges,10000,convId);
|
2018-04-08 23:44:21 +00:00
|
|
|
}
|
2018-04-08 18:18:10 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-28 21:42:17 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 00:20:10 +00:00
|
|
|
function doreply(parent, ident) {
|
|
|
|
showHideCommentBox(parent);
|
|
|
|
openClose('wall-item-comment-wrapper-' + ident.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function commentClose(obj, id) {
|
|
|
|
if(obj.value === '') {
|
|
|
|
obj.value = aStr.comment;
|
2017-08-28 21:42:17 +00:00
|
|
|
$("#comment-edit-text-" + id).removeClass("expanded");
|
2015-03-15 21:18:59 +00:00
|
|
|
$("#mod-cmnt-wrap-" + id).hide();
|
2017-08-12 20:29:57 +00:00
|
|
|
$("#comment-tools-" + id).hide();
|
|
|
|
$("#comment-edit-anon-" + id).hide();
|
2015-03-15 21:18:59 +00:00
|
|
|
return true;
|
2012-08-14 05:12:16 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-08-14 05:12:16 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function showHideCommentBox(id) {
|
|
|
|
if( $('#comment-edit-form-' + id).is(':visible')) {
|
|
|
|
$('#comment-edit-form-' + id).hide();
|
|
|
|
} else {
|
|
|
|
$('#comment-edit-form-' + id).show();
|
2012-08-14 05:12:16 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2012-08-14 05:12:16 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function commentInsert(obj, id) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let tmpStr = $("#comment-edit-text-" + id).val();
|
2015-03-15 21:18:59 +00:00
|
|
|
if(tmpStr == '$comment') {
|
|
|
|
tmpStr = '';
|
2017-08-28 21:42:17 +00:00
|
|
|
$("#comment-edit-text-" + id).addClass("expanded");
|
2015-03-15 21:18:59 +00:00
|
|
|
openMenu("comment-tools-" + id);
|
2012-08-14 05:12:16 +00:00
|
|
|
}
|
2021-08-10 21:37:00 +00:00
|
|
|
let ins = $(obj).html();
|
2015-03-15 21:18:59 +00:00
|
|
|
ins = ins.replace('<','<');
|
|
|
|
ins = ins.replace('>','>');
|
|
|
|
ins = ins.replace('&','&');
|
|
|
|
ins = ins.replace('"','"');
|
|
|
|
$("#comment-edit-text-" + id).val(tmpStr + ins);
|
|
|
|
}
|
2012-08-14 05:12:16 +00:00
|
|
|
|
2018-09-20 05:00:29 +00:00
|
|
|
function commentAuthors(id) {
|
2020-05-14 00:39:48 +00:00
|
|
|
$("#hidden-mentions-" + id).val($("#thread-authors-" + id).html());
|
2018-09-20 05:00:29 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function insertbbcomment(comment, BBcode, id) {
|
|
|
|
// allow themes to override this
|
|
|
|
if(typeof(insertFormatting) != 'undefined')
|
|
|
|
return(insertFormatting(comment, BBcode, id));
|
2013-11-14 23:41:25 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let tmpStr = $("#comment-edit-text-" + id).val();
|
2015-03-15 21:18:59 +00:00
|
|
|
if(tmpStr == comment) {
|
|
|
|
tmpStr = "";
|
2017-08-28 21:42:17 +00:00
|
|
|
$("#comment-edit-text-" + id).addClass("expanded");
|
2015-03-15 21:18:59 +00:00
|
|
|
openMenu("comment-tools-" + id);
|
|
|
|
$("#comment-edit-text-" + id).val(tmpStr);
|
2013-11-14 23:41:25 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
textarea = document.getElementById("comment-edit-text-" +id);
|
|
|
|
if (document.selection) {
|
|
|
|
textarea.focus();
|
|
|
|
selected = document.selection.createRange();
|
2019-01-05 06:31:12 +00:00
|
|
|
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
|
2015-03-15 21:18:59 +00:00
|
|
|
} else if (textarea.selectionStart || textarea.selectionStart == "0") {
|
2021-08-10 21:37:00 +00:00
|
|
|
let start = textarea.selectionStart;
|
|
|
|
let end = textarea.selectionEnd;
|
2019-01-05 06:31:12 +00:00
|
|
|
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
|
2015-03-10 01:32:51 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-03-10 01:32:51 +00:00
|
|
|
|
2015-10-05 10:26:04 +00:00
|
|
|
function inserteditortag(BBcode, id) {
|
2015-03-15 21:18:59 +00:00
|
|
|
// allow themes to override this
|
|
|
|
if(typeof(insertEditorFormatting) != 'undefined')
|
|
|
|
return(insertEditorFormatting(BBcode));
|
|
|
|
|
2015-10-05 10:26:04 +00:00
|
|
|
textarea = document.getElementById(id);
|
2015-03-15 21:18:59 +00:00
|
|
|
if (document.selection) {
|
|
|
|
textarea.focus();
|
|
|
|
selected = document.selection.createRange();
|
|
|
|
selected.text = urlprefix+"["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
|
|
|
|
} else if (textarea.selectionStart || textarea.selectionStart == "0") {
|
2021-08-10 21:37:00 +00:00
|
|
|
let start = textarea.selectionStart;
|
|
|
|
let end = textarea.selectionEnd;
|
2015-03-15 21:18:59 +00:00
|
|
|
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-03-10 01:32:51 +00:00
|
|
|
|
2017-08-09 05:55:47 +00:00
|
|
|
function insertCommentAttach(comment,id) {
|
|
|
|
|
|
|
|
activeCommentID = id;
|
|
|
|
activeCommentText = comment;
|
|
|
|
|
|
|
|
$('body').css('cursor', 'wait');
|
|
|
|
|
|
|
|
$('#invisible-comment-upload').trigger('click');
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-03 01:57:43 +00:00
|
|
|
// used by link modal to pass data to callbacks and still allow handler removal
|
2021-08-10 21:37:00 +00:00
|
|
|
let currentComment = null;
|
|
|
|
let currentID = null;
|
2019-06-03 01:57:43 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function insertCommentURL(comment, id) {
|
2019-05-23 23:37:56 +00:00
|
|
|
textarea = document.getElementById("comment-edit-text-" +id);
|
|
|
|
if (textarea.selectionStart || textarea.selectionStart == "0") {
|
2021-08-10 21:37:00 +00:00
|
|
|
let start = textarea.selectionStart;
|
|
|
|
let end = textarea.selectionEnd;
|
2019-05-23 23:37:56 +00:00
|
|
|
if (end > start) {
|
|
|
|
reply = prompt(aStr['linkurl']);
|
|
|
|
if(reply && reply.length) {
|
|
|
|
textarea.value = textarea.value.substring(0, start) + "[url=" + reply + "]" + textarea.value.substring(start, end) + "[/url]" + textarea.value.substring(end, textarea.value.length);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2019-06-03 01:57:43 +00:00
|
|
|
|
|
|
|
if ($('#jot-popup').length != 0) $('#jot-popup').show();
|
2019-05-23 23:37:56 +00:00
|
|
|
|
2019-06-03 01:57:43 +00:00
|
|
|
currentComment = comment;
|
|
|
|
currentID = id;
|
|
|
|
|
2021-09-17 07:02:02 +00:00
|
|
|
$('#linkModal').modal('show');
|
2019-04-30 04:07:57 +00:00
|
|
|
$('#id_link_url').focus();
|
2019-05-30 02:55:29 +00:00
|
|
|
$('#link-modal-CancelButton').on('click', commentclearlinkmodal);
|
2019-06-03 01:57:43 +00:00
|
|
|
$('#link-modal-OKButton').on('click', commentgetlinkmodal);
|
2019-05-30 02:55:29 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function commentclearlinkmodal() {
|
|
|
|
$('#link-modal-OKButton').off('click', commentgetlinkmodal);
|
|
|
|
$('#link-modal-CancelButton').off('click', commentclearlinkmodal);
|
|
|
|
}
|
|
|
|
|
|
|
|
function commentgetlinkmodal() {
|
2021-08-10 21:37:00 +00:00
|
|
|
let reply=$('#id_link_url').val();
|
2019-05-30 02:55:29 +00:00
|
|
|
if(reply && reply.length) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let radioValue = $("input[name='link_style']:checked"). val();
|
2019-05-30 02:55:29 +00:00
|
|
|
if(radioValue == '0') {
|
|
|
|
reply = '!' + reply;
|
2019-04-30 04:07:57 +00:00
|
|
|
}
|
2021-08-10 21:37:00 +00:00
|
|
|
let optstr = '';
|
|
|
|
let opts = $("input[name='oembed']:checked"). val();
|
2019-05-30 02:55:29 +00:00
|
|
|
if(opts) {
|
|
|
|
optstr = optstr + '&oembed=1';
|
|
|
|
}
|
2021-08-10 21:37:00 +00:00
|
|
|
opts = $("input[name='zotobj']:checked"). val();
|
2019-05-30 02:55:29 +00:00
|
|
|
if(opts) {
|
|
|
|
optstr = optstr + '&zotobj=1';
|
|
|
|
}
|
|
|
|
reply = bin2hex(reply);
|
|
|
|
$('body').css('cursor', 'wait');
|
|
|
|
$.get('linkinfo?f=&binurl=' + reply + optstr, function(data) {
|
|
|
|
$('#linkModal').modal('hide');
|
2019-06-03 01:57:43 +00:00
|
|
|
$("#comment-edit-text-" + currentID).focus();
|
|
|
|
$("#comment-edit-text-" + currentID).addClass("expanded");
|
|
|
|
openMenu("comment-tools-" + currentID);
|
2021-08-10 21:37:00 +00:00
|
|
|
let tmpStr = $("#comment-edit-text-" + currentID).val();
|
2019-05-23 23:37:56 +00:00
|
|
|
|
2019-06-03 01:57:43 +00:00
|
|
|
textarea = document.getElementById("comment-edit-text-" + currentID);
|
2019-05-30 02:55:29 +00:00
|
|
|
textarea.value = textarea.value + data;
|
2019-06-03 01:57:43 +00:00
|
|
|
preview_comment(currentID);
|
2019-05-30 02:55:29 +00:00
|
|
|
$('#link-modal-OKButton').off('click', commentgetlinkmodal);
|
|
|
|
$('#link-modal-CancelButton').off('click', commentclearlinkmodal);
|
|
|
|
$('#id_link_url').val('');
|
|
|
|
$('body').css('cursor', 'auto');
|
|
|
|
});
|
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2015-03-05 04:00:54 +00:00
|
|
|
|
2018-03-02 21:15:28 +00:00
|
|
|
function doFollowAuthor(url) {
|
|
|
|
$.get(url, function(data) { notificationsUpdate(); });
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-26 00:20:10 +00:00
|
|
|
function doPoke(xchan) {
|
|
|
|
$.get('poke?xchan=' + xchan, function(data) { notificationsUpdate(); });
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 21:15:28 +00:00
|
|
|
|
2020-11-16 00:58:31 +00:00
|
|
|
function update_role_text() {
|
2021-08-10 21:37:00 +00:00
|
|
|
let new_role = $("#id_permissions_role").val();
|
2020-11-16 00:58:31 +00:00
|
|
|
if (typeof(new_role) !== 'undefined') {
|
|
|
|
$("#channel_role_text").html(aStr[new_role]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function viewsrc(id) {
|
|
|
|
$.colorbox({href: 'viewsrc/' + id, maxWidth: '80%', maxHeight: '80%' });
|
|
|
|
}
|
2015-03-05 04:00:54 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function showHideComments(id) {
|
|
|
|
if( $('#collapsed-comments-' + id).is(':visible')) {
|
|
|
|
$('#collapsed-comments-' + id + ' .autotime').timeago('dispose');
|
|
|
|
$('#collapsed-comments-' + id).slideUp();
|
|
|
|
$('#hide-comments-' + id).html(aStr.showmore);
|
|
|
|
$('#hide-comments-total-' + id).show();
|
|
|
|
} else {
|
|
|
|
$('#collapsed-comments-' + id + ' .autotime').timeago();
|
|
|
|
$('#collapsed-comments-' + id).slideDown();
|
|
|
|
$('#hide-comments-' + id).html(aStr.showfewer);
|
|
|
|
$('#hide-comments-total-' + id).hide();
|
2014-06-19 03:33:28 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2013-11-14 23:41:25 +00:00
|
|
|
|
2020-09-21 04:11:42 +00:00
|
|
|
|
|
|
|
function collapseComments(id) {
|
|
|
|
if( $('.collapsed-comments-' + id).is(':visible')) {
|
|
|
|
$('.collapsed-comments-' + id + ' .autotime').timeago('dispose');
|
|
|
|
$('.collapsed-comments-' + id).slideUp();
|
|
|
|
$('#hide-comments-' + id).html(aStr.showmore);
|
|
|
|
$('#hide-comments-total-' + id).show();
|
|
|
|
} else {
|
|
|
|
$('.collapsed-comments-' + id + ' .autotime').timeago();
|
|
|
|
$('.collapsed-comments-' + id).slideDown();
|
|
|
|
$('#hide-comments-' + id).html(aStr.showfewer);
|
|
|
|
$('#hide-comments-total-' + id).hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function openClose(theID) {
|
|
|
|
if(document.getElementById(theID).style.display == "block") {
|
|
|
|
document.getElementById(theID).style.display = "none";
|
|
|
|
} else {
|
|
|
|
document.getElementById(theID).style.display = "block";
|
2012-08-14 05:12:16 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2012-08-14 05:12:16 +00:00
|
|
|
|
2017-09-15 20:17:18 +00:00
|
|
|
function openCloseTR(theID) {
|
|
|
|
if(document.getElementById(theID).style.display == "table-row") {
|
|
|
|
document.getElementById(theID).style.display = "none";
|
|
|
|
} else {
|
|
|
|
document.getElementById(theID).style.display = "table-row";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function closeOpen(theID) {
|
|
|
|
if(document.getElementById(theID).style.display == "none") {
|
|
|
|
document.getElementById(theID).style.display = "block";
|
|
|
|
} else {
|
|
|
|
document.getElementById(theID).style.display = "none";
|
2012-08-14 05:12:16 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2012-08-14 05:12:16 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function openMenu(theID) {
|
|
|
|
document.getElementById(theID).style.display = "block";
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeMenu(theID) {
|
|
|
|
document.getElementById(theID).style.display = "none";
|
|
|
|
}
|
2012-08-14 05:12:16 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function markRead(notifType) {
|
2013-02-04 03:07:01 +00:00
|
|
|
$.get('ping?f=&markRead='+notifType);
|
2017-09-01 19:27:59 +00:00
|
|
|
$('.' + notifType + '-button').hide();
|
2018-02-19 19:23:13 +00:00
|
|
|
$('#nav-' + notifType + '-sub').removeClass('show');
|
2018-02-09 13:06:59 +00:00
|
|
|
sessionStorage.removeItem(notifType + '_notifications_cache');
|
2018-02-19 19:23:13 +00:00
|
|
|
sessionStorage.removeItem('notification_open');
|
2017-11-29 11:01:36 +00:00
|
|
|
if(timer) clearTimeout(timer);
|
2017-11-29 07:34:47 +00:00
|
|
|
timer = setTimeout(updateInit,2000);
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2012-04-18 11:23:42 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function markItemRead(itemId) {
|
2014-11-17 23:18:06 +00:00
|
|
|
$.get('ping?f=&markItemRead='+itemId);
|
|
|
|
$('.unseen-wall-indicator-'+itemId).hide();
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2011-07-25 14:54:39 +00:00
|
|
|
|
2021-08-24 04:44:37 +00:00
|
|
|
function alertsUpdate() {
|
|
|
|
|
|
|
|
let alertspingCmd = 'fastping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
|
|
|
|
|
|
|
|
$.get(alertspingCmd,function(data) {
|
|
|
|
if (! data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(data.invalid == 1) {
|
|
|
|
window.location.href=window.location.href;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.jGrowl.defaults.closerTemplate = '<div>[ ' + aStr.closeAll + ']</div>';
|
|
|
|
|
|
|
|
$(data.notice).each(function() { $.jGrowl(this.message, { sticky: false, theme: 'notice', life: 10000 }); });
|
|
|
|
|
|
|
|
$(data.info).each(function() { $.jGrowl(this.message, { sticky: false, theme: 'info' }); });
|
|
|
|
});
|
|
|
|
|
|
|
|
if (alertstimer) {
|
|
|
|
clearTimeout(alertstimer);
|
|
|
|
}
|
|
|
|
alertstimer = setTimeout(alertsUpdate,alertsInterval);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
function notificationsUpdate(cached_data) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
|
2018-01-24 10:16:51 +00:00
|
|
|
|
|
|
|
if(cached_data !== undefined) {
|
|
|
|
handleNotifications(cached_data);
|
2021-08-24 04:44:37 +00:00
|
|
|
} else {
|
2021-08-28 00:37:32 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
$.get(pingCmd,function(data) {
|
|
|
|
|
2021-08-24 04:44:37 +00:00
|
|
|
if(! data) return;
|
2019-01-17 23:12:58 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
// Put the object into storage
|
2022-05-31 01:07:31 +00:00
|
|
|
sessionStorage.setItem('notifications_cache', JSON.stringify(data));
|
2018-01-24 10:16:51 +00:00
|
|
|
|
2021-08-24 04:44:37 +00:00
|
|
|
let fnotifs = []; if(data.forums) {
|
|
|
|
$.each(data.forums_sub, function() { fnotifs.push(this);
|
|
|
|
}); handleNotificationsItems('forums', fnotifs); }
|
2018-06-02 13:39:38 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
if(data.invalid == 1) {
|
2021-08-24 04:44:37 +00:00
|
|
|
window.location.href=window.location.href; }
|
2018-01-24 10:16:51 +00:00
|
|
|
|
|
|
|
handleNotifications(data);
|
|
|
|
});
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2018-01-24 10:16:51 +00:00
|
|
|
|
2021-08-24 04:44:37 +00:00
|
|
|
let notifyType = null; if($('.notification-content.show').length)
|
|
|
|
{ notifyType = $('.notification-content.show').data('type'); }
|
|
|
|
if(notifyType !== null) { loadNotificationItems(notifyType); }
|
2018-01-24 21:46:36 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
if(timer) clearTimeout(timer);
|
|
|
|
timer = setTimeout(updateInit,updateInterval);
|
2017-11-28 10:15:19 +00:00
|
|
|
}
|
2021-08-24 04:44:37 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
function handleNotifications(data) {
|
2020-02-13 05:36:21 +00:00
|
|
|
if(data.stream || data.home || data.intros || data.register || data.mail || data.all_events || data.notify || data.files || data.pubs || data.forums) {
|
2018-01-24 10:16:51 +00:00
|
|
|
$('.notifications-btn').css('opacity', 1);
|
|
|
|
$('#no_notifications').hide();
|
2022-04-18 22:46:35 +00:00
|
|
|
$('#notifications_wrapper').show();
|
2018-01-24 10:16:51 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('.notifications-btn').css('opacity', 0.5);
|
|
|
|
$('#navbar-collapse-1').removeClass('show');
|
|
|
|
$('#no_notifications').show();
|
2022-04-18 22:46:35 +00:00
|
|
|
$('#notifications_wrapper').hide();
|
2022-05-31 01:07:31 +00:00
|
|
|
sessionStorage.removeItem('notifications_cache');
|
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
}
|
2012-07-16 04:06:07 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
if(data.home || data.intros || data.register || data.mail || data.notify || data.files) {
|
|
|
|
$('.notifications-btn-icon').removeClass('fa-exclamation-circle');
|
2022-04-18 22:46:35 +00:00
|
|
|
$('.notifications-btn-icon').addClass('fa-exclamation-triangle');
|
2018-01-24 10:16:51 +00:00
|
|
|
}
|
|
|
|
if(!data.home && !data.intros && !data.register && !data.mail && !data.notify && !data.files) {
|
|
|
|
$('.notifications-btn-icon').removeClass('fa-exclamation-triangle');
|
|
|
|
$('.notifications-btn-icon').addClass('fa-exclamation-circle');
|
|
|
|
}
|
2018-03-14 20:39:33 +00:00
|
|
|
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');
|
|
|
|
}
|
2017-10-18 09:38:45 +00:00
|
|
|
|
2021-09-07 06:32:54 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
$.each(data, function(index, item) {
|
|
|
|
//do not process those
|
2021-08-24 04:44:37 +00:00
|
|
|
let arr = ['invalid'];
|
2018-01-24 10:16:51 +00:00
|
|
|
if(arr.indexOf(index) !== -1)
|
|
|
|
return;
|
2012-07-26 05:55:43 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
if(item == 0) {
|
|
|
|
$('.' + index + '-button').fadeOut();
|
2018-02-09 13:06:59 +00:00
|
|
|
sessionStorage.removeItem(index + '_notifications_cache');
|
2018-01-24 10:16:51 +00:00
|
|
|
} else {
|
|
|
|
$('.' + index + '-button').fadeIn();
|
|
|
|
$('.' + index + '-update').html(item);
|
2017-11-29 07:34:47 +00:00
|
|
|
}
|
2018-01-24 10:16:51 +00:00
|
|
|
});
|
|
|
|
}
|
2017-11-28 15:06:07 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
function handleNotificationsItems(notifyType, data) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let notifications_tpl = ((notifyType == 'forums') ? unescape($("#nav-notifications-forums-template[rel=template]").html()) : unescape($("#nav-notifications-template[rel=template]").html()));
|
|
|
|
let notify_menu = $("#nav-" + notifyType + "-menu");
|
2017-02-03 10:00:35 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
notify_menu.html('');
|
2012-07-16 04:06:07 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
$(data).each(function() {
|
2021-09-07 06:32:54 +00:00
|
|
|
if (notifyType == 'notify') {
|
|
|
|
$(document).trigger('z:handleNetWorkNotificationsItems', this);
|
|
|
|
}
|
|
|
|
|
2018-12-01 03:01:10 +00:00
|
|
|
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);
|
2018-01-24 10:16:51 +00:00
|
|
|
notify_menu.append(html);
|
|
|
|
});
|
2012-07-16 04:06:07 +00:00
|
|
|
|
2018-01-27 21:23:47 +00:00
|
|
|
datasrc2src('#notifications .notification img[data-src]');
|
2011-11-11 16:00:05 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
if($('#tt-' + notifyType + '-only').hasClass('active'))
|
|
|
|
$('#nav-' + notifyType + '-menu [data-thread_top=false]').hide();
|
|
|
|
|
|
|
|
if($('#cn-' + notifyType + '-input').length) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let filter = $('#cn-' + notifyType + '-input').val().toString().toLowerCase();
|
2018-01-24 10:16:51 +00:00
|
|
|
if(filter) {
|
|
|
|
$('#nav-' + notifyType + '-menu .notification').each(function(i, el){
|
2021-08-10 21:37:00 +00:00
|
|
|
let cn = $(el).data('contact_name').toString().toLowerCase();
|
2018-01-24 10:16:51 +00:00
|
|
|
if(cn.indexOf(filter) === -1)
|
|
|
|
$(el).addClass('d-none');
|
|
|
|
else
|
|
|
|
$(el).removeClass('d-none');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2010-08-19 11:59:31 +00:00
|
|
|
|
2016-04-23 14:39:56 +00:00
|
|
|
function contextualHelp() {
|
2021-08-10 21:37:00 +00:00
|
|
|
let container = $("#contextual-help-content");
|
2016-04-23 14:39:56 +00:00
|
|
|
|
|
|
|
if(container.hasClass('contextual-help-content-open')) {
|
|
|
|
container.removeClass('contextual-help-content-open');
|
2016-12-30 19:50:12 +00:00
|
|
|
$('main').css('margin-top', '')
|
2016-04-23 14:39:56 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
container.addClass('contextual-help-content-open');
|
2021-08-10 21:37:00 +00:00
|
|
|
let mainTop = container.outerHeight(true);
|
2016-12-30 19:50:12 +00:00
|
|
|
$('main').css('margin-top', mainTop + 'px');
|
2016-04-23 14:39:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function contextualHelpFocus(target, openSidePanel) {
|
2016-11-27 03:29:53 +00:00
|
|
|
if($(target).length) {
|
|
|
|
if (openSidePanel) {
|
|
|
|
$("main").addClass('region_1-on'); // Open the side panel to highlight element
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("main").removeClass('region_1-on');
|
|
|
|
}
|
2016-12-19 19:36:40 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let css_position = $(target).parent().css('position');
|
2016-12-19 19:36:40 +00:00
|
|
|
if (css_position === 'fixed') {
|
|
|
|
$(target).parent().css('position', 'static');
|
|
|
|
}
|
|
|
|
|
2016-11-27 03:29:53 +00:00
|
|
|
$('html,body').animate({ scrollTop: $(target).offset().top - $('nav').outerHeight(true) - $('#contextual-help-content').outerHeight(true)}, 'slow');
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
$(target).fadeTo('slow', 0.1).fadeTo('slow', 1.0);
|
|
|
|
}
|
2016-12-19 19:36:40 +00:00
|
|
|
|
|
|
|
$(target).parent().css('position', css_position);
|
2016-11-27 03:29:53 +00:00
|
|
|
}
|
2016-04-23 14:39:56 +00:00
|
|
|
}
|
2012-07-24 03:49:56 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function updatePageItems(mode, data) {
|
2014-08-06 04:57:46 +00:00
|
|
|
|
2014-07-23 05:15:34 +00:00
|
|
|
if(mode === 'append') {
|
|
|
|
$(data).each(function() {
|
|
|
|
$('#page-end').before($(this));
|
|
|
|
});
|
|
|
|
|
|
|
|
if(loadingPage) {
|
|
|
|
loadingPage = false;
|
|
|
|
}
|
|
|
|
}
|
2014-08-06 05:01:47 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let e = document.getElementById('content-complete');
|
2014-08-06 05:01:47 +00:00
|
|
|
if(e) {
|
2015-03-15 21:18:59 +00:00
|
|
|
pageHasMoreContent = false;
|
2014-08-06 05:01:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:43:36 +00:00
|
|
|
collapseHeight();
|
2014-07-23 05:15:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-24 03:49:56 +00:00
|
|
|
function updateConvItems(mode,data) {
|
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
if(mode === 'update' || mode === 'replace') {
|
2012-07-24 03:49:56 +00:00
|
|
|
prev = 'threads-begin';
|
2017-08-25 07:00:51 +00:00
|
|
|
}
|
|
|
|
if(mode === 'append') {
|
|
|
|
next = 'threads-end';
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mode === 'replace') {
|
|
|
|
$('.thread-wrapper').remove(); // clear existing content
|
|
|
|
}
|
2012-07-24 03:49:56 +00:00
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
$('.thread-wrapper.toplevel_item',data).each(function() {
|
2013-07-03 03:15:45 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let ident = $(this).attr('id');
|
|
|
|
let convId = ident.replace('thread-wrapper-','');
|
|
|
|
let commentWrap = $('#'+ident+' .collapsed-comments').attr('id');
|
2018-04-13 04:44:06 +00:00
|
|
|
|
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let itmId = 0;
|
|
|
|
let isVisible = false;
|
2017-08-25 07:00:51 +00:00
|
|
|
|
|
|
|
// figure out the comment state
|
|
|
|
if(typeof commentWrap !== 'undefined')
|
|
|
|
itmId = commentWrap.replace('collapsed-comments-','');
|
2013-07-04 22:46:20 +00:00
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
if($('#collapsed-comments-'+itmId).is(':visible'))
|
|
|
|
isVisible = true;
|
2013-08-18 07:04:38 +00:00
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
// insert the content according to the mode and first_page
|
|
|
|
// and whether or not the content exists already (overwrite it)
|
2013-08-18 07:04:38 +00:00
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
if($('#' + ident).length == 0) {
|
|
|
|
if((mode === 'update' || mode === 'replace') && profile_page == 1) {
|
|
|
|
$('#' + prev).after($(this));
|
|
|
|
prev = ident;
|
2012-07-24 03:49:56 +00:00
|
|
|
}
|
2017-08-25 07:00:51 +00:00
|
|
|
if(mode === 'append') {
|
|
|
|
$('#' + next).before($(this));
|
2012-07-24 03:49:56 +00:00
|
|
|
}
|
2013-06-14 02:21:45 +00:00
|
|
|
}
|
2017-08-25 07:00:51 +00:00
|
|
|
else {
|
|
|
|
$('#' + ident).replaceWith($(this));
|
|
|
|
}
|
2012-07-25 04:03:15 +00:00
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
// set the comment state to the state we discovered earlier
|
2012-07-25 04:03:15 +00:00
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
if(isVisible)
|
|
|
|
showHideComments(itmId);
|
2015-03-15 21:18:59 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let commentBody = localStorage.getItem("comment_body-" + convId);
|
2018-04-13 04:44:06 +00:00
|
|
|
|
|
|
|
if(commentBody) {
|
2021-08-13 02:34:35 +00:00
|
|
|
commentElm = $('#comment-edit-text-' + convId);
|
2018-04-13 04:44:06 +00:00
|
|
|
if(auto_save_draft) {
|
2018-04-13 05:24:25 +00:00
|
|
|
if($(commentElm).val() === '') {
|
2018-04-13 04:44:06 +00:00
|
|
|
$('#comment-edit-form-' + convId).show();
|
2018-04-13 05:24:25 +00:00
|
|
|
$(commentElm).addClass("expanded");
|
|
|
|
openMenu("comment-tools-" + convId);
|
|
|
|
$(commentElm).val(commentBody);
|
2018-04-13 04:44:06 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-04-13 05:24:25 +00:00
|
|
|
localStorage.removeItem("comment_body-" + convId);
|
2018-04-13 04:44:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
// trigger the autotime function on all newly created content
|
|
|
|
|
2020-03-18 04:30:25 +00:00
|
|
|
$(".pinned .autotime").timeago();
|
2017-08-25 07:00:51 +00:00
|
|
|
$("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
|
|
|
|
$("> .shared_header .autotime",this).timeago();
|
|
|
|
|
|
|
|
if((mode === 'append' || mode === 'replace') && (loadingPage)) {
|
2013-12-09 21:43:15 +00:00
|
|
|
loadingPage = false;
|
|
|
|
}
|
2015-02-20 13:07:56 +00:00
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
// if single thread view and the item has a title, display it in the title bar
|
|
|
|
|
|
|
|
if(mode === 'replace') {
|
|
|
|
if (window.location.search.indexOf("mid=") != -1 || window.location.pathname.indexOf("display") != -1) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let title = $(".wall-item-title").text();
|
2017-08-25 07:00:51 +00:00
|
|
|
title.replace(/^\s+/, '');
|
|
|
|
title.replace(/\s+$/, '');
|
2017-08-27 00:21:33 +00:00
|
|
|
if (title) {
|
|
|
|
savedTitle = title + " " + savedTitle;
|
2019-01-30 05:26:52 +00:00
|
|
|
document.title = title;
|
2017-08-27 00:21:33 +00:00
|
|
|
}
|
2017-08-25 07:00:51 +00:00
|
|
|
}
|
2015-02-20 13:07:56 +00:00
|
|
|
}
|
2017-08-25 07:00:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// reset rotators and cursors we may have set before reaching this place
|
2012-07-24 03:49:56 +00:00
|
|
|
|
2017-09-26 11:02:11 +00:00
|
|
|
$('.like-rotator').hide();
|
2012-07-24 03:49:56 +00:00
|
|
|
|
|
|
|
if(commentBusy) {
|
|
|
|
commentBusy = false;
|
|
|
|
$('body').css('cursor', 'auto');
|
|
|
|
}
|
|
|
|
|
2017-08-25 07:00:51 +00:00
|
|
|
// Setup to determine if the media player is playing. This affects
|
|
|
|
// some content loading decisions.
|
|
|
|
|
2015-11-24 01:47:18 +00:00
|
|
|
$('video').off('playing');
|
|
|
|
$('video').off('pause');
|
|
|
|
$('audio').off('playing');
|
|
|
|
$('audio').off('pause');
|
|
|
|
|
|
|
|
$('video').on('playing', function() {
|
|
|
|
mediaPlaying = true;
|
|
|
|
});
|
|
|
|
$('video').on('pause', function() {
|
|
|
|
mediaPlaying = false;
|
|
|
|
});
|
|
|
|
$('audio').on('playing', function() {
|
|
|
|
mediaPlaying = true;
|
|
|
|
});
|
|
|
|
$('audio').on('pause', function() {
|
|
|
|
mediaPlaying = false;
|
|
|
|
});
|
|
|
|
|
2012-07-24 03:49:56 +00:00
|
|
|
/* autocomplete @nicknames */
|
2022-01-25 20:51:37 +00:00
|
|
|
$(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acloader?f=&n=1");
|
2016-04-04 15:12:23 +00:00
|
|
|
/* autocomplete bbcode */
|
|
|
|
$(".comment-edit-form textarea").bbco_autocomplete('bbcode');
|
2016-02-16 19:53:38 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let bimgs = ((preloadImages) ? false : $(".wall-item-body img, .wall-photo-item img").not(function() { return this.complete; }));
|
|
|
|
let bimgcount = bimgs.length;
|
2012-07-24 03:49:56 +00:00
|
|
|
|
2012-08-07 06:10:37 +00:00
|
|
|
if (bimgcount) {
|
2016-07-18 01:32:38 +00:00
|
|
|
bimgs.on('load',function() {
|
2015-03-15 21:18:59 +00:00
|
|
|
bimgcount--;
|
|
|
|
if (! bimgcount) {
|
2016-01-30 00:34:27 +00:00
|
|
|
collapseHeight();
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
|
|
|
});
|
2012-08-07 06:10:37 +00:00
|
|
|
} else {
|
|
|
|
collapseHeight();
|
|
|
|
}
|
2016-02-16 19:53:38 +00:00
|
|
|
|
2019-08-01 01:15:38 +00:00
|
|
|
|
2016-09-26 06:09:08 +00:00
|
|
|
// auto-scroll to a particular comment in a thread (designated by mid) when in single-thread mode
|
2017-01-20 20:03:46 +00:00
|
|
|
// use the same method to generate the submid as we use in ThreadItem,
|
2017-09-05 21:18:02 +00:00
|
|
|
// base64_encode + replace(['+','='],['','']);
|
2017-09-07 21:12:58 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let submid = ((bParam_mid.length) ? bParam_mid : 'abcdefg');
|
|
|
|
let encoded = ((submid.substr(0,4) == 'b64.') ? true : false);
|
|
|
|
let submid_encoded = ((encoded) ? submid.substr(4) : window.btoa(submid));
|
2017-09-07 21:12:58 +00:00
|
|
|
|
2022-07-24 10:31:38 +00:00
|
|
|
submid_encoded = submid_encoded.replace(/[\+\=]/g,'');
|
2017-01-20 20:03:46 +00:00
|
|
|
if($('.item_' + submid_encoded).length && !$('.item_' + submid_encoded).hasClass('toplevel_item') && mode == 'replace') {
|
2016-09-26 09:26:13 +00:00
|
|
|
if($('.collapsed-comments').length) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let scrolltoid = $('.collapsed-comments').attr('id').substring(19);
|
2016-09-29 09:07:53 +00:00
|
|
|
$('#collapsed-comments-' + scrolltoid + ' .autotime').timeago();
|
|
|
|
$('#collapsed-comments-' + scrolltoid).show();
|
2016-09-26 09:26:13 +00:00
|
|
|
$('#hide-comments-' + scrolltoid).html(aStr.showfewer);
|
|
|
|
$('#hide-comments-total-' + scrolltoid).hide();
|
|
|
|
}
|
2017-01-20 20:03:46 +00:00
|
|
|
$('html, body').animate({ scrollTop: $('.item_' + submid_encoded).offset().top - $('nav').outerHeight() }, 'slow');
|
|
|
|
$('.item_' + submid_encoded).addClass('item-highlight');
|
2016-09-25 03:10:20 +00:00
|
|
|
}
|
|
|
|
|
2019-07-31 00:56:35 +00:00
|
|
|
|
2019-07-29 02:34:42 +00:00
|
|
|
$(document.body).trigger("sticky_kit:recalc");
|
2012-08-07 06:10:37 +00:00
|
|
|
}
|
2012-07-24 03:49:56 +00:00
|
|
|
|
2016-01-30 00:34:27 +00:00
|
|
|
function collapseHeight() {
|
2021-08-10 21:37:00 +00:00
|
|
|
let origContentHeight = Math.ceil($("#region_2").height());
|
|
|
|
let cDiff = 0;
|
|
|
|
let i = 0;
|
|
|
|
let position = $(window).scrollTop();
|
2016-02-16 13:42:13 +00:00
|
|
|
|
2015-09-17 12:14:01 +00:00
|
|
|
$(".wall-item-content, .directory-collapse").each(function() {
|
2021-08-11 02:25:23 +00:00
|
|
|
orgHeight = $(this).outerHeight(true);
|
2016-01-29 23:30:49 +00:00
|
|
|
if(orgHeight > divmore_height) {
|
2017-03-06 10:52:07 +00:00
|
|
|
if(! $(this).hasClass('divmore') && $(this).has('div.no-collapse').length == 0) {
|
2016-02-02 11:40:40 +00:00
|
|
|
|
2016-02-16 13:42:13 +00:00
|
|
|
// check if we will collapse some content above the visible content and compensate the diff later
|
2016-02-17 10:07:47 +00:00
|
|
|
if($(this).offset().top + divmore_height - $(window).scrollTop() + cDiff - ($(".divgrow-showmore").outerHeight() * i) < 65) {
|
2016-02-16 13:42:13 +00:00
|
|
|
diff = orgHeight - divmore_height;
|
|
|
|
cDiff = cDiff + diff;
|
|
|
|
i++;
|
|
|
|
}
|
2016-02-02 11:40:40 +00:00
|
|
|
|
2016-02-16 19:53:38 +00:00
|
|
|
$(this).readmore({
|
|
|
|
speed: 0,
|
|
|
|
heightMargin: 50,
|
|
|
|
collapsedHeight: divmore_height,
|
2016-07-15 11:20:00 +00:00
|
|
|
moreLink: '<a href="#" class="divgrow-showmore fakelink">' + aStr.divgrowmore + '</a>',
|
|
|
|
lessLink: '<a href="#" class="divgrow-showmore fakelink">' + aStr.divgrowless + '</a>',
|
2016-02-16 19:53:38 +00:00
|
|
|
beforeToggle: function(trigger, element, expanded) {
|
|
|
|
if(expanded) {
|
|
|
|
if((($(element).offset().top + divmore_height) - $(window).scrollTop()) < 65 ) {
|
2016-07-22 12:03:14 +00:00
|
|
|
$(window).scrollTop($(window).scrollTop() - ($(element).outerHeight(true) - divmore_height));
|
2015-03-26 20:33:44 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-16 19:53:38 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$(this).addClass('divmore');
|
2011-12-13 02:08:09 +00:00
|
|
|
}
|
2010-08-19 11:59:31 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
});
|
2016-01-29 23:30:49 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let collapsedContentHeight = Math.ceil($("#region_2").height());
|
2019-01-23 22:27:51 +00:00
|
|
|
contentHeightDiff = liking ? 0 : origContentHeight - collapsedContentHeight;
|
|
|
|
|
2016-02-12 10:00:50 +00:00
|
|
|
console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px');
|
2016-01-29 23:30:49 +00:00
|
|
|
|
2019-01-23 22:27:51 +00:00
|
|
|
if(i && ! liking){
|
2021-08-10 21:37:00 +00:00
|
|
|
let sval = position - cDiff + ($(".divgrow-showmore").outerHeight() * i);
|
2016-02-16 20:02:28 +00:00
|
|
|
console.log('collapsed above viewport count: ' + i);
|
2016-02-16 13:42:13 +00:00
|
|
|
$(window).scrollTop(sval);
|
|
|
|
}
|
2019-07-31 00:56:35 +00:00
|
|
|
|
2017-11-29 07:34:47 +00:00
|
|
|
}
|
2016-02-16 13:42:13 +00:00
|
|
|
|
2017-11-29 07:34:47 +00:00
|
|
|
function updateInit() {
|
2016-01-29 23:30:49 +00:00
|
|
|
|
2020-02-13 05:48:10 +00:00
|
|
|
if($('#live-stream').length) { src = 'stream'; }
|
2017-11-29 07:34:47 +00:00
|
|
|
if($('#live-channel').length) { src = 'channel'; }
|
|
|
|
if($('#live-pubstream').length) { src = 'pubstream'; }
|
|
|
|
if($('#live-display').length) { src = 'display'; }
|
|
|
|
if($('#live-hq').length) { src = 'hq'; }
|
|
|
|
if($('#live-search').length) { src = 'search'; }
|
2012-07-25 05:06:21 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
if (initialLoad && (sessionStorage.getItem('notifications_cache') !== null)) {
|
2021-08-10 21:37:00 +00:00
|
|
|
cached_data = JSON.parse(sessionStorage.getItem('notifications_cache'));
|
2018-01-24 10:16:51 +00:00
|
|
|
notificationsUpdate(cached_data);
|
2018-06-02 13:39:38 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let fnotifs = [];
|
2018-06-02 13:39:38 +00:00
|
|
|
if(cached_data.forums) {
|
|
|
|
$.each(cached_data.forums_sub, function() {
|
|
|
|
fnotifs.push(this);
|
|
|
|
});
|
|
|
|
handleNotificationsItems('forums', fnotifs);
|
|
|
|
}
|
2018-06-02 20:11:11 +00:00
|
|
|
|
2018-01-24 10:16:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 07:34:47 +00:00
|
|
|
if(! src) {
|
|
|
|
notificationsUpdate();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
liveUpdate();
|
|
|
|
}
|
2017-11-28 15:06:07 +00:00
|
|
|
|
|
|
|
if($('#live-photos').length || $('#live-cards').length || $('#live-articles').length ) {
|
|
|
|
if(liking) {
|
|
|
|
liking = 0;
|
|
|
|
window.location.href=window.location.href;
|
2017-11-28 10:15:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 10:22:59 +00:00
|
|
|
function liveUpdate(notify_id) {
|
2017-11-09 10:34:41 +00:00
|
|
|
|
2021-08-11 02:25:23 +00:00
|
|
|
let origHeight = 0;
|
2021-08-27 05:15:24 +00:00
|
|
|
let expanded = $('.comment-edit-text.expanded');
|
|
|
|
|
2021-08-11 02:25:23 +00:00
|
|
|
|
2021-11-17 01:58:45 +00:00
|
|
|
if(typeof profile_uid === 'undefined') profile_uid = false;
|
2017-11-29 07:34:47 +00:00
|
|
|
|
2021-08-27 05:15:24 +00:00
|
|
|
if((src === null) || (! profile_uid)) { $('.like-rotator').hide(); return; }
|
2017-11-29 07:34:47 +00:00
|
|
|
|
2021-08-27 05:15:24 +00:00
|
|
|
if(in_progress || mediaPlaying || expanded.length || stopped) {
|
|
|
|
console.log('liveUpdate: deferred');
|
2015-03-15 21:18:59 +00:00
|
|
|
if(livetime) {
|
|
|
|
clearTimeout(livetime);
|
2014-06-27 00:17:24 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
livetime = setTimeout(liveUpdate, 10000);
|
|
|
|
return;
|
|
|
|
}
|
2021-08-27 05:15:24 +00:00
|
|
|
console.log('liveUpdate');
|
2018-01-24 10:16:51 +00:00
|
|
|
if(timer)
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
if(livetime !== null)
|
|
|
|
livetime = null;
|
2014-06-27 00:17:24 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
prev = 'live-' + src;
|
2014-06-27 00:17:24 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
in_progress = true;
|
2012-07-23 12:15:06 +00:00
|
|
|
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
if(scroll_next) {
|
|
|
|
bParam_page = next_page;
|
|
|
|
page_load = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bParam_page = 1;
|
2010-08-19 11:59:31 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
update_url = buildCmd();
|
2014-07-23 05:15:34 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
if(page_load) {
|
2017-09-26 11:02:11 +00:00
|
|
|
$("#page-spinner").show();
|
2015-03-15 21:18:59 +00:00
|
|
|
if(bParam_page == 1)
|
|
|
|
update_mode = 'replace';
|
|
|
|
else
|
|
|
|
update_mode = 'append';
|
|
|
|
}
|
2015-03-26 09:43:09 +00:00
|
|
|
else {
|
2015-03-15 21:18:59 +00:00
|
|
|
update_mode = 'update';
|
2021-08-11 02:25:23 +00:00
|
|
|
origHeight = $("#region_2").height();
|
2015-03-26 09:43:09 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let dstart = new Date();
|
2019-01-14 00:08:26 +00:00
|
|
|
console.log('LOADING data...' + update_url);
|
2015-03-15 21:18:59 +00:00
|
|
|
$.get(update_url, function(data) {
|
2016-11-02 04:39:49 +00:00
|
|
|
|
|
|
|
// on shared hosts occasionally the live update process will be killed
|
|
|
|
// leaving an incomplete HTML structure, which leads to conversations getting
|
|
|
|
// truncated and the page messed up if all the divs aren't closed. We will try
|
|
|
|
// again and give up if we can't get a valid HTML response after 10 tries.
|
|
|
|
|
|
|
|
if((data.indexOf("<html>") != (-1)) && (data.indexOf("</html>") == (-1))) {
|
|
|
|
console.log('Incomplete data. Reloading');
|
|
|
|
in_progress = false;
|
|
|
|
liveRecurse ++;
|
|
|
|
if(liveRecurse < 10) {
|
|
|
|
liveUpdate();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log('Incomplete data. Too many attempts. Giving up.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// else data was valid - reset the recursion counter
|
|
|
|
liveRecurse = 0;
|
|
|
|
|
2018-01-27 21:23:47 +00:00
|
|
|
if(typeof notify_id !== 'undefined' && notify_id !== 'undefined') {
|
2017-11-29 10:22:59 +00:00
|
|
|
$.post(
|
|
|
|
"hq",
|
|
|
|
{
|
|
|
|
"notify_id" : notify_id
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let dready = new Date();
|
2016-02-12 10:00:50 +00:00
|
|
|
console.log('DATA ready in: ' + (dready - dstart)/1000 + ' seconds.');
|
|
|
|
|
2016-02-17 11:32:12 +00:00
|
|
|
if(update_mode === 'update' || preloadImages) {
|
2016-02-16 19:53:38 +00:00
|
|
|
console.log('LOADING images...');
|
|
|
|
|
|
|
|
$('.wall-item-body, .wall-photo-item',data).imagesLoaded( function() {
|
2021-08-10 21:37:00 +00:00
|
|
|
let iready = new Date();
|
2016-02-16 19:53:38 +00:00
|
|
|
console.log('IMAGES ready in: ' + (iready - dready)/1000 + ' seconds.');
|
|
|
|
|
|
|
|
page_load = false;
|
|
|
|
scroll_next = false;
|
|
|
|
updateConvItems(update_mode,data);
|
2017-09-26 11:02:11 +00:00
|
|
|
$("#page-spinner").hide();
|
|
|
|
$("#profile-jot-text-loading").hide();
|
2016-02-16 19:53:38 +00:00
|
|
|
|
2016-02-17 10:07:47 +00:00
|
|
|
// adjust scroll position if new content was added above viewport
|
2019-01-25 03:03:14 +00:00
|
|
|
if(update_mode === 'update' && !justifiedGalleryActive) {
|
2021-08-11 02:25:23 +00:00
|
|
|
$(window).scrollTop($(window).scrollTop() + $("#region_2").height() - origHeight + contentHeightDiff);
|
2016-02-17 11:32:12 +00:00
|
|
|
}
|
2016-02-16 19:53:38 +00:00
|
|
|
|
|
|
|
in_progress = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
2016-02-16 13:42:13 +00:00
|
|
|
page_load = false;
|
|
|
|
scroll_next = false;
|
|
|
|
updateConvItems(update_mode,data);
|
2017-09-26 11:02:11 +00:00
|
|
|
$("#page-spinner").hide();
|
|
|
|
$("#profile-jot-text-loading").hide();
|
2015-03-15 21:18:59 +00:00
|
|
|
|
2016-02-16 13:42:13 +00:00
|
|
|
in_progress = false;
|
|
|
|
|
2016-02-16 19:53:38 +00:00
|
|
|
}
|
2016-02-12 10:00:50 +00:00
|
|
|
|
2017-11-29 07:34:47 +00:00
|
|
|
})
|
|
|
|
.done(function() {
|
|
|
|
notificationsUpdate();
|
2015-03-15 21:18:59 +00:00
|
|
|
});
|
|
|
|
}
|
2014-07-23 05:15:34 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function pageUpdate() {
|
2014-07-23 05:15:34 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
in_progress = true;
|
2014-07-23 05:15:34 +00:00
|
|
|
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
if(scroll_next) {
|
|
|
|
bParam_page = next_page;
|
|
|
|
page_load = true;
|
2014-07-23 05:15:34 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
else {
|
|
|
|
bParam_page = 1;
|
2014-09-11 08:35:19 +00:00
|
|
|
}
|
2014-07-23 05:15:34 +00:00
|
|
|
|
2020-09-09 00:52:06 +00:00
|
|
|
update_url = baseurl + '/' + decodeURIComponent(page_query) + '/?f=&aj=1&page=' + bParam_page + extra_args ;
|
|
|
|
|
2017-09-26 11:02:11 +00:00
|
|
|
$("#page-spinner").show();
|
2015-03-15 21:18:59 +00:00
|
|
|
update_mode = 'append';
|
2012-12-19 00:17:08 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
$.get(update_url,function(data) {
|
|
|
|
page_load = false;
|
|
|
|
scroll_next = false;
|
|
|
|
updatePageItems(update_mode,data);
|
2017-09-26 11:02:11 +00:00
|
|
|
$("#page-spinner").hide();
|
2016-10-12 08:59:19 +00:00
|
|
|
$(".autotime").timeago();
|
2015-03-15 21:18:59 +00:00
|
|
|
in_progress = false;
|
|
|
|
});
|
|
|
|
}
|
2012-07-18 05:11:24 +00:00
|
|
|
|
2015-12-07 11:13:51 +00:00
|
|
|
function justifyPhotos(id) {
|
2015-03-15 21:18:59 +00:00
|
|
|
justifiedGalleryActive = true;
|
2017-09-27 13:48:13 +00:00
|
|
|
$('#' + id).show();
|
2015-12-07 11:13:51 +00:00
|
|
|
$('#' + id).justifiedGallery({
|
2019-06-11 06:21:57 +00:00
|
|
|
selector: 'a, div:not(#page-end)',
|
2015-03-15 21:18:59 +00:00
|
|
|
margins: 3,
|
2019-06-11 06:21:57 +00:00
|
|
|
border: 0
|
2015-03-15 21:18:59 +00:00
|
|
|
}).on('jg.complete', function(e){ justifiedGalleryActive = false; });
|
|
|
|
}
|
2012-07-18 05:11:24 +00:00
|
|
|
|
2015-12-07 11:13:51 +00:00
|
|
|
function justifyPhotosAjax(id) {
|
2015-03-15 21:18:59 +00:00
|
|
|
justifiedGalleryActive = true;
|
2015-12-07 11:13:51 +00:00
|
|
|
$('#' + id).justifiedGallery('norewind').on('jg.complete', function(e){ justifiedGalleryActive = false; });
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2012-07-18 05:11:24 +00:00
|
|
|
|
2018-01-24 21:46:36 +00:00
|
|
|
function loadNotificationItems(notifyType) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let pingExCmd = 'ping/' + notifyType + ((localUser != 0) ? '?f=&uid=' + localUser : '');
|
2018-01-18 11:44:40 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let clicked = $('[data-type=\'' + notifyType + '\']').data('clicked');
|
2018-01-28 18:35:01 +00:00
|
|
|
|
2018-01-24 21:46:36 +00:00
|
|
|
if((clicked === undefined) && (sessionStorage.getItem(notifyType + '_notifications_cache') !== null)) {
|
2021-08-10 21:37:00 +00:00
|
|
|
cached_data = JSON.parse(sessionStorage.getItem(notifyType + '_notifications_cache'));
|
2018-01-24 10:16:51 +00:00
|
|
|
handleNotificationsItems(notifyType, cached_data);
|
2018-01-28 18:35:01 +00:00
|
|
|
$('[data-type=\'' + notifyType + '\']').data('clicked',true);
|
2018-01-24 21:46:36 +00:00
|
|
|
console.log('updating ' + notifyType + ' notifications from cache...');
|
2018-01-24 10:16:51 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-08-10 21:37:00 +00:00
|
|
|
cached_data = [];
|
2018-01-24 21:46:36 +00:00
|
|
|
}
|
2018-01-18 10:22:30 +00:00
|
|
|
|
2018-01-24 21:46:36 +00:00
|
|
|
console.log('updating ' + notifyType + ' notifications...');
|
2018-06-02 13:39:38 +00:00
|
|
|
|
2018-01-24 21:46:36 +00:00
|
|
|
$.get(pingExCmd, function(data) {
|
|
|
|
if(data.invalid == 1) {
|
|
|
|
window.location.href=window.location.href;
|
|
|
|
}
|
2017-10-12 18:36:25 +00:00
|
|
|
|
2018-01-24 21:46:36 +00:00
|
|
|
if(JSON.stringify(cached_data[0]) === JSON.stringify(data.notify[0])) {
|
2022-05-31 01:07:31 +00:00
|
|
|
console.log(notifyType + ' notifications cache up to date');
|
2018-01-24 21:46:36 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-01-24 10:16:51 +00:00
|
|
|
handleNotificationsItems(notifyType, data.notify);
|
2018-01-24 21:46:36 +00:00
|
|
|
sessionStorage.setItem(notifyType + '_notifications_cache', JSON.stringify(data.notify));
|
2017-10-17 22:25:00 +00:00
|
|
|
}
|
2018-01-24 21:46:36 +00:00
|
|
|
});
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2010-09-17 10:10:19 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
// Since our ajax calls are asynchronous, we will give a few
|
|
|
|
// seconds for the first ajax call (setting like/dislike), then
|
|
|
|
// run the updater to pick up any changes and display on the page.
|
|
|
|
// The updater will turn any rotators off when it's done.
|
|
|
|
// This function will have returned long before any of these
|
|
|
|
// events have completed and therefore there won't be any
|
|
|
|
// visible feedback that anything changed without all this
|
|
|
|
// trickery. This still could cause confusion if the "like" ajax call
|
2017-11-29 07:34:47 +00:00
|
|
|
// is delayed and updateInit runs before it completes.
|
2021-08-10 21:37:00 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function dolike(ident, verb) {
|
|
|
|
unpause();
|
2017-09-26 11:02:11 +00:00
|
|
|
$('#like-rotator-' + ident.toString()).show();
|
2017-11-29 07:34:47 +00:00
|
|
|
$.get('like/' + ident.toString() + '?verb=' + verb, updateInit );
|
2015-03-15 21:18:59 +00:00
|
|
|
liking = 1;
|
|
|
|
}
|
2014-06-23 05:16:26 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function doprofilelike(ident, verb) {
|
2021-07-17 11:28:12 +00:00
|
|
|
$.get('plike/' + ident + '?verb=' + verb, function() { window.location.href=window.location.href; });
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2014-06-23 05:16:26 +00:00
|
|
|
|
2018-05-03 03:08:59 +00:00
|
|
|
|
2019-12-03 02:42:59 +00:00
|
|
|
function dopin(id) {
|
|
|
|
id = id.toString();
|
|
|
|
$('#like-rotator-' + id).show();
|
|
|
|
$.post('pin', { 'id' : id })
|
|
|
|
.done(function() {
|
|
|
|
window.location.href=window.location.href;
|
|
|
|
})
|
|
|
|
.fail(function() {
|
|
|
|
window.location.href=window.location.href;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function dropItem(url, object) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let confirm = confirmDelete();
|
2019-12-03 02:42:59 +00:00
|
|
|
if(confirm) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let id = url.split('/')[2];
|
2019-12-03 02:42:59 +00:00
|
|
|
$('body').css('cursor', 'wait');
|
|
|
|
$(object + ', #pinned-wrapper-' + id).fadeTo('fast', 0.33, function () {
|
|
|
|
$.post('pin', { 'id' : id });
|
|
|
|
$.get(url).done(function() {
|
|
|
|
$(object + ', #pinned-wrapper-' + id).remove();
|
|
|
|
$('body').css('cursor', 'auto');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-12 12:30:33 +00:00
|
|
|
function dropItem(url, object) {
|
2018-05-03 03:08:59 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let confirm = confirmDelete();
|
2015-04-08 12:10:38 +00:00
|
|
|
if(confirm) {
|
|
|
|
$('body').css('cursor', 'wait');
|
|
|
|
$(object).fadeTo('fast', 0.33, function () {
|
2015-04-12 12:30:33 +00:00
|
|
|
$.get(url).done(function() {
|
2015-04-08 12:10:38 +00:00
|
|
|
$(object).remove();
|
|
|
|
$('body').css('cursor', 'auto');
|
|
|
|
});
|
|
|
|
});
|
2016-06-19 18:34:38 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
2015-04-08 12:10:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function dosubthread(ident) {
|
|
|
|
unpause();
|
2017-09-26 11:02:11 +00:00
|
|
|
$('#like-rotator-' + ident.toString()).show();
|
2017-11-29 07:34:47 +00:00
|
|
|
$.get('subthread/sub/' + ident.toString(), updateInit );
|
2015-03-15 21:18:59 +00:00
|
|
|
liking = 1;
|
|
|
|
}
|
2012-10-02 01:02:11 +00:00
|
|
|
|
2015-11-03 22:59:14 +00:00
|
|
|
function dounsubthread(ident) {
|
|
|
|
unpause();
|
2017-09-26 11:02:11 +00:00
|
|
|
$('#like-rotator-' + ident.toString()).show();
|
2017-11-29 07:34:47 +00:00
|
|
|
$.get('subthread/unsub/' + ident.toString(), updateInit );
|
2015-11-03 22:59:14 +00:00
|
|
|
liking = 1;
|
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function dostar(ident) {
|
|
|
|
ident = ident.toString();
|
2017-09-26 11:02:11 +00:00
|
|
|
$('#like-rotator-' + ident).show();
|
2015-03-15 21:18:59 +00:00
|
|
|
$.get('starred/' + ident, function(data) {
|
|
|
|
if(data.result == 1) {
|
|
|
|
$('#starred-' + ident).addClass('starred');
|
|
|
|
$('#starred-' + ident).removeClass('unstarred');
|
2018-04-13 09:58:12 +00:00
|
|
|
$('#starred-' + ident).addClass('fa-star');
|
2016-04-30 18:51:01 +00:00
|
|
|
$('#starred-' + ident).removeClass('fa-star-o');
|
2015-03-15 21:18:59 +00:00
|
|
|
$('#star-' + ident).addClass('hidden');
|
|
|
|
$('#unstar-' + ident).removeClass('hidden');
|
2021-08-10 21:37:00 +00:00
|
|
|
let 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>'
|
2018-04-13 09:58:12 +00:00
|
|
|
$('#wall-item-tools-left-' + ident).prepend(btn_tpl);
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#starred-' + ident).addClass('unstarred');
|
|
|
|
$('#starred-' + ident).removeClass('starred');
|
2016-04-30 18:51:01 +00:00
|
|
|
$('#starred-' + ident).addClass('fa-star-o');
|
2018-04-13 09:58:12 +00:00
|
|
|
$('#starred-' + ident).removeClass('fa-star');
|
2015-03-15 21:18:59 +00:00
|
|
|
$('#star-' + ident).removeClass('hidden');
|
|
|
|
$('#unstar-' + ident).addClass('hidden');
|
2018-04-13 09:58:12 +00:00
|
|
|
$('#star-button-' + ident).remove();
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2017-09-26 11:02:11 +00:00
|
|
|
$('#like-rotator-' + ident).hide();
|
2015-03-15 21:18:59 +00:00
|
|
|
});
|
|
|
|
}
|
2012-10-02 01:02:11 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function getPosition(e) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let cursor = {x:0, y:0};
|
2015-03-15 21:18:59 +00:00
|
|
|
if ( e.pageX || e.pageY ) {
|
|
|
|
cursor.x = e.pageX;
|
|
|
|
cursor.y = e.pageY;
|
2011-07-04 02:41:04 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
else {
|
|
|
|
if( e.clientX || e.clientY ) {
|
|
|
|
cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
|
|
|
|
cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
|
2010-09-30 05:11:26 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-03-15 21:18:59 +00:00
|
|
|
if( e.x || e.y ) {
|
|
|
|
cursor.x = e.x;
|
|
|
|
cursor.y = e.y;
|
2010-09-30 05:11:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
return cursor;
|
|
|
|
}
|
2010-09-30 05:11:26 +00:00
|
|
|
|
2015-04-21 20:45:54 +00:00
|
|
|
function lockview(type, id) {
|
|
|
|
$.get('lockview/' + type + '/' + id, function(data) {
|
2015-03-15 21:18:59 +00:00
|
|
|
$('#panel-' + id).html(data);
|
|
|
|
});
|
|
|
|
}
|
2010-09-30 05:11:26 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function filestorage(event, nick, id) {
|
|
|
|
$('#cloud-index-' + last_filestorage_id).removeClass('cloud-index-active');
|
|
|
|
$('#perms-panel-' + last_filestorage_id).hide().html('');
|
2017-09-26 11:02:11 +00:00
|
|
|
$('#file-edit-' + id).show();
|
2015-03-15 21:18:59 +00:00
|
|
|
$.get('filestorage/' + nick + '/' + id + '/edit', function(data) {
|
|
|
|
$('#cloud-index-' + id).addClass('cloud-index-active');
|
|
|
|
$('#perms-panel-' + id).html(data).show();
|
2017-09-26 11:02:11 +00:00
|
|
|
$('#file-edit-' + id).hide();
|
2015-03-15 21:18:59 +00:00
|
|
|
last_filestorage_id = id;
|
|
|
|
});
|
|
|
|
}
|
2014-12-21 19:11:30 +00:00
|
|
|
|
2020-01-27 23:54:43 +00:00
|
|
|
function submitPoll(id) {
|
|
|
|
|
|
|
|
$.post('vote/' + id,
|
2020-01-29 02:17:47 +00:00
|
|
|
$('#question-form-' + id).serialize(),
|
|
|
|
function(data) {
|
|
|
|
$.jGrowl(data.message, { sticky: false, theme: ((data.success) ? 'info' : 'notice'), life: 10000 });
|
2020-01-28 04:46:14 +00:00
|
|
|
if(timer) clearTimeout(timer);
|
|
|
|
timer = setTimeout(updateInit,1500);
|
2020-01-29 02:17:47 +00:00
|
|
|
}
|
2020-01-28 04:46:14 +00:00
|
|
|
);
|
2020-01-27 23:54:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function post_comment(id) {
|
|
|
|
unpause();
|
|
|
|
commentBusy = true;
|
|
|
|
$('body').css('cursor', 'wait');
|
|
|
|
$("#comment-preview-inp-" + id).val("0");
|
|
|
|
$.post(
|
|
|
|
"item",
|
|
|
|
$("#comment-edit-form-" + id).serialize(),
|
|
|
|
function(data) {
|
|
|
|
if(data.success) {
|
2018-04-13 10:50:37 +00:00
|
|
|
localStorage.removeItem("comment_body-" + id);
|
2015-03-15 21:18:59 +00:00
|
|
|
$("#comment-edit-preview-" + id).hide();
|
|
|
|
$("#comment-edit-wrapper-" + id).hide();
|
|
|
|
$("#comment-edit-text-" + id).val('');
|
2021-08-10 21:37:00 +00:00
|
|
|
let tarea = document.getElementById("comment-edit-text-" + id);
|
2017-08-28 02:02:50 +00:00
|
|
|
if(tarea) {
|
2015-03-15 21:18:59 +00:00
|
|
|
commentClose(tarea, id);
|
2017-08-28 02:02:50 +00:00
|
|
|
$(document).unbind( "click.commentOpen");
|
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
if(timer) clearTimeout(timer);
|
2017-11-29 07:34:47 +00:00
|
|
|
timer = setTimeout(updateInit,1500);
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
|
|
|
if(data.reload) {
|
|
|
|
window.location.href=data.reload;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
2011-02-14 12:43:19 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function preview_comment(id) {
|
|
|
|
$("#comment-preview-inp-" + id).val("1");
|
|
|
|
$("#comment-edit-preview-" + id).show();
|
|
|
|
$.post(
|
|
|
|
"item",
|
|
|
|
$("#comment-edit-form-" + id).serialize(),
|
|
|
|
function(data) {
|
|
|
|
if(data.preview) {
|
|
|
|
$("#comment-edit-preview-" + id).html(data.preview);
|
2016-04-11 04:30:35 +00:00
|
|
|
$("#comment-edit-preview-" + id + " .autotime").timeago();
|
2015-03-15 21:18:59 +00:00
|
|
|
$("#comment-edit-preview-" + id + " a").click(function() { return false; });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-06 00:38:24 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function importElement(elem) {
|
|
|
|
$.post(
|
|
|
|
"impel",
|
|
|
|
{ "element" : elem },
|
|
|
|
function(data) {
|
|
|
|
if(timer) clearTimeout(timer);
|
2017-11-29 07:34:47 +00:00
|
|
|
timer = setTimeout(updateInit,10);
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-06 00:38:24 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function preview_post() {
|
|
|
|
$("#jot-preview").val("1");
|
|
|
|
$("#jot-preview-content").show();
|
|
|
|
$.post(
|
|
|
|
"item",
|
|
|
|
$("#profile-jot-form").serialize(),
|
|
|
|
function(data) {
|
|
|
|
if(data.preview) {
|
|
|
|
$("#jot-preview-content").html(data.preview);
|
2016-04-11 04:30:35 +00:00
|
|
|
$("#jot-preview-content .autotime").timeago();
|
2015-03-15 21:18:59 +00:00
|
|
|
$("#jot-preview-content" + " a").click(function() { return false; });
|
2014-10-10 03:59:33 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
$("#jot-preview").val("0");
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-07 00:47:17 +00:00
|
|
|
|
2020-11-30 00:38:45 +00:00
|
|
|
function save_draft() {
|
|
|
|
$("#jot-draft").val("1");
|
|
|
|
$.post(
|
|
|
|
"item",
|
|
|
|
$("#profile-jot-form").serialize(),
|
|
|
|
function() {
|
|
|
|
itemCancel();
|
|
|
|
document.location.href=document.location.href;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-07 23:11:03 +00:00
|
|
|
function save_draft_comment(id) {
|
|
|
|
$("#comment-draft-" + id).val("1");
|
|
|
|
$.post(
|
|
|
|
"item",
|
|
|
|
$("#comment-edit-form-" + id).serialize(),
|
|
|
|
function() {
|
|
|
|
commentCancel(id);
|
|
|
|
document.location.href=document.location.href;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-30 00:38:45 +00:00
|
|
|
|
2016-12-14 01:30:02 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function unpause() {
|
|
|
|
// unpause auto reloads if they are currently stopped
|
|
|
|
totStopped = false;
|
|
|
|
stopped = false;
|
|
|
|
$('#pause').html('');
|
|
|
|
}
|
2012-01-06 00:38:24 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function bin2hex(s) {
|
|
|
|
// Converts the binary representation of data to hex
|
|
|
|
//
|
|
|
|
// version: 812.316
|
|
|
|
// discuss at: http://phpjs.org/functions/bin2hex
|
|
|
|
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
|
|
|
// + bugfixed by: Onno Marsman
|
|
|
|
// + bugfixed by: Linuxworld
|
|
|
|
// * example 1: bin2hex('Kev');
|
|
|
|
// * returns 1: '4b6576'
|
|
|
|
// * example 2: bin2hex(String.fromCharCode(0x00));
|
|
|
|
// * returns 2: '00'
|
2021-08-10 21:37:00 +00:00
|
|
|
let v,i, f = 0, a = [];
|
2015-03-15 21:18:59 +00:00
|
|
|
s += '';
|
|
|
|
f = s.length;
|
|
|
|
|
|
|
|
for (i = 0; i<f; i++) {
|
|
|
|
a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
|
2012-01-10 02:52:49 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
return a.join('');
|
|
|
|
}
|
2012-01-06 00:38:24 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function hex2bin(hex) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let bytes = [], str;
|
2013-12-23 23:13:09 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
for(let i=0; i< hex.length-1; i+=2)
|
2015-03-15 21:18:59 +00:00
|
|
|
bytes.push(parseInt(hex.substr(i, 2), 16));
|
2011-04-13 04:21:33 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
return String.fromCharCode.apply(String, bytes);
|
|
|
|
}
|
2011-04-13 04:21:33 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function groupChangeMember(gid, cid, sec_token) {
|
|
|
|
$('body .fakelink').css('cursor', 'wait');
|
2019-10-02 02:03:48 +00:00
|
|
|
$.get('lists/' + gid + '/' + cid + "?t=" + sec_token, function(data) {
|
2015-03-15 21:18:59 +00:00
|
|
|
$('#group-update-wrapper').html(data);
|
|
|
|
$('body .fakelink').css('cursor', 'auto');
|
|
|
|
});
|
|
|
|
}
|
2011-08-03 05:39:35 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function profChangeMember(gid, cid) {
|
|
|
|
$('body .fakelink').css('cursor', 'wait');
|
|
|
|
$.get('profperm/' + gid + '/' + cid, function(data) {
|
|
|
|
$('#prof-update-wrapper').html(data);
|
|
|
|
$('body .fakelink').css('cursor', 'auto');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function contactgroupChangeMember(gid, cid) {
|
|
|
|
$('body').css('cursor', 'wait');
|
|
|
|
$.get('contactgroup/' + gid + '/' + cid, function(data) {
|
|
|
|
$('body').css('cursor', 'auto');
|
2016-04-30 18:51:01 +00:00
|
|
|
$('#group-' + gid).toggleClass('fa-check-square-o fa-square-o');
|
2015-03-15 21:18:59 +00:00
|
|
|
});
|
|
|
|
}
|
2011-08-03 05:39:35 +00:00
|
|
|
|
2011-06-18 05:58:15 +00:00
|
|
|
function checkboxhighlight(box) {
|
2015-03-15 21:18:59 +00:00
|
|
|
if($(box).is(':checked')) {
|
|
|
|
$(box).addClass('checkeditem');
|
|
|
|
} else {
|
|
|
|
$(box).removeClass('checkeditem');
|
|
|
|
}
|
2011-06-18 05:58:15 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
/**
|
|
|
|
* sprintf in javascript
|
|
|
|
* "{0} and {1}".format('zero','uno');
|
|
|
|
*/
|
2011-06-16 12:56:43 +00:00
|
|
|
String.prototype.format = function() {
|
2021-08-10 21:37:00 +00:00
|
|
|
let formatted = this;
|
|
|
|
for (let i = 0; i < arguments.length; i++) {
|
|
|
|
let regexp = new RegExp('\\{'+i+'\\}', 'gi');
|
2015-03-15 21:18:59 +00:00
|
|
|
formatted = formatted.replace(regexp, arguments[i]);
|
|
|
|
}
|
|
|
|
return formatted;
|
2011-06-16 12:56:43 +00:00
|
|
|
};
|
2017-11-29 07:34:47 +00:00
|
|
|
|
2011-07-19 14:17:58 +00:00
|
|
|
// Array Remove
|
|
|
|
Array.prototype.remove = function(item) {
|
2015-03-15 21:18:59 +00:00
|
|
|
to = undefined;
|
|
|
|
from = this.indexOf(item);
|
2021-08-10 21:37:00 +00:00
|
|
|
let rest = this.slice((to || from) + 1 || this.length);
|
2015-03-15 21:18:59 +00:00
|
|
|
this.length = from < 0 ? this.length + from : from;
|
|
|
|
return this.push.apply(this, rest);
|
2011-07-19 14:17:58 +00:00
|
|
|
};
|
2011-08-11 04:06:35 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function zFormError(elm,x) {
|
|
|
|
if(x) {
|
|
|
|
$(elm).addClass("zform-error");
|
|
|
|
$(elm).removeClass("zform-ok");
|
|
|
|
} else {
|
|
|
|
$(elm).addClass("zform-ok");
|
|
|
|
$(elm).removeClass("zform-error");
|
2012-12-13 12:47:06 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2012-12-13 12:47:06 +00:00
|
|
|
|
2013-06-14 02:21:45 +00:00
|
|
|
|
2014-09-11 08:35:19 +00:00
|
|
|
$(window).scroll(function () {
|
2012-12-11 02:24:59 +00:00
|
|
|
if(typeof buildCmd == 'function') {
|
2014-07-23 05:15:34 +00:00
|
|
|
// This is a content page with items and/or conversations
|
2016-02-15 21:20:55 +00:00
|
|
|
if($(window).scrollTop() + $(window).height() > $(document).height() - 300) {
|
2013-09-26 04:22:36 +00:00
|
|
|
if((pageHasMoreContent) && (! loadingPage)) {
|
2013-06-14 02:21:45 +00:00
|
|
|
next_page++;
|
|
|
|
scroll_next = true;
|
|
|
|
loadingPage = true;
|
|
|
|
liveUpdate();
|
|
|
|
}
|
2012-12-11 02:24:59 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-23 05:15:34 +00:00
|
|
|
else {
|
|
|
|
// This is some other kind of page - perhaps a directory
|
2016-02-15 21:20:55 +00:00
|
|
|
if($(window).scrollTop() + $(window).height() > $(document).height() - 300) {
|
2014-09-12 19:04:43 +00:00
|
|
|
if((pageHasMoreContent) && (! loadingPage) && (! justifiedGalleryActive)) {
|
2014-07-23 05:15:34 +00:00
|
|
|
next_page++;
|
|
|
|
scroll_next = true;
|
|
|
|
loadingPage = true;
|
|
|
|
pageUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-11 02:24:59 +00:00
|
|
|
});
|
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let chanviewFullSize = false;
|
2012-12-11 02:24:59 +00:00
|
|
|
|
2013-01-25 10:53:41 +00:00
|
|
|
function chanviewFull() {
|
|
|
|
if(chanviewFullSize) {
|
|
|
|
chanviewFullSize = false;
|
2013-01-25 11:52:16 +00:00
|
|
|
$('#chanview-iframe-border').css({ 'position' : 'relative', 'z-index' : '10' });
|
|
|
|
$('#remote-channel').css({ 'position' : 'relative' , 'z-index' : '10' });
|
2013-01-25 10:53:41 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
chanviewFullSize = true;
|
2013-01-25 11:52:16 +00:00
|
|
|
$('#chanview-iframe-border').css({ 'position' : 'fixed', 'top' : '0', 'left' : '0', 'z-index' : '150001' });
|
|
|
|
$('#remote-channel').css({ 'position' : 'fixed', 'top' : '0', 'left' : '0', 'z-index' : '150000' });
|
2013-01-25 10:53:41 +00:00
|
|
|
resize_iframe();
|
|
|
|
}
|
|
|
|
}
|
2013-11-12 23:44:49 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function addhtmltext(data) {
|
|
|
|
data = h2b(data);
|
|
|
|
addeditortext(data);
|
|
|
|
}
|
2013-11-12 23:44:49 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function loadText(textRegion,data) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let currentText = $(textRegion).val();
|
2015-03-15 21:18:59 +00:00
|
|
|
$(textRegion).val(currentText + data);
|
|
|
|
}
|
2015-03-05 04:00:54 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function addeditortext(data) {
|
|
|
|
if(plaintext == 'none') {
|
2021-08-10 21:37:00 +00:00
|
|
|
let currentText = $("#profile-jot-text").val();
|
2015-03-15 21:18:59 +00:00
|
|
|
$("#profile-jot-text").val(currentText + data);
|
2015-03-05 04:00:54 +00:00
|
|
|
}
|
2015-03-15 21:18:59 +00:00
|
|
|
}
|
2015-03-05 04:00:54 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function h2b(s) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let y = s;
|
2015-03-15 21:18:59 +00:00
|
|
|
function rep(re, str) {
|
|
|
|
y = y.replace(re,str);
|
2013-11-13 00:48:31 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
|
|
|
|
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
|
|
|
|
rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
|
|
|
|
rep(/<font>(.*?)<\/font>/gi,"$1");
|
|
|
|
rep(/<img.*?width=\"(.*?)\".*?height=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$1x$2]$3[/img]");
|
|
|
|
rep(/<img.*?height=\"(.*?)\".*?width=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$2x$1]$3[/img]");
|
|
|
|
rep(/<img.*?src=\"(.*?)\".*?height=\"(.*?)\".*?width=\"(.*?)\".*?\/>/gi,"[img=$3x$2]$1[/img]");
|
|
|
|
rep(/<img.*?src=\"(.*?)\".*?width=\"(.*?)\".*?height=\"(.*?)\".*?\/>/gi,"[img=$2x$3]$1[/img]");
|
|
|
|
rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
|
|
|
|
|
|
|
|
rep(/<ul class=\"listbullet\" style=\"list-style-type\: circle\;\">(.*?)<\/ul>/gi,"[list]$1[/list]");
|
|
|
|
rep(/<ul class=\"listnone\" style=\"list-style-type\: none\;\">(.*?)<\/ul>/gi,"[list=]$1[/list]");
|
|
|
|
rep(/<ul class=\"listdecimal\" style=\"list-style-type\: decimal\;\">(.*?)<\/ul>/gi,"[list=1]$1[/list]");
|
|
|
|
rep(/<ul class=\"listlowerroman\" style=\"list-style-type\: lower-roman\;\">(.*?)<\/ul>/gi,"[list=i]$1[/list]");
|
|
|
|
rep(/<ul class=\"listupperroman\" style=\"list-style-type\: upper-roman\;\">(.*?)<\/ul>/gi,"[list=I]$1[/list]");
|
|
|
|
rep(/<ul class=\"listloweralpha\" style=\"list-style-type\: lower-alpha\;\">(.*?)<\/ul>/gi,"[list=a]$1[/list]");
|
|
|
|
rep(/<ul class=\"listupperalpha\" style=\"list-style-type\: upper-alpha\;\">(.*?)<\/ul>/gi,"[list=A]$1[/list]");
|
|
|
|
rep(/<li>(.*?)<\/li>/gi,"[li]$1[/li]");
|
|
|
|
|
|
|
|
rep(/<code>(.*?)<\/code>/gi,"[code]$1[/code]");
|
|
|
|
rep(/<\/(strong|b)>/gi,"[/b]");
|
|
|
|
rep(/<(strong|b)>/gi,"[b]");
|
|
|
|
rep(/<\/(em|i)>/gi,"[/i]");
|
|
|
|
rep(/<(em|i)>/gi,"[i]");
|
|
|
|
rep(/<\/u>/gi,"[/u]");
|
|
|
|
|
|
|
|
rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
|
|
|
|
rep(/<u>/gi,"[u]");
|
|
|
|
rep(/<blockquote[^>]*>/gi,"[quote]");
|
|
|
|
rep(/<\/blockquote>/gi,"[/quote]");
|
|
|
|
rep(/<hr \/>/gi,"[hr]");
|
|
|
|
rep(/<br (.*?)\/>/gi,"\n");
|
|
|
|
rep(/<br\/>/gi,"\n");
|
|
|
|
rep(/<br>/gi,"\n");
|
|
|
|
rep(/<p>/gi,"");
|
|
|
|
rep(/<\/p>/gi,"\n");
|
|
|
|
rep(/ /gi," ");
|
|
|
|
rep(/"/gi,"\"");
|
|
|
|
rep(/</gi,"<");
|
|
|
|
rep(/>/gi,">");
|
|
|
|
rep(/&/gi,"&");
|
|
|
|
|
|
|
|
return y;
|
|
|
|
}
|
2013-11-12 23:44:49 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
function b2h(s) {
|
2021-08-10 21:37:00 +00:00
|
|
|
let y = s;
|
2015-03-15 21:18:59 +00:00
|
|
|
function rep(re, str) {
|
|
|
|
y = y.replace(re,str);
|
|
|
|
}
|
2013-11-12 23:44:49 +00:00
|
|
|
|
2015-03-15 21:18:59 +00:00
|
|
|
rep(/\&/gi,"&");
|
|
|
|
rep(/\</gi,"<");
|
|
|
|
rep(/\>/gi,">");
|
|
|
|
rep(/\"/gi,""");
|
|
|
|
|
2019-11-22 04:00:57 +00:00
|
|
|
rep(/\n/gi,"<br>");
|
2015-03-15 21:18:59 +00:00
|
|
|
rep(/\[b\]/gi,"<strong>");
|
|
|
|
rep(/\[\/b\]/gi,"</strong>");
|
|
|
|
rep(/\[i\]/gi,"<em>");
|
|
|
|
rep(/\[\/i\]/gi,"</em>");
|
|
|
|
rep(/\[u\]/gi,"<u>");
|
|
|
|
rep(/\[\/u\]/gi,"</u>");
|
|
|
|
rep(/\[hr\]/gi,"<hr />");
|
|
|
|
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
|
|
|
|
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
|
|
|
|
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
|
|
|
|
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
|
|
|
|
|
|
|
|
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 + "\" />");
|
|
|
|
rep(/\[zmg\](.*?)\[\/zmg\]/gi,"<img src=\"$1" + '?f=&zid=' + zid + "\" />");
|
|
|
|
|
|
|
|
rep(/\[list\](.*?)\[\/list\]/gi, '<ul class="listbullet" style="list-style-type: circle;">$1</ul>');
|
|
|
|
rep(/\[list=\](.*?)\[\/list\]/gi, '<ul class="listnone" style="list-style-type: none;">$1</ul>');
|
|
|
|
rep(/\[list=1\](.*?)\[\/list\]/gi, '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>');
|
|
|
|
rep(/\[list=i\](.*?)\[\/list\]/gi,'<ul class="listlowerroman" style="list-style-type: lower-roman;">$1</ul>');
|
|
|
|
rep(/\[list=I\](.*?)\[\/list\]/gi, '<ul class="listupperroman" style="list-style-type: upper-roman;">$1</ul>');
|
|
|
|
rep(/\[list=a\](.*?)\[\/list\]/gi, '<ul class="listloweralpha" style="list-style-type: lower-alpha;">$1</ul>');
|
|
|
|
rep(/\[list=A\](.*?)\[\/list\]/gi, '<ul class="listupperalpha" style="list-style-type: upper-alpha;">$1</ul>');
|
|
|
|
rep(/\[li\](.*?)\[\/li\]/gi, '<li>$1</li>');
|
|
|
|
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");
|
|
|
|
rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"<span style=\"font-size: $1;\">$2</span>");
|
|
|
|
rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");
|
|
|
|
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");
|
|
|
|
|
|
|
|
rep(/\[video\](.*?)\[\/video\]/gi,"<a href=\"$1\">$1</a>");
|
|
|
|
rep(/\[audio\](.*?)\[\/audio\]/gi,"<a href=\"$1\">$1</a>");
|
|
|
|
|
|
|
|
rep(/\[\&\;([#a-z0-9]+)\;\]/gi,'&$1;');
|
|
|
|
|
|
|
|
rep(/\<(.*?)(src|href)=\"[^hfm](.*?)\>/gi,'<$1$2="">');
|
|
|
|
|
|
|
|
return y;
|
|
|
|
}
|
2013-11-12 23:44:49 +00:00
|
|
|
|
2021-08-24 04:44:37 +00:00
|
|
|
function dozid(s) {
|
2013-11-12 23:44:49 +00:00
|
|
|
if((! s.length) || (s.indexOf('zid=') != (-1)))
|
|
|
|
return s;
|
2015-03-15 21:18:59 +00:00
|
|
|
|
2013-11-12 23:44:49 +00:00
|
|
|
if(! zid.length)
|
|
|
|
return s;
|
2015-03-15 21:18:59 +00:00
|
|
|
|
2021-08-10 21:37:00 +00:00
|
|
|
let has_params = ((s.indexOf('?') == (-1)) ? false : true);
|
|
|
|
let achar = ((has_params) ? '&' : '?');
|
2013-11-12 23:44:49 +00:00
|
|
|
s = s + achar + 'f=&zid=' + zid;
|
2015-03-15 21:18:59 +00:00
|
|
|
|
2013-11-12 23:44:49 +00:00
|
|
|
return s;
|
2015-03-26 08:45:30 +00:00
|
|
|
}
|
2021-09-07 06:32:54 +00:00
|
|
|
|
|
|
|
function push_notification_request(e) {
|
|
|
|
if ('Notification' in window) {
|
|
|
|
if (Notification.permission !== 'granted') {
|
|
|
|
Notification.requestPermission(function(permission) {
|
|
|
|
if(permission === 'granted') {
|
|
|
|
$(e.target).closest('div').hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function push_notification(title, body, b64mid) {
|
|
|
|
let options = {
|
|
|
|
body: body,
|
|
|
|
data: b64mid,
|
|
|
|
icon: aStr.icon,
|
|
|
|
silent: false
|
|
|
|
}
|
|
|
|
|
|
|
|
let n = new Notification(title, options);
|
|
|
|
n.onclick = function (e) {
|
2022-08-21 23:46:32 +00:00
|
|
|
window.location.href = baseurl + '/display/?mid=' + e.target.data;
|
2021-09-07 06:32:54 +00:00
|
|
|
}
|
|
|
|
}
|