post-hover.js: use camelCase

This commit is contained in:
Zankaria 2024-09-04 11:31:14 +02:00
parent 988d454ee1
commit a20266f222

View file

@ -34,7 +34,7 @@ if ((active_page === 'thread' || active_page === 'index' || active_page === 'ukk
}
let dont_fetch_again = [];
init_hover = function() {
let initHover = function() {
let link = $(this);
let id;
@ -52,26 +52,26 @@ if ((active_page === 'thread' || active_page === 'index' || active_page === 'ukk
while (board.data('board') === undefined) {
board = board.parent();
}
let threadid;
let threadId;
if (link.is('[data-thread]')) {
threadid = 0;
threadId = 0;
} else {
threadid = board.attr('id').replace("thread_", "");
threadId = board.attr('id').replace("thread_", "");
}
board = board.data('board');
let parentboard = board;
let parentBoard = board;
if (link.is('[data-thread]')) {
parentboard = $('form[name="post"] input[name="board"]').val();
parentBoard = $('form[name="post"] input[name="board"]').val();
} else if (matches[1] !== undefined) {
board = matches[1];
}
let post = false;
let hovering = false;
let hovered_at;
let hoveredAt;
let updatePreviewPosition = function(pageX, pageY, hoverPreview) {
let scrollTop = $(window).scrollTop();
@ -83,7 +83,7 @@ if ((active_page === 'thread' || active_page === 'index' || active_page === 'ukk
epy -= $(window).scrollTop();
}
let top = (epy ? epy : hovered_at['y']) - 10;
let top = (epy ? epy : hoveredAt['y']) - 10;
if (epy < scrollTop + 15) {
top = scrollTop;
@ -91,7 +91,7 @@ if ((active_page === 'thread' || active_page === 'index' || active_page === 'ukk
top = scrollTop + $(window).height() - hoverPreview.height() - 15;
}
let hovery = pageY ? pageY : hovered_at['y'];
let hovery = pageY ? pageY : hoveredAt['y'];
if ((hovery - top) > 20){
top = hovery;
}
@ -100,7 +100,7 @@ if ((active_page === 'thread' || active_page === 'index' || active_page === 'ukk
if (isScreenSmall) {
previewX = 0;
} else {
previewX = (pageX ? pageX : hovered_at['x']) + 1
previewX = (pageX ? pageX : hoveredAt['x']) + 1
}
hoverPreview.css('left', previewX).css('top', top);
@ -108,7 +108,7 @@ if ((active_page === 'thread' || active_page === 'index' || active_page === 'ukk
link.hover(function(e) {
hovering = true;
hovered_at = {'x': e.pageX, 'y': e.pageY};
hoveredAt = {'x': e.pageX, 'y': e.pageY};
let start_hover = function(link) {
if ($.contains(post[0], link[0])) {
@ -165,18 +165,18 @@ if ((active_page === 'thread' || active_page === 'index' || active_page === 'ukk
url: url,
context: document.body,
success: function(data) {
var mythreadid = $(data).find('div[id^="thread_"]').attr('id').replace("thread_", "");
let myThreadId = $(data).find('div[id^="thread_"]').attr('id').replace("thread_", "");
if (mythreadid == threadid && parentboard == board) {
if (myThreadId == threadId && parentBoard == board) {
$(data).find('div.post.reply').each(function() {
if ($('[data-board="' + board + '"] #' + $(this).attr('id')).length === 0) {
$('[data-board="' + board + '"]#thread_' + threadid + " .post.reply:first").before($(this).hide().addClass('hidden'));
$('[data-board="' + board + '"]#thread_' + threadId + " .post.reply:first").before($(this).hide().addClass('hidden'));
}
});
} else if ($('[data-board="' + board + '"]#thread_'+mythreadid).length > 0) {
} else if ($('[data-board="' + board + '"]#thread_' + myThreadId).length > 0) {
$(data).find('div.post.reply').each(function() {
if ($('[data-board="' + board + '"] #' + $(this).attr('id')).length === 0) {
$('[data-board="' + board + '"]#thread_' + mythreadid + " .post.reply:first").before($(this).hide().addClass('hidden'));
$('[data-board="' + board + '"]#thread_' + myThreadId + " .post.reply:first").before($(this).hide().addClass('hidden'));
}
});
} else {
@ -221,14 +221,14 @@ if ((active_page === 'thread' || active_page === 'index' || active_page === 'ukk
});
};
$('div.body a:not([rel="nofollow"])').each(init_hover);
$('div.body a:not([rel="nofollow"])').each(initHover);
// allow to work with auto-reload.js, etc.
$(document).on('new_post', function(e, post) {
$(post).find('div.body a:not([rel="nofollow"])').each(init_hover);
$(post).find('div.body a:not([rel="nofollow"])').each(initHover);
});
// Must be available to `show-backlinks.js` and likely others...
window.init_hover = init_hover;
window.init_hover = initHover;
});
}