Reformated JS (#770)

This commit is contained in:
Roman Kelesidis 2023-06-05 14:48:40 +07:00 committed by GitHub
commit 76fa6eeabd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 36 deletions

View file

@ -107,9 +107,8 @@ if (DBG_USER) {
unset($_COOKIE['explain']); unset($_COOKIE['explain']);
} }
define('DELETED', -1);
// User Levels // User Levels
define('DELETED', -1);
define('USER', 0); define('USER', 0);
define('ADMIN', 1); define('ADMIN', 1);
define('MOD', 2); define('MOD', 2);

View file

@ -30,19 +30,12 @@ BBCode.prototype = {
this.textarea = textarea; this.textarea = textarea;
this.tags = {}; this.tags = {};
// Tag for quoting // Tag for quoting
this.addTag( this.addTag('_quoter', function () {
'_quoter', return '[quote="' + th.quoter + '"][qpost=' + th.qouted_pid + ']'
function () { }, '[/quote]\n', null, null, function () {
return '[quote="' + th.quoter + '"][qpost=' + th.qouted_pid + ']' th.collapseAfterInsert = true;
}, return th._prepareMultiline(th.quoterText)
'[/quote]\n', });
null,
null,
function () {
th.collapseAfterInsert = true;
return th._prepareMultiline(th.quoterText)
}
);
// Init events // Init events
var th = this; var th = this;
@ -73,8 +66,7 @@ BBCode.prototype = {
var sel = this.getSelection()[0]; var sel = this.getSelection()[0];
if (sel) { if (sel) {
this.insertAtCursor('[quote]' + sel + '[/quote]\n'); this.insertAtCursor('[quote]' + sel + '[/quote]\n');
} } else {
else {
alert('Вы не выбрали текст'); alert('Вы не выбрали текст');
} }
return false; return false;
@ -84,8 +76,7 @@ BBCode.prototype = {
emoticon: function (em) { emoticon: function (em) {
if (em) { if (em) {
this.insertAtCursor(' ' + em + ' '); this.insertAtCursor(' ' + em + ' ');
} } else {
else {
return false; return false;
} }
return false; return false;
@ -230,12 +221,9 @@ BBCode.prototype = {
// Hot keys // Hot keys
var form = this.textarea.form; var form = this.textarea.form;
var submitter = null; var submitter = null;
if (e.keyCode === this.VK_PAGE_UP && e.shiftKey && !e.ctrlKey && e.altKey) if (e.keyCode === this.VK_PAGE_UP && e.shiftKey && !e.ctrlKey && e.altKey) submitter = form.add_attachment_box;
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) if (e.keyCode === this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey) submitter = form.post;
submitter = form.preview;
if (e.keyCode === this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey)
submitter = form.post;
if (submitter) { if (submitter) {
submitter.click(); submitter.click();
return this._cancelEvent(e); return this._cancelEvent(e);
@ -272,8 +260,7 @@ BBCode.prototype = {
return false; return false;
}); });
} }
} } else {
else {
if (id && id.indexOf('_') !== 0) return alert("addTag('" + id + "'): no such element in the form"); 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? // Open tag is generated by callback?
var op = tag.open; 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; var cl = tag.close !== null ? tag.close : "/" + op;
// Use "[" if needed // Use "[" if needed
@ -317,8 +304,7 @@ if (window.HTMLElement && window.HTMLElement.prototype.__defineSetter__) {
} }
function AddSelectedText(BBOpen, BBClose) { function AddSelectedText(BBOpen, BBClose) {
if (document.post.message.caretPos) document.post.message.caretPos.text = BBOpen + document.post.message.caretPos.text + 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;
else document.post.message.value += BBOpen + BBClose;
document.post.message.focus() document.post.message.focus()
} }
@ -384,8 +370,7 @@ function initPostImages(context) {
imgFit(this, maxW); imgFit(this, maxW);
$v.empty().append(this); $v.empty().append(this);
}); });
} } else {
else {
$img.one('load', function () { $img.one('load', function () {
imgFit(this, maxW) imgFit(this, maxW)
}); });
@ -419,8 +404,7 @@ function initSpoilers(context) {
$('div.sp-head', $($sp_body.parents('td')[0])).filter(function () { $('div.sp-head', $($sp_body.parents('td')[0])).filter(function () {
return $(this).hasClass('unfolded') ? fold : !fold return $(this).hasClass('unfolded') ? fold : !fold
}).click(); }).click();
} } else {
else {
$(this).toggleClass('unfolded'); $(this).toggleClass('unfolded');
$sp_body.slideToggle('fast'); $sp_body.slideToggle('fast');
} }
@ -440,8 +424,7 @@ function fixPostImage($img) {
var src = $img[0].src; var src = $img[0].src;
if (src.match(banned_image_hosts)) { if (src.match(banned_image_hosts)) {
$img.wrap('<a href="' + this.src + '" target="_blank"></a>').attr({ $img.wrap('<a href="' + this.src + '" target="_blank"></a>').attr({
src: "" + bb_url + "styles/images/smiles/tr_oops.gif", src: "" + bb_url + "styles/images/smiles/tr_oops.gif", title: "" + bbl['scr_rules'] + ""
title: "" + bbl['scr_rules'] + ""
}); });
} }
return $img; return $img;