1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-02 12:57:35 +01:00

Merge pull request #873 from Zankaria/cleanup-pre-mobile-ui

Cleanup pre mobile UI
This commit is contained in:
Lorenzo Yario 2025-01-05 02:00:20 -06:00 committed by GitHub
commit f39988229a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 271 additions and 264 deletions

View File

@ -17,62 +17,62 @@
*
* You must have boardlinks or else this script will not load.
* Search for "$config['boards'] = array(" within your inc/config.php and add something similar to your instance-config.php.
*
*/
auto_reload_enabled = true; // for watch.js to interop
auto_reload_enabled = true; // For watch.js to interop.
$(document).ready(function(){
if($('div.banner').length == 0)
return; // not index
if($('div.banner').length == 0) {
// Not index.
return;
}
if($(".post.op").size() != 1)
return; //not thread page
if($(".post.op").size() != 1) {
// Not thread page.
return;
}
var countdown_interval;
// Add an update link
// Add an update link.
$('.boardlist.bottom').prev().after("<span id='updater'><a href='#' id='update_thread' style='padding-left:10px'>["+_("Update")+"]</a> (<input type='checkbox' id='auto_update_status' checked> "+_("Auto")+") <span id='update_secs'></span></span>");
// Grab the settings
// Grab the settings.
var settings = new script_settings('auto-reload');
var poll_interval_mindelay = settings.get('min_delay_bottom', 5000);
var poll_interval_maxdelay = settings.get('max_delay', 600000);
var poll_interval_errordelay = settings.get('error_delay', 30000);
// number of ms to wait before reloading
// number of ms to wait before reloading.
var poll_interval_delay = poll_interval_mindelay;
var poll_current_time = poll_interval_delay;
var end_of_page = false;
var new_posts = 0;
var first_new_post = null;
var new_posts = 0;
var title = document.title;
if (typeof update_title == "undefined") {
var update_title = function() {
if (new_posts) {
document.title = "("+new_posts+") "+title;
} else {
document.title = title;
}
};
var update_title = function() {
if (new_posts) {
document.title = "("+new_posts+") "+title;
} else {
document.title = title;
}
};
}
if (typeof add_title_collector != "undefined")
add_title_collector(function(){
return new_posts;
});
if (typeof add_title_collector != "undefined") {
add_title_collector(function() {
return new_posts;
});
}
var window_active = true;
$(window).focus(function() {
window_active = true;
recheck_activated();
// Reset the delay if needed
// Reset the delay if needed.
if(settings.get('reset_focus', true)) {
poll_interval_delay = poll_interval_mindelay;
}
@ -89,7 +89,6 @@ $(document).ready(function(){
stop_auto_update();
$('#update_secs').text("");
}
});
@ -110,7 +109,6 @@ $(document).ready(function(){
new_posts = 0;
}
update_title();
first_new_post = null;
};
// automatically updates the thread after a specified delay
@ -126,14 +124,14 @@ $(document).ready(function(){
clearInterval(countdown_interval);
}
var epoch = (new Date).getTime();
var epochold = epoch;
var epoch = (new Date).getTime();
var epochold = epoch;
var timeDiff = function (delay) {
if((epoch-epochold) > delay) {
if ((epoch-epochold) > delay) {
epochold = epoch = (new Date).getTime();
return true;
}else{
} else {
epoch = (new Date).getTime();
return;
}
@ -152,9 +150,6 @@ $(document).ready(function(){
$(data).find('div.post.reply').each(function() {
var id = $(this).attr('id');
if($('#' + id).length == 0) {
if (!new_posts) {
first_new_post = this;
}
new_posts++;
loaded_posts++;
elementsToAppend.push($(this));
@ -225,16 +220,14 @@ $(document).ready(function(){
$(window).scroll(function() {
recheck_activated();
// if the newest post is not visible
// If the newest post is not visible.
if($(this).scrollTop() + $(this).height() <
$('div.post:last').position().top + $('div.post:last').height()) {
end_of_page = false;
return;
} else {
if($("#auto_update_status").is(':checked') && timeDiff(poll_interval_mindelay)) {
poll(manualUpdate = true);
}
end_of_page = true;
}
});

View File

@ -10,60 +10,61 @@
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/expand.js';
*
*/
$(document).ready(function(){
if($('span.omitted').length == 0)
return; // nothing to expand
$(document).ready(function() {
if ($('span.omitted').length === 0) {
// Nothing to expand.
return;
}
var do_expand = function() {
let doExpand = function() {
$(this)
.html($(this).text().replace(_("Click reply to view."), '<a href="javascript:void(0)">'+_("Click to expand")+'</a>.'))
.find('a').click(window.expand_fun = function() {
var thread = $(this).parents('[id^="thread_"]');
var id = thread.attr('id').replace(/^thread_/, '');
.html($(this).text().replace(_("Click reply to view."), '<a href="javascript:void(0)">' + _("Click to expand") + '</a>.'))
.find('a').click(window.expandFun = function() {
let thread = $(this).parents('[id^="thread_"]');
$.ajax({
url: thread.find('p.intro a.post_no:first').attr('href'),
context: document.body,
success: function(data) {
var last_expanded = false;
let lastExpanded = false;
$(data).find('div.post.reply').each(function() {
thread.find('div.hidden').remove();
var post_in_doc = thread.find('#' + $(this).attr('id'));
if(post_in_doc.length == 0) {
if(last_expanded) {
$(this).addClass('expanded').insertAfter(last_expanded).before('<br class="expanded">');
let postInDoc = thread.find('#' + $(this).attr('id'));
if (postInDoc.length === 0) {
if (lastExpanded) {
$(this).addClass('expanded').insertAfter(lastExpanded).before('<br class="expanded">');
} else {
$(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('<br class="expanded">');
}
last_expanded = $(this);
lastExpanded = $(this);
$(document).trigger('new_post', this);
} else {
last_expanded = post_in_doc;
lastExpanded = postInDoc;
}
});
thread.find("span.omitted").css('display', 'none');
thread.find('span.omitted').css('display', 'none');
$('<span class="omitted hide-expanded"><a href="javascript:void(0)">' + _('Hide expanded replies') + '</a>.</span>')
.insertAfter(thread.find('.op div.body, .op span.omitted').last())
.click(function() {
thread.find('.expanded').remove();
$(this).parent().find(".omitted:not(.hide-expanded)").css('display', '');
$(this).parent().find(".hide-expanded").remove();
let parent = $(this).parent();
parent.find('.omitted:not(.hide-expanded)').css('display', '');
parent.find('.hide-expanded').remove();
});
}
});
});
}
$('div.post.op span.omitted').each(do_expand);
$('div.post.op span.omitted').each(doExpand);
$(document).on("new_post", function(e, post) {
if (!$(post).hasClass("reply")) {
$(post).find('div.post.op span.omitted').each(do_expand);
$(document).on('new_post', function(e, post) {
if (!$(post).hasClass('reply')) {
$(post).find('div.post.op span.omitted').each(doExpand);
}
});
});

View File

@ -9,31 +9,31 @@
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/inline-expanding.js';
*
*/
$(document).ready(function(){
$(document).ready(function() {
'use strict';
var DEFAULT_MAX = 5; // default maximum image loads
var inline_expand_post = function() {
var link = this.getElementsByTagName('a');
// Default maximum image loads.
const DEFAULT_MAX = 5;
var loadingQueue = (function () {
var MAX_IMAGES = localStorage.inline_expand_max || DEFAULT_MAX; // maximum number of images to load concurrently, 0 to disable
var loading = 0; // number of images that is currently loading
var waiting = []; // waiting queue
let inline_expand_post = function() {
let link = this.getElementsByTagName('a');
var enqueue = function (ele) {
let loadingQueue = (function() {
let MAX_IMAGES = localStorage.inline_expand_max || DEFAULT_MAX; // Maximum number of images to load concurrently, 0 to disable.
let loading = 0; // Number of images that is currently loading.
let waiting = []; // Waiting queue.
let enqueue = function(ele) {
waiting.push(ele);
};
var dequeue = function () {
let dequeue = function() {
return waiting.shift();
};
var update = function() {
var ele;
let update = function() {
while (loading < MAX_IMAGES || MAX_IMAGES === 0) {
ele = dequeue();
let ele = dequeue();
if (ele) {
++loading;
ele.deferred.resolve();
@ -43,8 +43,8 @@ $(document).ready(function(){
}
};
return {
remove: function (ele) {
var i = waiting.indexOf(ele);
remove: function(ele) {
let i = waiting.indexOf(ele);
if (i > -1) {
waiting.splice(i, 1);
}
@ -54,14 +54,14 @@ $(document).ready(function(){
--loading;
}
},
add: function (ele) {
add: function(ele) {
ele.deferred = $.Deferred();
ele.deferred.done(function () {
var $loadstart = $.Deferred();
var thumb = ele.childNodes[0];
var img = ele.childNodes[1];
let $loadstart = $.Deferred();
let thumb = ele.childNodes[0];
let img = ele.childNodes[1];
var onLoadStart = function (img) {
let onLoadStart = function (img) {
if (img.naturalWidth) {
$loadstart.resolve(img, thumb);
} else {
@ -71,7 +71,7 @@ $(document).ready(function(){
$(img).one('load', function () {
$.when($loadstart).done(function () {
// once fully loaded, update the waiting queue
// Once fully loaded, update the waiting queue.
--loading;
$(ele).data('imageLoading', 'false');
update();
@ -93,35 +93,36 @@ $(document).ready(function(){
} else {
enqueue(ele);
}
}
};
})();
for (var i = 0; i < link.length; i++) {
for (let i = 0; i < link.length; i++) {
if (typeof link[i] == "object" && link[i].childNodes && typeof link[i].childNodes[0] !== 'undefined' &&
link[i].childNodes[0].src && link[i].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) {
link[i].onclick = function(e) {
var img, post_body, still_open, canvas, scroll;
var thumb = this.childNodes[0];
var padding = 5;
var boardlist = $('.boardlist')[0];
let thumb = this.childNodes[0];
let padding = 5;
let boardlist = $('.boardlist')[0];
if (thumb.className == 'hidden')
if (thumb.className == 'hidden') {
return false;
if (e.which == 2 || e.ctrlKey) // open in new tab
}
if (e.which == 2 || e.ctrlKey) {
// Open in new tab.
return true;
}
if (!$(this).data('expanded')) {
if (~this.parentNode.className.indexOf('multifile'))
if (~this.parentNode.className.indexOf('multifile')) {
$(this).data('width', this.parentNode.style.width);
}
this.parentNode.removeAttribute('style');
$(this).data('expanded', 'true');
if (thumb.tagName === 'CANVAS') {
canvas = thumb;
let canvas = thumb;
thumb = thumb.nextSibling;
this.removeChild(canvas);
canvas.style.display = 'block';
@ -130,7 +131,7 @@ $(document).ready(function(){
thumb.style.opacity = '0.4';
thumb.style.filter = 'alpha(opacity=40)';
img = document.createElement('img');
let img = document.createElement('img');
img.className = 'full-image';
img.style.display = 'none';
img.setAttribute('alt', 'Fullsized image');
@ -140,41 +141,48 @@ $(document).ready(function(){
} else {
loadingQueue.remove(this);
scroll = false;
let scroll = false;
// scroll to thumb if not triggered by 'shrink all image'
// Scroll to thumb if not triggered by 'shrink all image'.
if (e.target.className == 'full-image') {
scroll = true;
}
if (~this.parentNode.className.indexOf('multifile'))
if (~this.parentNode.className.indexOf('multifile')) {
this.parentNode.style.width = $(this).data('width');
}
thumb.style.opacity = '';
thumb.style.display = '';
if (thumb.nextSibling) this.removeChild(thumb.nextSibling); //full image loaded or loading
if (thumb.nextSibling) {
// Full image loaded or loading.
this.removeChild(thumb.nextSibling);
}
$(this).removeData('expanded');
delete thumb.style.filter;
// do the scrolling after page reflow
// Do the scrolling after page reflow.
if (scroll) {
post_body = $(thumb).parentsUntil('form > div').last();
let post_body = $(thumb).parentsUntil('form > div').last();
// on multifile posts, determin how many other images are still expanded
still_open = post_body.find('.post-image').filter(function(){
// On multifile posts, determine how many other images are still expanded.
let still_open = post_body.find('.post-image').filter(function() {
return $(this).parent().data('expanded') == 'true';
}).length;
// deal with differnt boards' menu styles
if ($(boardlist).css('position') == 'fixed')
// Deal with different boards menu styles.
if ($(boardlist).css('position') == 'fixed') {
padding += boardlist.getBoundingClientRect().height;
}
if (still_open > 0) {
if (thumb.getBoundingClientRect().top - padding < 0)
if (thumb.getBoundingClientRect().top - padding < 0) {
$(document).scrollTop($(thumb).parent().parent().offset().top - padding);
}
} else {
if (post_body[0].getBoundingClientRect().top - padding < 0)
if (post_body[0].getBoundingClientRect().top - padding < 0) {
$(document).scrollTop(post_body.offset().top - padding);
}
}
}
@ -188,17 +196,18 @@ $(document).ready(function(){
}
};
// setting up user option
// Setting up user option.
if (window.Options && Options.get_tab('general')) {
Options.extend_tab('general', '<span id="inline-expand-max">'+ _('Number of simultaneous image downloads (0 to disable): ') +
'<input type="number" step="1" min="0" size="4"></span>');
Options.extend_tab('general', '<span id="inline-expand-max">' +
_('Number of simultaneous image downloads (0 to disable): ') +
'<input type="number" step="1" min="0" size="4"></span>');
$('#inline-expand-max input')
.css('width', '50px')
.val(localStorage.inline_expand_max || DEFAULT_MAX)
.on('change', function (e) {
// validation in case some fucktard tries to enter a negative floating point number
var n = parseInt(e.target.value);
var val = (n<0) ? 0 : n;
// Validation in case some fucktard tries to enter a negative floating point number.
let n = parseInt(e.target.value);
let val = (n < 0) ? 0 : n;
localStorage.inline_expand_max = val;
});
@ -207,7 +216,7 @@ $(document).ready(function(){
if (window.jQuery) {
$('div[id^="thread_"]').each(inline_expand_post);
// allow to work with auto-reload.js, etc.
// Allow to work with auto-reload.js, etc.
$(document).on('new_post', function(e, post) {
inline_expand_post.call(post);
});

View File

@ -85,7 +85,7 @@ if (active_page == 'index' && (""+document.location).match(/\/(index\.html)?(\?|
if ($(th).find(".new-posts").html() != msg) {
$(th).find(".new-posts").html(msg);
$(th).find(".new-posts a").click(window.expand_fun);
$(th).find(".new-posts a").click(window.expandFun);
}
};

View File

@ -1,3 +1,9 @@
/* Depends on post-menu.js
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/post-menu.js';
* $config['additional_javascript'][] = 'js/post-filter.js';
*/
if (active_page === 'thread' || active_page === 'index' || active_page === 'catalog' || active_page === 'ukko') {
$(document).on('menu_ready', function () {
'use strict';

View File

@ -10,17 +10,15 @@
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/quick-post-controls.js';
*
*/
$(document).ready(function(){
var open_form = function() {
var thread = $(this).parent().parent().hasClass('op');
var id = $(this).attr('name').match(/^delete_(\d+)$/)[1];
var submitButton;
$(document).ready(function() {
let open_form = function() {
let thread = $(this).parent().parent().hasClass('op');
let id = $(this).attr('name').match(/^delete_(\d+)$/)[1];
if(this.checked) {
var post_form = $('<form class="post-actions" method="post" style="margin:10px 0 0 0">' +
if (this.checked) {
let post_form = $('<form class="post-actions" method="post" style="margin:10px 0 0 0">' +
'<div style="text-align:right">' +
(!thread ? '<hr>' : '') +
@ -29,14 +27,14 @@ $(document).ready(function(){
'<label for="password_' + id + '">'+_("Password")+'</label>: ' +
'<input id="password_' + id + '" type="password" name="password" size="11" maxlength="18">' +
'<input title="'+_('Delete file only')+'" type="checkbox" name="file" id="delete_file_' + id + '">' +
'<label for="delete_file_' + id + '">'+_('File')+'</label>' +
' <input type="submit" name="delete" value="'+_('Delete')+'">' +
'<label for="delete_file_' + id + '">' + _('File') + '</label>' +
' <input type="submit" name="delete" value="' + _('Delete') + '">' +
'<br>' +
'<label for="reason_' + id + '">'+_('Reason')+'</label>: ' +
'<label for="reason_' + id + '">' + _('Reason') + '</label>: ' +
'<input id="reason_' + id + '" type="text" name="reason" size="20" maxlength="100">' +
' <input type="submit" name="report" value="'+_('Report')+'">' +
' <input type="submit" name="report" value="' + _('Report') + '">' +
'</div>' +
'</form>');
post_form
@ -59,26 +57,27 @@ $(document).ready(function(){
post_form.find('input[type="password"]').val(localStorage.password);
if(thread) {
if (thread) {
post_form.prependTo($(this).parent().parent().find('div.body'));
} else {
post_form.appendTo($(this).parent().parent());
//post_form.insertBefore($(this));
}
$(window).trigger('quick-post-controls', post_form);
} else {
var elm = $(this).parent().parent().find('form');
let elm = $(this).parent().parent().find('form');
if(elm.attr('class') == 'post-actions')
if (elm.attr('class') == 'post-actions') {
elm.remove();
}
}
};
var init_qpc = function() {
let init_qpc = function() {
$(this).change(open_form);
if(this.checked)
if (this.checked) {
$(this).trigger('change');
}
};
$('div.post input[type=checkbox].delete').each(init_qpc);
@ -87,4 +86,3 @@ $(document).ready(function(){
$(post).find('input[type=checkbox].delete').each(init_qpc);
});
});

View File

@ -8,9 +8,8 @@
*
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* // $config['additional_javascript'][] = 'js/post-hover'; (optional; must come first)
* // $config['additional_javascript'][] = 'js/post-hover.js'; (optional; must come first)
* $config['additional_javascript'][] = 'js/show-backlinks.js';
*
*/
onReady(function() {
@ -18,34 +17,33 @@ onReady(function() {
let reply_id = $(this).attr('id').replace(/(^reply_)|(^op_)/, '');
$(this).find('div.body a:not([rel="nofollow"])').each(function() {
let id, post, $mentioned;
if (id = $(this).text().match(/^>>(\d+)$/)) {
let id = $(this).text().match(/^>>(\d+)$/);
if (id) {
id = id[1];
} else {
return;
}
$post = $('#reply_' + id);
if ($post.length == 0){
$post = $('#op_' + id);
if ($post.length == 0) {
let post = $('#reply_' + id);
if (post.length == 0){
post = $('#op_' + id);
if (post.length == 0) {
return;
}
}
$mentioned = $post.find('p.intro span.mentioned');
if($mentioned.length == 0) {
$mentioned = $('<span class="mentioned unimportant"></span>').appendTo($post.find('p.intro'));
let mentioned = post.find('p.intro span.mentioned');
if(mentioned.length == 0) {
mentioned = $('<span class="mentioned unimportant"></span>').appendTo(post.find('p.intro'));
}
if ($mentioned.find('a.mentioned-' + reply_id).length != 0) {
if (mentioned.find('a.mentioned-' + reply_id).length != 0) {
return;
}
let link = $('<a class="mentioned-' + reply_id + '" onclick="highlightReply(\'' + reply_id + '\');" href="#' + reply_id + '">&gt;&gt;' +
reply_id + '</a>');
link.appendTo($mentioned)
link.appendTo(mentioned)
if (window.init_hover) {
link.each(init_hover);
@ -54,13 +52,12 @@ onReady(function() {
};
$('div.post.reply').each(showBackLinks);
$('div.post.op').each(showBackLinks);
$(document).on('new_post', function(e, post) {
if ($(post).hasClass("op")) {
$(post).find('div.post.reply').each(showBackLinks);
if ($(post).hasClass('reply')) {
showBackLinks.call(post);
} else {
$(post).parent().find('div.post.reply').each(showBackLinks);
$(post).find('div.post.reply').each(showBackLinks);
}
});
});

View File

@ -5,9 +5,9 @@
/* jshint globalstrict:true, quotmark:single */
/* jshint browser:true, jquery:true, devel:true, unused:true, undef:true */
/* global active_page:false, board_name:false */
if(!localStorage.watchlist){
//If the watchlist is undefined in the localStorage,
//initialize it as an empty array.
if(!localStorage.watchlist) {
// If the watchlist is undefined in the localStorage,
// initialize it as an empty array.
localStorage.watchlist = '[]';
}
var watchlist = {};
@ -20,13 +20,17 @@ var watchlist = {};
*/
watchlist.render = function(reset) {
/* jshint eqnull:true */
if (reset == null) reset = false;
if (reset == null) {
reset = false;
}
/* jshint eqnull:false */
if (reset && $('#watchlist').length) $('#watchlist').remove();
var threads = [];
//Read the watchlist and create a new container for each thread.
if (reset && $('#watchlist').length) {
$('#watchlist').remove();
}
let threads = [];
// Read the watchlist and create a new container for each thread.
JSON.parse(localStorage.watchlist).forEach(function(e, i) {
//look at line 69, that's what (e) is here.
// Look at line 69, that's what (e) is here.
threads.push('<div class="watchlist-inner" id="watchlist-'+i+'">' +
'<span>/'+e[0]+'/ - ' +
'<a href="'+e[3]+'">'+e[1].replace("thread_", _("Thread #"))+'</a>' +
@ -35,20 +39,21 @@ watchlist.render = function(reset) {
'</div>');
});
if ($('#watchlist').length) {
//If the watchlist is already there, empty it and append the threads.
// If the watchlist is already there, empty it and append the threads.
$('#watchlist').children('.watchlist-inner').remove();
$('#watchlist').append(threads.join(''));
} else {
//If the watchlist has not yet been rendered, create it.
var menuStyle = getComputedStyle($('.boardlist')[0]);
// If the watchlist has not yet been rendered, create it.
let menuStyle = getComputedStyle($('.boardlist')[0]);
$((active_page == 'ukko') ? 'hr:first' : (active_page == 'catalog') ? 'body>span:first' : 'form[name="post"]').before(
$('<div id="watchlist">'+
'<div class="watchlist-controls">'+
'<span><a id="clearList">['+_('Clear List')+']</a></span>&nbsp'+
'<span><a id="clearGhosts">['+_('Clear Ghosts')+']</a></span>'+
'</div>'+
threads.join('')+
'</div>').css("background-color", menuStyle.backgroundColor).css("border", menuStyle.borderBottomWidth+" "+menuStyle.borderBottomStyle+" "+menuStyle.borderBottomColor));
'<div class="watchlist-controls">'+
'<span><a id="clearList">['+_('Clear List')+']</a></span>&nbsp'+
'<span><a id="clearGhosts">['+_('Clear Ghosts')+']</a></span>'+
'</div>'+
threads.join('')+
'</div>').css("background-color", menuStyle.backgroundColor).css("border", menuStyle.borderBottomWidth+" "+menuStyle.borderBottomStyle+" "+menuStyle.borderBottomColor)
);
}
return this;
};
@ -58,32 +63,31 @@ watchlist.render = function(reset) {
* @param {[Obj/Str]} sel [An unwrapped jquery selector.]
*/
watchlist.add = function(sel) {
var threadName, threadInfo;
let threadName;
let threadInfo;
var board_name = $(sel).parents('.thread').data('board');
let board_name = $(sel).parents('.thread').data('board');
if (active_page === 'thread') {
if ($('.subject').length){
//If a subject is given, use the first 20 characters as the thread name.
if ($('.subject').length) {
// If a subject is given, use the first 20 characters as the thread name.
threadName = $('.subject').text().substring(0,20);
} else { //Otherwise use the thread id.
threadName = $('.op').parent().attr('id');
}
//board name, thread name as defined above, current amount of posts, thread url
// Board name, thread name as defined above, current amount of posts, thread url
threadInfo = [board_name, threadName, $('.post').length, location.href];
} else if (active_page === 'index' || active_page === 'ukko') {
var postCount;
//Figure out the post count.
let postCount;
// Figure out the post count.
if ($(sel).parents('.op').children('.omitted').length) {
postCount = $(sel).parents('.op').children('.omitted').text().split(' ')[0];
} else {
postCount = $(sel).parents('.op').siblings('.post').length+1;
}
//Grab the reply link.;
var threadLink = $(sel).siblings('a:not(.watchThread)').last().attr('href');
//Figure out the thread name. If anon, use the thread id.
// Grab the reply link.;
let threadLink = $(sel).siblings('a:not(.watchThread)').last().attr('href');
// Figure out the thread name. If anon, use the thread id.
if ($(sel).parent().find('.subject').length) {
threadName = $(sel).parent().find('.subject').text().substring(0,20);
} else {
@ -91,7 +95,6 @@ watchlist.add = function(sel) {
}
threadInfo = [board_name, threadName, postCount, threadLink];
} else {
alert('Functionality not yet implemented for this type of page.');
return this;
@ -102,7 +105,7 @@ watchlist.add = function(sel) {
return this;
}
var _watchlist = JSON.parse(localStorage.watchlist); //Read the watchlist
let _watchlist = JSON.parse(localStorage.watchlist); //Read the watchlist
_watchlist.push(threadInfo); //Add the new watch item.
localStorage.watchlist = JSON.stringify(_watchlist); //Save the watchlist.
return this;
@ -113,7 +116,7 @@ watchlist.add = function(sel) {
* @param {[Int]} n [The index at which to remove.]
*/
watchlist.remove = function(n) {
var _watchlist = JSON.parse(localStorage.watchlist);
let _watchlist = JSON.parse(localStorage.watchlist);
_watchlist.splice(n, 1);
localStorage.watchlist = JSON.stringify(_watchlist);
return this;
@ -137,26 +140,26 @@ watchlist.exists = function(sel) {
error: function() {
watchlist.remove(parseInt($(sel).attr('id').split('-')[1])).render();
},
success : function(){
success : function() {
return;
}
});
};
$(document).ready(function(){
$(document).ready(function() {
if (!(active_page == 'thread' || active_page == 'index' || active_page == 'catalog' || active_page == 'ukko')) {
return;
}
//Append the watchlist toggle button.
$('.boardlist').append(' <span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>');
//Append a watch thread button after every OP post number.
$('.op>.intro>.post_no:odd').after('<a class="watchThread" href="#">['+_('Watch Thread')+']</a>');
// Append the watchlist toggle button.
$('.boardlist').append(' <span>[ <a class="watchlist-toggle" href="#">' + _('watchlist') + '</a> ]</span>');
// Append a watch thread button after every OP post number.
$('.op>.intro>.post_no:odd').after('<a class="watchThread" href="#">[' + _('Watch Thread') + ']</a>');
//Draw the watchlist, hidden.
// Draw the watchlist, hidden.
watchlist.render();
//Show or hide the watchlist.
// Show or hide the watchlist.
$('.watchlist-toggle').on('click', function(e) {
e.preventDefault();
//if ctrl+click, reset the watchlist.
@ -167,35 +170,33 @@ $(document).ready(function(){
$('#watchlist').css('display', 'none');
} else {
$('#watchlist').css('display', 'block');
} //Shit got really weird with hide/show. Went with css manip. Probably faster anyway.
} // Shit got really weird with hide/show. Went with css manip. Probably faster anyway.
});
//Trigger the watchlist add function.
//The selector is passed as an argument in case the page is not a thread.
// Trigger the watchlist add function.
// The selector is passed as an argument in case the page is not a thread.
$('.watchThread').on('click', function(e) {
e.preventDefault();
watchlist.add(this).render();
});
//The index is saved in .watchlist-inner so that it can be passed as the argument here.
//$('.watchlist-remove').on('click') won't work in case of re-renders and
//the page will need refreshing. This works around that.
// The index is saved in .watchlist-inner so that it can be passed as the argument here.
// $('.watchlist-remove').on('click') won't work in case of re-renders and
// the page will need refreshing. This works around that.
$(document).on('click', '.watchlist-remove', function() {
var item = parseInt($(this).parent().attr('id').split('-')[1]);
let item = parseInt($(this).parent().attr('id').split('-')[1]);
watchlist.remove(item).render();
});
//Empty the watchlist and redraw it.
$('#clearList').on('click', function(){
// Empty the watchlist and redraw it.
$('#clearList').on('click', function() {
watchlist.clear().render();
});
//Get rid of every watched item that no longer directs to an existing page.
// Get rid of every watched item that no longer directs to an existing page.
$('#clearGhosts').on('click', function() {
$('.watchlist-inner').each(function(){
$('.watchlist-inner').each(function() {
watchlist.exists(this);
});
});
});

View File

@ -929,9 +929,11 @@ pre {
display: inline-block;
user-select: none;
}
.poster_id:hover {
color: #800000!important;
}
.poster_id::before {
content: " ID: ";
}

View File

@ -12,7 +12,7 @@
var modRoot = "{{ config.root }}" + (inMod ? "mod.php?/" : "");
</script>
{% if not nojavascript %}
<script type="text/javascript" src="{{ config.url_javascript }}?v={{ config.resource_version }} data-resource-version="{{ config.resource_version }}"></script>
<script type="text/javascript" src="{{ config.url_javascript }}?v={{ config.resource_version }}"></script>
{% if not config.additional_javascript_compile %}
{% for javascript in config.additional_javascript %}<script type="text/javascript" src="{{ config.additional_javascript_url }}{{ javascript }}?v={{ config.resource_version }}"></script>{% endfor %}
{% endif %}

View File

@ -1,9 +1,9 @@
{% if post.embed %}
{{ post.embed }}
{% else %}
<div class="files">
{% for file in post.files %}
<div class="file{% if post.num_files > 1 %} multifile" style="width:{{ file.thumbwidth + 40 }}px"{% else %}"{% endif %}>
{% else %}
<div class="files">
{% for file in post.files %}
<div class="file{% if post.num_files > 1 %} multifile" style="width:{{ file.thumbwidth + 40 }}px"{% else %}"{% endif %}>
{% if file.file == 'deleted' %}
<img class="post-image deleted" src="{{ config.root }}{{ config.image_deleted }}" alt="" />
{% else %}

View File

@ -12,5 +12,5 @@
</a>
{% endif %}
{% if capcode %}
{{ capcode.cap }}
{{ capcode.cap }}
{% endif %}