1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-03 19:56:22 -07:00

Merge pull request #59 from gochan-org/deepsource-fix-48cf22f9

Replace `if-else` with ternary operator
This commit is contained in:
Eggbertx 2022-05-12 19:48:44 -07:00 committed by GitHub
commit effdb90323
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 12 deletions

View file

@ -104,15 +104,11 @@ export function banSelectedPost() {
* @param {StaffInfo} action * @param {StaffInfo} action
*/ */
function menuItem(action, isCategory = false) { function menuItem(action, isCategory = false) {
if(isCategory) { return isCategory ? $("<div/>").append($("<b/>").text(action)) : $("<div/>").append(
return $("<div/>").append($("<b/>").text(action));
} else {
return $("<div/>").append(
$("<a/>").prop({ $("<a/>").prop({
href: `${webroot}manage?action=${action.id}` href: `${webroot}manage?action=${action.id}`
}).text(action.title) }).text(action.title)
); );
}
} }
function getAction(id) { function getAction(id) {

View file

@ -31,8 +31,7 @@ export function getUploadPostID(upload, container) {
// if container, upload is div.upload-container // if container, upload is div.upload-container
// otherwise it's img or video // otherwise it's img or video
let jqu = container? $(upload) : $(upload).parent(); let jqu = container? $(upload) : $(upload).parent();
if(insideOP(jqu)) return jqu.siblings().eq(4).text(); return insideOP(jqu) ? jqu.siblings().eq(4).text() : jqu.siblings().eq(3).text();
else return jqu.siblings().eq(3).text();
} }
export function currentBoard() { export function currentBoard() {
@ -131,11 +130,7 @@ export function initPostPreviews($post = null) {
doClickPreview = getBooleanStorageVal("enablepostclick", true); doClickPreview = getBooleanStorageVal("enablepostclick", true);
doHoverPreview = getBooleanStorageVal("enableposthover", false); doHoverPreview = getBooleanStorageVal("enableposthover", false);
let $refs = null; let $refs = null;
if($post == null) { $refs = $post == null ? $("a.postref") : $post.find("a.postref");
$refs = $("a.postref");
} else {
$refs = $post.find("a.postref");
}
if(doClickPreview) { if(doClickPreview) {
$refs.on("click", expandPost); $refs.on("click", expandPost);