From 3a10067e6590699f2ee6e0dbbd24c66e40505833 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 8 Dec 2022 07:27:51 +0300 Subject: scripts: JSDoc cleanup --- src/main/assets/scripts.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/main/assets') diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js index 8d201438..95ca913d 100644 --- a/src/main/assets/scripts.js +++ b/src/main/assets/scripts.js @@ -260,8 +260,13 @@ function handleErrors(response) { return response; } +/** + * + * @param {number} mid message id + * @param {string} rid reply id + */ function showCommentForm(mid, rid) { - let reply = document.getElementById(rid); + let reply = /** @type { HTMLElement } */ (document.getElementById(rid)); let formTarget = reply.querySelector('div.msg-cont .msg-comment-target'); if (formTarget) { let formHtml = ` @@ -279,10 +284,10 @@ function showCommentForm(mid, rid) { formTarget.insertAdjacentHTML('afterend', formHtml); formTarget.remove(); - let form = reply.querySelector('form'); + let form = /** @type {HTMLFormElement} */ (reply.querySelector('form')); let submitButton = /** @type {HTMLInputElement} */ (form.querySelector('input[type="submit"]')); - let attachButton = form.querySelector('.msg-comment .attach-photo'); + let attachButton = /** @type {HTMLInputElement} */ (form.querySelector('.msg-comment .attach-photo')); attachButton.addEventListener('click', e => attachCommentPhoto(/** @type {HTMLDivElement} */(e.target))); let textarea = /** @type {HTMLTextAreaElement} */ (form.querySelector('.msg-comment textarea')); @@ -340,7 +345,7 @@ function attachInput() { /** * "Attach" button * - * @param {HTMLDivElement} div + * @param {HTMLDivElement} div element attach to */ function attachCommentPhoto(div) { let input = div.querySelector('input'); @@ -383,11 +388,11 @@ function openDialog(html, image) { ${html} `; - let body = document.querySelector('body'); + let body = /** @type {HTMLElement} */ (document.querySelector('body')); body.classList.add('dialog-opened'); body.insertAdjacentHTML('afterbegin', dialogHtml); if (image) { - let header = document.querySelector('#dialog_header'); + let header = /** @type {HTMLElement} */ (document.querySelector('#dialog_header')); header.classList.add('header_image'); } document.addEventListener('keydown', closeDialogListener); @@ -650,9 +655,10 @@ ready(() => { Array.from(document.querySelectorAll('.l .a-privacy')).forEach(function(e) { e.addEventListener('click', function(e) { + const article = /** @type {HTMLElement} */((e.target).closest('article')); setPrivacy( e.target, - /** @type {HTMLElement} */(e.target).closest('article').getAttribute('data-mid')); + article.getAttribute('data-mid')); e.preventDefault(); }); }); -- cgit v1.2.3