')) {
window.location.reload();
- }
- else {
+ } else {
displayComments(container, text);
}
});
- }
- else {
+ } else {
window.location.reload();
window.scrollTo(0, 0); // Error message is displayed at the top of the page (flash)
}
-
}
function loadParentPost(event) {
-
const clickedLink = event.target,
- // Find the comment containing the link that was clicked
- fullComment = clickedLink.closest('article.block'),
- // Look for a potential image and comment ID
- commentMatches = /(\w+)#comment_(\w+)$/.exec(clickedLink.getAttribute('href'));
+ // Find the comment containing the link that was clicked
+ fullComment = clickedLink.closest('article.block'),
+ // Look for a potential image and comment ID
+ commentMatches = /(\w+)#comment_(\w+)$/.exec(clickedLink.getAttribute('href'));
// If the clicked link is already active, just clear the parent comments
if (clickedLink.classList.contains('active_reply_link')) {
@@ -61,9 +54,8 @@ function loadParentPost(event) {
}
if (commentMatches) {
-
// If the regex matched, get the image and comment ID
- const [ , imageId, commentId ] = commentMatches;
+ const [, imageId, commentId] = commentMatches;
fetchHtml(`/images/${imageId}/comments/${commentId}`)
.then(handleError)
@@ -73,13 +65,10 @@ function loadParentPost(event) {
});
return true;
-
}
-
}
function insertParentPost(data, clickedLink, fullComment) {
-
// Add the 'subthread' class to the comment with the clicked link
fullComment.classList.add('subthread');
@@ -98,11 +87,9 @@ function insertParentPost(data, clickedLink, fullComment) {
// Filter images (if any) in the loaded comment
filterNode(fullComment.previousSibling);
-
}
function clearParentPost(clickedLink, fullComment) {
-
// Remove any previous siblings with the class fetched-comment
while (fullComment.previousSibling && fullComment.previousSibling.classList.contains('fetched-comment')) {
fullComment.previousSibling.parentNode.removeChild(fullComment.previousSibling);
@@ -117,11 +104,9 @@ function clearParentPost(clickedLink, fullComment) {
if (!fullComment.classList.contains('fetched-comment')) {
fullComment.classList.remove('subthread');
}
-
}
function displayComments(container, commentsHtml) {
-
container.innerHTML = commentsHtml;
// Execute timeago on comments
@@ -129,21 +114,21 @@ function displayComments(container, commentsHtml) {
// Filter images in the comments
filterNode(container);
-
}
function loadComments(event) {
-
const container = document.getElementById('comments'),
- hasHref = event.target && event.target.getAttribute('href'),
- hasHash = window.location.hash && window.location.hash.match(/#comment_([a-f0-9]+)/),
- getURL = hasHref || (hasHash ? `${container.dataset.currentUrl}?comment_id=${window.location.hash.substring(9, window.location.hash.length)}`
- : container.dataset.currentUrl);
+ hasHref = event.target && event.target.getAttribute('href'),
+ hasHash = window.location.hash && window.location.hash.match(/#comment_([a-f0-9]+)/),
+ getURL =
+ hasHref ||
+ (hasHash
+ ? `${container.dataset.currentUrl}?comment_id=${window.location.hash.substring(9, window.location.hash.length)}`
+ : container.dataset.currentUrl);
fetchHtml(getURL)
.then(handleError)
.then(data => {
-
displayComments(container, data);
// Make sure the :target CSS selector applies to the inserted content
@@ -155,21 +140,19 @@ function loadComments(event) {
});
return true;
-
}
function setupComments() {
- const comments = document.getElementById('comments'),
- hasHash = window.location.hash && window.location.hash.match(/^#comment_([a-f0-9]+)$/),
- targetOnPage = hasHash ? Boolean($(window.location.hash)) : true;
+ const comments = document.getElementById('comments'),
+ hasHash = window.location.hash && window.location.hash.match(/^#comment_([a-f0-9]+)$/),
+ targetOnPage = hasHash ? Boolean($(window.location.hash)) : true;
// Load comments over AJAX if we are on a page with element #comments
if (comments) {
if (!comments.dataset.loaded || !targetOnPage) {
// There is no event associated with the initial load, so use false
loadComments(false);
- }
- else {
+ } else {
filterNode(comments);
}
}
@@ -182,7 +165,8 @@ function setupComments() {
};
document.addEventListener('click', event => {
- if (event.button === 0) { // Left-click only
+ if (event.button === 0) {
+ // Left-click only
for (const target in targets) {
if (event.target && event.target.closest(target)) {
targets[target](event) && event.preventDefault();
diff --git a/assets/js/duplicate_reports.ts b/assets/js/duplicate_reports.ts
index 55cdfeb1..623aaf8b 100644
--- a/assets/js/duplicate_reports.ts
+++ b/assets/js/duplicate_reports.ts
@@ -15,7 +15,7 @@ export function setupDupeReports() {
}
function setupSwipe(swipe: SVGSVGElement) {
- const [ clip, divider ] = $$
('#clip rect, #divider', swipe);
+ const [clip, divider] = $$('#clip rect, #divider', swipe);
const { width } = swipe.viewBox.baseVal;
function moveDivider({ clientX }: MouseEvent) {
diff --git a/assets/js/fp.ts b/assets/js/fp.ts
index 65f0c583..8302029d 100644
--- a/assets/js/fp.ts
+++ b/assets/js/fp.ts
@@ -11,19 +11,19 @@ const storageKey = 'cached_ses_value';
declare global {
interface Keyboard {
- getLayoutMap: () => Promise