From 76fa6eeabdb5f82be6b18a64947452bc7be17b2d Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 5 Jun 2023 14:48:40 +0700 Subject: [PATCH] Reformated JS (#770) --- library/includes/init_bb.php | 3 +-- styles/js/bbcode.js | 51 ++++++++++++------------------------ 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index 08e61ad9e..6905ba11d 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -107,9 +107,8 @@ if (DBG_USER) { unset($_COOKIE['explain']); } -define('DELETED', -1); - // User Levels +define('DELETED', -1); define('USER', 0); define('ADMIN', 1); define('MOD', 2); diff --git a/styles/js/bbcode.js b/styles/js/bbcode.js index b020f938e..13e64bf6d 100644 --- a/styles/js/bbcode.js +++ b/styles/js/bbcode.js @@ -30,19 +30,12 @@ BBCode.prototype = { this.textarea = textarea; this.tags = {}; // Tag for quoting - this.addTag( - '_quoter', - function () { - return '[quote="' + th.quoter + '"][qpost=' + th.qouted_pid + ']' - }, - '[/quote]\n', - null, - null, - function () { - th.collapseAfterInsert = true; - return th._prepareMultiline(th.quoterText) - } - ); + this.addTag('_quoter', function () { + return '[quote="' + th.quoter + '"][qpost=' + th.qouted_pid + ']' + }, '[/quote]\n', null, null, function () { + th.collapseAfterInsert = true; + return th._prepareMultiline(th.quoterText) + }); // Init events var th = this; @@ -73,8 +66,7 @@ BBCode.prototype = { var sel = this.getSelection()[0]; if (sel) { this.insertAtCursor('[quote]' + sel + '[/quote]\n'); - } - else { + } else { alert('Вы не выбрали текст'); } return false; @@ -84,8 +76,7 @@ BBCode.prototype = { emoticon: function (em) { if (em) { this.insertAtCursor(' ' + em + ' '); - } - else { + } else { return false; } return false; @@ -230,12 +221,9 @@ BBCode.prototype = { // Hot keys var form = this.textarea.form; var submitter = null; - if (e.keyCode === this.VK_PAGE_UP && e.shiftKey && !e.ctrlKey && e.altKey) - submitter = form.add_attachment_box; - if (e.keyCode === this.VK_ENTER && !e.shiftKey && !e.ctrlKey && e.altKey) - submitter = form.preview; - if (e.keyCode === this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey) - submitter = form.post; + if (e.keyCode === this.VK_PAGE_UP && e.shiftKey && !e.ctrlKey && e.altKey) submitter = form.add_attachment_box; + if (e.keyCode === this.VK_ENTER && !e.shiftKey && !e.ctrlKey && e.altKey) submitter = form.preview; + if (e.keyCode === this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey) submitter = form.post; if (submitter) { submitter.click(); return this._cancelEvent(e); @@ -272,8 +260,7 @@ BBCode.prototype = { return false; }); } - } - else { + } else { if (id && id.indexOf('_') !== 0) return alert("addTag('" + id + "'): no such element in the form"); } }, @@ -286,7 +273,7 @@ BBCode.prototype = { // Open tag is generated by callback? var op = tag.open; - if (typeof(tag.open) === "function") op = tag.open(tag.elt); + if (typeof (tag.open) === "function") op = tag.open(tag.elt); var cl = tag.close !== null ? tag.close : "/" + op; // Use "[" if needed @@ -317,8 +304,7 @@ if (window.HTMLElement && window.HTMLElement.prototype.__defineSetter__) { } function AddSelectedText(BBOpen, BBClose) { - if (document.post.message.caretPos) document.post.message.caretPos.text = BBOpen + document.post.message.caretPos.text + BBClose; - else document.post.message.value += BBOpen + BBClose; + if (document.post.message.caretPos) document.post.message.caretPos.text = BBOpen + document.post.message.caretPos.text + BBClose; else document.post.message.value += BBOpen + BBClose; document.post.message.focus() } @@ -384,8 +370,7 @@ function initPostImages(context) { imgFit(this, maxW); $v.empty().append(this); }); - } - else { + } else { $img.one('load', function () { imgFit(this, maxW) }); @@ -419,8 +404,7 @@ function initSpoilers(context) { $('div.sp-head', $($sp_body.parents('td')[0])).filter(function () { return $(this).hasClass('unfolded') ? fold : !fold }).click(); - } - else { + } else { $(this).toggleClass('unfolded'); $sp_body.slideToggle('fast'); } @@ -440,8 +424,7 @@ function fixPostImage($img) { var src = $img[0].src; if (src.match(banned_image_hosts)) { $img.wrap('').attr({ - src: "" + bb_url + "styles/images/smiles/tr_oops.gif", - title: "" + bbl['scr_rules'] + "" + src: "" + bb_url + "styles/images/smiles/tr_oops.gif", title: "" + bbl['scr_rules'] + "" }); } return $img;