Compare commits

..

75 Commits

Author SHA1 Message Date
towards-a-new-leftypol 419a57f2d9 add backlinks to OP 2024-12-30 20:14:27 -05:00
towards-a-new-leftypol 40d77692a2 Fix commit 1c13ec98ba
- Unintentionally disabled that piece of code instead of removing adding
  the additional br tag that made double spaces between posts.
- add the postcontainers instead of post.reply (which is inside this
  container) to preserve the arrows
2024-12-26 02:38:32 -05:00
towards-a-new-leftypol 9e944dc189 undo instance-config.php settings changes 2024-12-22 00:41:17 -05:00
towards-a-new-leftypol f78bf4c036 retab image.php (use vim, convert tabs to space) 2024-12-22 05:24:27 +00:00
towards-a-new-leftypol e9020ed17f Improve posting error handling
- if spamnoticer was contacted, add cleanup callback to error handler if
  something goes wrong during the rest of the process (like thumbnail
  creation for example)

- add another allowed warning (string) that gm may safely report back
  and don't call error if we see it.
2024-12-22 05:21:37 +00:00
towards-a-new-leftypol 9c1bed645e bunker_like: heading and subtitle font sizes 2024-12-01 13:07:59 +00:00
towards-a-new-leftypol 05fd69026c Up the font sizes for bunker_like a little bit 2024-12-01 12:42:43 +00:00
towards-a-new-leftypol 2cd594c2ce Fix textarea size in bunker_like theme 2024-11-29 04:25:13 -05:00
towards-a-new-leftypol f6557f4f67 bunker_like: submit button color 2024-11-27 19:23:26 -05:00
towards-a-new-leftypol e781ed5712 bunker_like: submit button color 2024-11-27 19:21:43 -05:00
towards-a-new-leftypol 952c5ad050 bunker-like css fix 2024-11-27 19:17:36 -05:00
towards-a-new-leftypol 4a2e25e5f9 fix bunker-like css tweaks 2024-11-27 19:15:51 -05:00
towards-a-new-leftypol 13ffe08443 bunker_like: padding adjust 2024-11-27 19:12:58 -05:00
towards-a-new-leftypol e27f7c3621 bunker-like: form tweaks 2024-11-27 18:55:49 -05:00
towards-a-new-leftypol 8dc190f8e1 bunkerlike form css tweaks (by 1px) 2024-11-27 18:31:17 -05:00
towards-a-new-leftypol ebb9f8a3ae retab 2024-11-27 18:29:32 -05:00
towards-a-new-leftypol bd4a5088be bunker_like css form field padding tweak 2024-11-27 18:16:54 -05:00
towards-a-new-leftypol d7e882dbde bunkerlike - fix form padding 2024-11-27 18:02:46 -05:00
towards-a-new-leftypol b0d2e73400 Bunker-like theme changes
- change post body font to 'serif'
- change border radius's to 2px (down from 5px, which was silly)
2024-11-27 14:19:39 -05:00
towards-a-new-leftypol 30d9305a2b Replace flag instead of creating a new one 2024-11-27 11:51:45 -05:00
towards-a-new-leftypol 183da23550 Add flags 2024-11-27 11:40:36 -05:00
towards-a-new-leftypol f8d359118e Add music board and a link to nukechan 2024-09-17 15:40:32 -04:00
towards-a-new-leftypol 1c13ec98ba expand.js: don't add weird spacing 2024-09-17 15:40:21 -04:00
towards-a-new-leftypol ff3e3e2358 Fix log.php 2024-08-25 17:24:53 -04:00
towards-a-new-leftypol a35dc59add Make headings bolder and brighter for better readability 2024-08-25 15:08:34 -04:00
towards-a-new-leftypol b14dac6681 Fix a rebuilding when moving (targetBoard -> originBoard) 2024-08-12 16:54:39 -04:00
towards-a-new-leftypol 0654d7f0ea 8 new banners 2024-08-08 01:26:02 -04:00
towards-a-new-leftypol 968eea515b anti-bot: do not flag missing hash values as spam 2024-07-19 15:40:25 -04:00
towards-a-new-leftypol 136caf9fa2 add banners 2024-07-19 15:21:46 -04:00
towards-a-new-leftypol 8613768192 add banners 2024-07-01 12:38:34 -04:00
towards-a-new-leftypol 1c4fad6cc7 Remove redundant leftypedia link 2024-06-18 18:12:32 -04:00
towards-a-new-leftypol 0eac624e7b Update booru and wiki links 2024-06-18 18:02:30 -04:00
towards-a-new-leftypol 0a6260070a Enable anti-bot, except for the case where the hash is missing from the db (most bots don't seem to be that smart) 2024-06-15 20:30:06 -04:00
towards-a-new-leftypol 0055b3cb25 Up the anti-bot hash expiration time to 120 days 2024-06-15 20:30:06 -04:00
towards-a-new-leftypol 027d74c5dc Autoformat (vim) anti-bot.php to use spaces instead of tabs and spaces 2024-06-11 18:50:24 -04:00
towards-a-new-leftypol 54020351c5 Anti-bot: print out failure cases and construction
- enable anti-bot spam protection setting but comment out it's rejection
- will monitor the output log to check for false-positives and just see
  what it's rejecting...
2024-06-11 18:49:16 -04:00
towards-a-new-leftypol cbdb07f53c Fix a bug with i2p captcha
- if captcha_tor_only is set to true, posting over i2p requires a
  captcha but the javascript code removes it. Add a check to see if
  we're on a .i2p domain in this case.
2024-06-07 15:09:16 -04:00
towards-a-new-leftypol dadb7b2318 Add missing import to auth.php 2024-06-07 15:09:06 -04:00
towards-a-new-leftypol b4dbeb9369 Remove maintenance message 2024-05-29 23:14:15 -04:00
towards-a-new-leftypol 47637b6c2f change message 2024-05-29 22:03:01 -04:00
towards-a-new-leftypol 2ca1b2d619 Add maintenance message 2024-05-29 15:04:13 -04:00
towards-a-new-leftypol 15044a0568 Rebuild origin board themes if moving a thread and not leaving a shadow 2024-05-25 16:29:16 -04:00
towards-a-new-leftypol 922a979f39 Don't forget to rebuild the themes on origin board when moving
- if you're moving a post to a different board it would only
  rebuildThemes of the target board
2024-05-21 16:21:15 -04:00
towards-a-new-leftypol 87c4f331a7 Captcha for TOR users only 2024-05-08 17:15:48 -04:00
towards-a-new-leftypol cb1b8d51d8 Fix captcha generator securimage.php to work with php 8
- basically use intval() everywhere to avoid implicit conversion from
  float
2024-05-07 10:55:59 -04:00
towards-a-new-leftypol 37b69175a8 Add 4 new banners 2024-05-06 16:23:54 -04:00
towards-a-new-leftypol c362d0d1da Revert "Add new banner"
This reverts commit c72b660c73.
2024-05-05 18:26:38 -04:00
towards-a-new-leftypol c72b660c73 Add new banner 2024-05-05 17:53:18 -04:00
towards-a-new-leftypol 9872ec908c Add opus to supported list of extensions 2024-05-02 17:06:30 -04:00
towards-a-new-leftypol 227574fa54 Fix banners (replace misspelt ones) 2024-04-29 17:00:33 -04:00
towards-a-new-leftypol b55f149f62 Add banners 2024-04-28 16:03:17 -04:00
towards-a-new-leftypol 9093676067 Fix flag list ordering in config 2024-04-09 03:41:21 -04:00
towards-a-new-leftypol 023f7d9880 Fix previous commit 2024-04-09 03:36:43 -04:00
towards-a-new-leftypol 1cd2a475c6 Add flag 2024-04-09 03:29:04 -04:00
towards-a-new-leftypol 501fc4a235 Add banners 2024-04-08 22:47:26 -04:00
towards-a-new-leftypol 24c6637b3d API - threads.json last_modified is now really the timestamp of the last post, put bump time in a new field 'bump' 2024-03-31 21:19:12 +00:00
towards-a-new-leftypol f45247a278 Fix top bar on windows/firefox which caused the page to scroll horizontally. (jungle theme) 2024-03-31 03:29:06 +00:00
towards-a-new-leftypol 9f00e4948e homepage sidebar: remove padding 2024-03-18 23:43:19 -04:00
towards-a-new-leftypol 741dedacc3 get rid of gap parameter in css layout 2024-03-18 23:39:14 -04:00
towards-a-new-leftypol 2475b381e1 Rename sidebar heading to Boards for the boards list 2024-03-17 17:39:59 -04:00
towards-a-new-leftypol 2d53302e33 homepage sizing fixes 2024-03-17 17:35:25 -04:00
towards-a-new-leftypol 98b038bdb8 Further homepage changes 2024-03-17 17:11:17 -04:00
towards-a-new-leftypol 08afcdb42c Homepage: remove sidebar border, make sidebar wider (300px instead of
200px)
2024-03-17 16:54:27 -04:00
towards-a-new-leftypol 3b88f9eba3 Merge branch 'deploy_spamnoticer' into icecat_fix 2024-03-15 18:34:21 -04:00
towards-a-new-leftypol 862d38c9b3 Merge branch 'deploy_spamnoticer' into icecat_fix 2024-03-15 16:58:28 -04:00
towards-a-new-leftypol fd8dd64b49 Merge branch 'deploy_spamnoticer' into icecat_fix 2024-03-14 17:31:24 -04:00
towards-a-new-leftypol da8afc8d13 Rate limit opening posts for specific ip (basically copy flood-time-any filter and add ip condition) 2024-03-14 17:10:38 -04:00
towards-a-new-leftypol 653aadf1af Merge branch 'deploy_spamnoticer' into icecat_fix 2024-03-01 00:30:27 -05:00
towards-a-new-leftypol 22254fcf6c Remove console.log implementation that renders to the page from utils (was there to debug mobile) 2024-02-29 22:57:07 +00:00
towards-a-new-leftypol cbe878c7d5 Finally fixed and tested 2024-02-29 22:57:05 +00:00
towards-a-new-leftypol d366f4cdf8 debugging and fixes. can't use Array.prototype.at 2024-02-29 22:56:20 +00:00
towards-a-new-leftypol 4ce3e0060f class.js seems to load now, idk if i've introduced any bugs though 2024-02-29 22:54:31 +00:00
towards-a-new-leftypol 314dd4d2c3 This works so far 2024-02-29 22:54:31 +00:00
towards-a-new-leftypol 19c090fe90 get some of classes.js building 2024-02-29 22:54:31 +00:00
towards-a-new-leftypol 5619b35643 WIP: slowly but surely 2024-02-29 22:54:31 +00:00
5 changed files with 338 additions and 282 deletions

View File

@ -4,7 +4,6 @@
*/ */
globalThis.LCNSite = class LCNSite { globalThis.LCNSite = class LCNSite {
static INSTANCE = null;
static "createAbortable" () { static "createAbortable" () {
const obj = { "abort": null, "controller": null, "signal": null } const obj = { "abort": null, "controller": null, "signal": null }
@ -32,54 +31,64 @@ globalThis.LCNSite = class LCNSite {
} }
return null return null
};
constructor () {
this._isModerator = document.body.classList.contains("is-moderator");
this._isThreadPage = document.body.classList.contains("active-thread");
this._isBoardPage = document.body.classList.contains("active-board");
this._isCatalogPage = document.body.classList.contains("active-catalog");
this._isModPage = location.pathname == "/mod.php";
this._isModRecentsPage = this._isModPage && (location.search == "?/recent" || location.search.startsWith("?/recent/"));
this._isModReportsPage = this._isModPage && (location.search == "?/reports" || location.search.startsWith("?/reports/"));
this._isModLogPage = this._isModPage && (location.search == "?/log" || location.search.startsWith("?/log/"));
this._unseen = 0;
this._pageTitle = document.title;
this._favicon = document.querySelector("head > link[rel=\"shortcut icon\"]");
this._generatedStyle = null;
} }
#isModerator = document.body.classList.contains("is-moderator"); "_doTitleUpdate" () {
#isThreadPage = document.body.classList.contains("active-thread"); document.title = (this._unseen > 0 ? `(${this._unseen}) ` : "") + this._pageTitle;
#isBoardPage = document.body.classList.contains("active-board"); };
#isCatalogPage = document.body.classList.contains("active-catalog");
#isModPage = location.pathname == "/mod.php"; "isModerator" () { return this._isModerator; }
#isModRecentsPage = this.#isModPage && (location.search == "?/recent" || location.search.startsWith("?/recent/")); "isThreadPage" () {
#isModReportsPage = this.#isModPage && (location.search == "?/reports" || location.search.startsWith("?/reports/")); return this._isThreadPage;
#isModLogPage = this.#isModPage && (location.search == "?/log" || location.search.startsWith("?/log/")); }
"isBoardPage" () { return this._isBoardPage; }
"isCatalogPage" () { return this._isCatalogPage; }
"isModerator" () { return this.#isModerator; } "isModPage" () { return this._isModPage; }
"isThreadPage" () { return this.#isThreadPage; } "isModRecentsPage" () { return this._isModRecentsPage; }
"isBoardPage" () { return this.#isBoardPage; } "isModReportsPage" () { return this._isModReportsPage; }
"isCatalogPage" () { return this.#isCatalogPage; } "isModLogPage" () { return this._isModLogPage; }
"isModPage" () { return this.#isModPage; } "getUnseen" () { return this._unseen; }
"isModRecentsPage" () { return this.#isModRecentsPage; } "clearUnseen" () { if (this._unseen != 0) { this.setUnseen(0); } }
"isModReportsPage" () { return this.#isModReportsPage; }
"isModLogPage" () { return this.#isModLogPage; }
#unseen = 0;
"getUnseen" () { return this.#unseen; }
"clearUnseen" () { if (this.#unseen != 0) { this.setUnseen(0); } }
"setUnseen" (int) { "setUnseen" (int) {
const bool = !!int const bool = !!int
if (bool != !!this.#unseen) { if (bool != !!this._unseen) {
this.setFaviconType(bool ? "reply" : null) this.setFaviconType(bool ? "reply" : null)
} }
this.#unseen = int this._unseen = int
this.#doTitleUpdate() this._doTitleUpdate()
} }
#pageTitle = document.title; "getTitle" () { return this._pageTitle; }
"getTitle" () { return this.#pageTitle; } "setTitle" (title) { this._pageTitle = title; this._doTitleUpdate(); }
"setTitle" (title) { this.#pageTitle = title; this.#doTitleUpdate(); }
#doTitleUpdate () { document.title = (this.#unseen > 0 ? `(${this.#unseen}) ` : "") + this.#pageTitle; }
#favicon = document.querySelector("head > link[rel=\"shortcut icon\"]");
"setFaviconType" (type=null) { "setFaviconType" (type=null) {
if (this.#favicon == null) { if (this._favicon == null) {
this.#favicon = document.createElement("link") this._favicon = document.createElement("link")
this.#favicon.rel = "shortcut icon" this._favicon.rel = "shortcut icon"
document.head.appendChild(this.#favicon) document.head.appendChild(this._favicon)
} }
this.#favicon.href = `/favicon${type ? "-" + type : ""}.ico` this._favicon.href = `/favicon${type ? "-" + type : ""}.ico`
} }
"getFloaterLContainer" () { return document.getElementById("bar-bottom-l"); } "getFloaterLContainer" () { return document.getElementById("bar-bottom-l"); }
@ -87,85 +96,93 @@ globalThis.LCNSite = class LCNSite {
"getThreadStatsLContainer" () { return document.getElementById("lcn-threadstats-l"); } "getThreadStatsLContainer" () { return document.getElementById("lcn-threadstats-l"); }
"getThreadStatsRContainer" () { return document.getElementById("lcn-threadstats-r"); } "getThreadStatsRContainer" () { return document.getElementById("lcn-threadstats-r"); }
#generatedStyle = null;
"writeCSSStyle" (origin, stylesheet) { "writeCSSStyle" (origin, stylesheet) {
if (this.#generatedStyle == null && (this.#generatedStyle = document.querySelector("head > style.generated-css")) == null) { if (this._generatedStyle == null && (this._generatedStyle = document.querySelector("head > style.generated-css")) == null) {
this.#generatedStyle = document.createElement("style") this._generatedStyle = document.createElement("style")
this.#generatedStyle.classList.add("generated-css") this._generatedStyle.classList.add("generated-css")
document.head.appendChild(this.#generatedStyle) document.head.appendChild(this._generatedStyle)
} }
this.#generatedStyle.textContent += `${this.#generatedStyle.textContent.length ? "\n\n" : ""}/*** Generated by ${origin} ***/\n${stylesheet}` this._generatedStyle.textContent += `${this._generatedStyle.textContent.length ? "\n\n" : ""}/*** Generated by ${origin} ***/\n${stylesheet}`
} }
} }
globalThis.LCNSite.INSTANCE = null;
globalThis.LCNPostInfo = class LCNPostInfo { globalThis.LCNPostInfo = class LCNPostInfo {
static nodeAttrib = "$LCNPostInfo"; constructor () {
static selector = ".post:not(.grid-li)"; this._boardId = null;
#boardId = null; this._threadId = null;
#threadId = null; this._postId = null;
#postId = null; this._name = null;
#name = null; this._email = null;
#email = null; this._capcode = null;
#capcode = null; this._flag = null;
#flag = null; this._ip = null;
#ip = null; this._subject = null;
#subject = null; this._createdAt = null;
#createdAt = null; this._parent = null;
this._isThread = false;
#parent = null; this._isReply = false;
#isThread = false; this._isLocked = false;
#isReply = false; this._isSticky = false;
#isLocked = false;
#isSticky = false;
static "assign" (post) { return post[this.nodeAttrib] ?? (post[this.nodeAttrib] = this.from(post)); }
static "from" (post) {
assert.ok(post.classList.contains("post"), "Arty must be expected Element.")
const inst = new this()
const intro = post.querySelector(".intro")
const link = intro.querySelector(".post_no:not([id])").href.split("/").reverse()
inst.#postId = link[0].slice(link[0].indexOf("#q") + 2)
inst.#threadId = link[0].slice(0, link[0].indexOf("."))
inst.#boardId = link[2]
inst.#isThread = post.classList.contains("op")
inst.#isReply = !inst.#isThread
inst.#subject = intro.querySelector(".subject")?.innerText ?? null
inst.#name = intro.querySelector(".name")?.innerText ?? null
inst.#email = intro.querySelector(".email")?.href.slice(7) ?? null
inst.#flag = intro.querySelector(".flag")?.src.split("/").reverse()[0].slice(0, -4) ?? null
inst.#capcode = intro.querySelector(".capcode")?.innerText ?? null
inst.#ip = intro.querySelector(".ip-link")?.innerText ?? null
inst.#createdAt = new Date(intro.querySelector("time[datetime]").dateTime ?? NaN)
inst.#isSticky = !!intro.querySelector("i.fa-thumb-tack")
inst.#isLocked = !!intro.querySelector("i.fa-lock")
return inst
} }
"getParent" () { return this.#parent; }
"__setParent" (inst) { return this.#parent = inst; }
"getBoardId" () { return this.#boardId; } static "assign" (post) {
"getThreadId" () { return this.#threadId; } if (post[this.nodeAttrib] == null) {
"getPostId" () { return this.#postId; } return post[this.nodeAttrib] = this.from(post);
} else {
return post[this.nodeAttrib];
}
}
static "from" (post) {
assert.ok(post.classList.contains("post"), "Arty must be expected Element.");
const inst = new this();
const intro = post.querySelector(".intro");
const link = intro.querySelector(".post_no:not([id])").href.split("/").reverse();
inst._postId = link[0].slice(link[0].indexOf("#q") + 2);
inst._threadId = link[0].slice(0, link[0].indexOf("."));
inst._boardId = link[2];
inst._isThread = post.classList.contains("op");
inst._isReply = !inst._isThread;
inst._subject = cont(intro.querySelector(".subject"), x => x.innerText);
inst._name = cont(intro.querySelector(".name"), x => x.innerText);
inst._email = cont(intro.querySelector(".email"), x => x.href.slice(7));
inst._flag = cont(intro.querySelector(".flag"), x => x.src.split("/").reverse()[0].slice(0, -4));
inst._capcode = cont(intro.querySelector(".capcode"), x => x.innerText);
inst._ip = cont(intro.querySelector(".ip-link"), x => x.innerText);
inst._createdAt = new Date(intro.querySelector("time[datetime]").dateTime || NaN);
inst._isSticky = !!intro.querySelector("i.fa-thumb-tack");
inst._isLocked = !!intro.querySelector("i.fa-lock");
return inst;
}
"getParent" () { return this._parent; }
"__setParent" (inst) { return this._parent = inst; }
"getBoardId" () { return this._boardId; }
"getThreadId" () { return this._threadId; }
"getPostId" () { return this._postId; }
"getHref" () { return `/${this.boardId}/res/${this.threadId}.html#q${this.postId}`; } "getHref" () { return `/${this.boardId}/res/${this.threadId}.html#q${this.postId}`; }
"getName" () { return this.#name; } "getName" () { return this._name; }
"getEmail" () { return this.#email; } "getEmail" () { return this._email; }
"getIP" () { return this.#ip; } "getIP" () { return this._ip; }
"getCapcode" () { return this.#capcode; } "getCapcode" () { return this._capcode; }
"getSubject" () { return this.#subject; } "getSubject" () { return this._subject; }
"getCreatedAt" () { return this.#createdAt; } "getCreatedAt" () { return this._createdAt; }
"isSticky" () { return this.#isSticky; } "isSticky" () { return this._isSticky; }
"isLocked" () { return this.#isLocked; } "isLocked" () { return this._isLocked; }
"isThread" () { return this.#isThread; } "isThread" () { return this._isThread; }
"isReply" () { return this.#isReply; } "isReply" () { return this._isReply; }
"is" (info) { "is" (info) {
assert.ok(info, "Must be LCNPost.") assert.ok(info, "Must be LCNPost.")
@ -174,45 +191,48 @@ globalThis.LCNPostInfo = class LCNPostInfo {
} }
LCNPostInfo.nodeAttrib = "$LCNPostInfo";
LCNPostInfo.selector = ".post:not(.grid-li)";
globalThis.LCNPost = class LCNPost { globalThis.LCNPost = class LCNPost {
static nodeAttrib = "$LCNPost"; static "assign" (post) {
static selector = ".post:not(.grid-li)"; return post[this.nodeAttrib] || (post[this.nodeAttrib] = this.from(post));
#parent = null;
#post = null;
#info = null;
#ipLink = null;
#controls = null;
#customControlsSeperatorNode = null;
static "assign" (post) { return post[this.nodeAttrib] ?? (post[this.nodeAttrib] = this.from(post)); }
static "from" (post) { return new this(post); }
"constructor" (post) {
assert.ok(post.classList.contains("post"), "Arty must be expected Element.")
const intro = post.querySelector(".intro")
this.#post = post
this.#info = LCNPostInfo.assign(post)
this.#ipLink = intro.querySelector(".ip-link")
this.#controls = Array.prototype.at.apply(post.querySelectorAll(".controls"), [ -1 ])
assert.equal(this.#info.getParent(), null, "Info should not have parent.")
this.#info.__setParent(this)
} }
"jQuery" () { return $(this.#post); } static "from" (post) { return new this(post); }
"trigger" (event_id, data=null) { $(this.#post).trigger(event_id, [ data ]); }
"getElement" () { return this.#post; } constructor (post) {
"getInfo" () { return this.#info; } this._parent = null;
this._post = null;
this._info = null;
this._ipLink = null;
this._controls = null;
this._customControlsSeperatorNode = null;
"getIPLink" () { return this.#ipLink; } assert.ok(post.classList.contains("post"), "Arty must be expected Element.");
"setIP" (ip) { this.#ipLink.innerText = ip; } const intro = post.querySelector(".intro");
this._post = post;
this._info = LCNPostInfo.assign(post);
this._ipLink = intro.querySelector(".ip-link");
this._controls = Array.prototype.at.apply(post.querySelectorAll(".controls"), [ -1 ]);
//assert.equal(this._info.getParent(), null, "Info should not have parent.");
this._info.__setParent(this);
}
"getParent" () { return this.#parent; }
"__setParent" (inst) { return this.#parent = inst; }
static #NBSP = String.fromCharCode(160); "jQuery" () { return $(this._post); }
"trigger" (event_id, data=null) { $(this._post).trigger(event_id, [ data ]); }
"getElement" () { return this._post; }
"getInfo" () { return this._info; }
"getIPLink" () { return this._ipLink; }
"setIP" (ip) { this._ipLink.innerText = ip; }
"getParent" () { return this._parent; }
"__setParent" (inst) { return this._parent = inst; }
"addCustomControl" (obj) { "addCustomControl" (obj) {
if (LCNSite.INSTANCE.isModerator()) { if (LCNSite.INSTANCE.isModerator()) {
const link = document.createElement("a") const link = document.createElement("a")
@ -227,115 +247,122 @@ globalThis.LCNPost = class LCNPost {
link.addEventListener("click", e => { e.preventDefault(); obj.onClick(this); }) link.addEventListener("click", e => { e.preventDefault(); obj.onClick(this); })
} }
if (this.#customControlsSeperatorNode == null) { if (this._customControlsSeperatorNode == null) {
this.#controls.insertBefore(this.#customControlsSeperatorNode = new Text(`${this.constructor.#NBSP}-${this.constructor.#NBSP}`), this.#controls.firstElementChild) this._controls.insertBefore(this._customControlsSeperatorNode = new Text(`${this.constructor.NBSP}-${this.constructor.NBSP}`), this._controls.firstElementChild)
} else { } else {
this.#controls.insertBefore(new Text(this.constructor.#NBSP), this.#customControlsSeperatorNode) this._controls.insertBefore(new Text(this.constructor.NBSP), this._customControlsSeperatorNode)
} }
this.#controls.insertBefore(link, this.#customControlsSeperatorNode) this._controls.insertBefore(link, this._customControlsSeperatorNode)
} }
} }
} }
globalThis.LCNPost.nodeAttrib = "$LCNPost";
globalThis.LCNPost.selector = ".post:not(.grid-li)";
globalThis.LCNPost. NBSP = String.fromCharCode(160);
globalThis.LCNThread = class LCNThread { globalThis.LCNThread = class LCNThread {
static nodeAttrib = "$LCNThread"; static "assign" (thread) {
static selector = ".thread:not(.grid-li)"; return thread[this.nodeAttrib] || (thread[this.nodeAttrib] = this.from(thread));
#element = null;
#parent = null;
#op = null;
static "assign" (thread) { return thread[this.nodeAttrib] ?? (thread[this.nodeAttrib] = this.from(thread)); }
static "from" (thread) { return new this(thread); }
"constructor" (thread) {
assert.ok(thread.classList.contains("thread"), "Arty must be expected Element.")
this.#element = thread
this.#op = LCNPost.assign(this.#element.querySelector(".post.op"))
//assert.equal(this.#op.getParent(), null, "Op should not have parent.")
this.#op.__setParent(this)
} }
"getElement" () { return this.#element; } static "from" (thread) { return new this(thread); }
"getContent" () { return this.#op; }
"getPosts" () { return Array.prototype.map.apply(this.#element.querySelectorAll(".post"), [ el => LCNPost.assign(el) ]); }
"getReplies" () { return Array.prototype.map.apply(this.#element.querySelectorAll(".post:not(.op)"), [ el => LCNPost.assign(el) ]); }
"getParent" () { return this.#parent; } constructor (thread) {
"__setParent" (inst) { return this.#parent = inst; } this._element = null;
this._parent = null;
this._op = null;
assert.ok(thread.classList.contains("thread"), "Arty must be expected Element.")
this._element = thread
this._op = LCNPost.assign(this._element.querySelector(".post.op"))
assert.equal(this._op.getParent(), null, "Op should not have parent.")
this._op.__setParent(this)
}
"getElement" () { return this._element; }
"getContent" () { return this._op; }
"getPosts" () { return Array.prototype.map.apply(this._element.querySelectorAll(".post"), [ el => LCNPost.assign(el) ]); }
"getReplies" () { return Array.prototype.map.apply(this._element.querySelectorAll(".post:not(.op)"), [ el => LCNPost.assign(el) ]); }
"getParent" () { return this._parent; }
"__setParent" (inst) { return this._parent = inst; }
} }
globalThis.LCNThread.nodeAttrib = "$LCNThread";
globalThis.LCNThread.selector = ".thread:not(.grid-li)";
globalThis.LCNPostContainer = class LCNPostContainer { globalThis.LCNPostContainer = class LCNPostContainer {
static nodeAttrib = "$LCNPostContainer"; static "assign" (container) { return container[this.nodeAttrib] || (container[this.nodeAttrib] = this.from(container)); }
static selector = ".postcontainer";
#parent = null;
#element = null;
#content = null;
#postId = null;
#boardId = null;
static "assign" (container) { return container[this.nodeAttrib] ?? (container[this.nodeAttrib] = this.from(container)); }
static "from" (container) { return new this(container); } static "from" (container) { return new this(container); }
"constructor" (container) { constructor (container) {
this._parent = null;
this._element = null;
this._content = null;
this._postId = null;
this._boardId = null;
assert.ok(container.classList.contains("postcontainer"), "Arty must be expected Element.") assert.ok(container.classList.contains("postcontainer"), "Arty must be expected Element.")
const child = container.querySelector(".thread, .post") const child = container.querySelector(".thread, .post")
this.#element = container this._element = container
this.#content = child.classList.contains("thread") ? LCNThread.assign(child) : LCNPost.assign(child) this._content = child.classList.contains("thread") ? LCNThread.assign(child) : LCNPost.assign(child)
this.#boardId = container.dataset.board this._boardId = container.dataset.board
this.#postId = container.id.slice(2) this._postId = container.id.slice(2)
assert.equal(this.#content.getParent(), null, "Content should not have parent.") assert.equal(this._content.getParent(), null, "Content should not have parent.")
this.#content.__setParent(this) this._content.__setParent(this)
} }
"getElement" () { return this.#element; } "getElement" () { return this._element; }
"getContent" () { return this.#content; } "getContent" () { return this._content; }
"getBoardId" () { return this.#boardId; } "getBoardId" () { return this._boardId; }
"getPostId" () { return this.#postId; } "getPostId" () { return this._postId; }
"getParent" () { return this.#parent; } "getParent" () { return this._parent; }
"__setParent" (inst) { return this.#parent = inst; } "__setParent" (inst) { return this._parent = inst; }
} }
globalThis.LCNPostContainer.nodeAttrib = "$LCNPostContainer";
globalThis.LCNPostContainer.selector = ".postcontainer";
globalThis.LCNPostWrapper = class LCNPostWrapper { globalThis.LCNPostWrapper = class LCNPostWrapper {
static nodeAttrib = "$LCNPostWrapper"; static "assign" (wrapper) { return wrapper[this.nodeAttrib] || (wrapper[this.nodeAttrib] = this.from(wrapper)); }
static selector = ".post-wrapper";
#wrapper = null;
#eitaLink = null;
#eitaId = null;
#eitaHref = null
#content = null;
static "assign" (wrapper) { return wrapper[this.nodeAttrib] ?? (wrapper[this.nodeAttrib] = this.from(wrapper)); }
static "from" (wrapper) { return new this(wrapper); } static "from" (wrapper) { return new this(wrapper); }
"constructor" (wrapper) { constructor (wrapper) {
this._wrapper = null;
this._eitaLink = null;
this._eitaId = null;
this._eitaHref = null
this._content = null;
assert.ok(wrapper.classList.contains("post-wrapper"), "Arty must be expected Element.") assert.ok(wrapper.classList.contains("post-wrapper"), "Arty must be expected Element.")
this.#wrapper = wrapper this._wrapper = wrapper
this.#eitaLink = wrapper.querySelector(".eita-link") this._eitaLink = wrapper.querySelector(".eita-link")
this.#eitaId = this.#eitaLink.id this._eitaId = this._eitaLink.id
this.#eitaHref = this.#eitaLink.href this._eitaHref = this._eitaLink.href
void Array.prototype.find.apply(wrapper.children, [ void Array.prototype.find.apply(wrapper.children, [
el => { el => {
if (el.classList.contains("thread")) { if (el.classList.contains("thread")) {
return this.#content = LCNThread.assign(el) return this._content = LCNThread.assign(el)
} else if (el.classList.contains("postcontainer")) { } else if (el.classList.contains("postcontainer")) {
return this.#content = LCNPostContainer.assign(el) return this._content = LCNPostContainer.assign(el)
} }
} }
]) ])
assert.ok(this.#content, "Wrapper should contain content.") assert.ok(this._content, "Wrapper should contain content.")
assert.equal(this.#content.getParent(), null, "Content should not have parent.") assert.equal(this._content.getParent(), null, "Content should not have parent.")
this.#content.__setParent(this) this._content.__setParent(this)
} }
"getPost" () { "getPost" () {
@ -344,60 +371,62 @@ globalThis.LCNPostWrapper = class LCNPostWrapper {
return post return post
} }
"getElement" () { return this.#wrapper; } "getElement" () { return this._wrapper; }
"getContent" () { return this.#content; } "getContent" () { return this._content; }
"getEitaId" () { return this.#eitaId; } "getEitaId" () { return this._eitaId; }
"getEitaHref" () { return this.#eitaHref; } "getEitaHref" () { return this._eitaHref; }
"getEitaLink" () { return this.#eitaLink; } "getEitaLink" () { return this._eitaLink; }
} }
globalThis.LCNSetting = class LCNSetting { globalThis.LCNPostWrapper.nodeAttrib = "$LCNPostWrapper";
#id = null; globalThis.LCNPostWrapper.selector = ".post-wrapper";
#eventId = null;
#label = null;
#hidden = false;
#value = null;
#valueDefault = null;
globalThis.LCNSetting = class LCNSetting {
static "build" (id) { return new this(id); } static "build" (id) { return new this(id); }
"constructor" (id) { constructor (id) {
this.#id = id; this._id = null;
this.#eventId = `lcnsetting::${this.#id}` this._eventId = null;
this._label = null;
this._hidden = false;
this._value = null;
this._valueDefault = null;
this._id = id;
this._eventId = `lcnsetting::${this._id}`
} }
#getValue () { "_getValue" () {
const v = localStorage.getItem(this.#id) const v = localStorage.getItem(this._id)
if (v != null) { if (v != null) {
return this.__builtinValueImporter(v) return this.__builtinValueImporter(v)
} else { } else {
return this.#valueDefault return this._valueDefault
} }
} }
"isHidden" () { return this.#hidden; } "isHidden" () { return this._hidden; }
"setHidden" (v) { this.#hidden = v; return this; } "setHidden" (v) { this._hidden = v; return this; }
"getValue" () { return this._value || (this._value = this._getValue()); }
"getValue" () { return this.#value ?? (this.#value = this.#getValue()); }
"setValue" (v) { "setValue" (v) {
if (this.#value !== v) { if (this._value !== v) {
this.#value = v this._value = v
localStorage.setItem(this.#id, this.__builtinValueExporter(this.#value)) localStorage.setItem(this._id, this.__builtinValueExporter(this._value))
setTimeout(() => $(document).trigger(`${this.#eventId}::change`, [ v, this ]), 1) setTimeout(() => $(document).trigger(`${this._eventId}::change`, [ v, this ]), 1)
} }
} }
"getLabel" () { return this.#label; } "getLabel" () { return this._label; }
"setLabel" (label) { this.#label = label; return this; } "setLabel" (label) { this._label = label; return this; }
"getDefaultValue" () { return this.#valueDefault; } "getDefaultValue" () { return this._valueDefault; }
"setDefaultValue" (vd) { this.#valueDefault = vd; return this; } "setDefaultValue" (vd) { this._valueDefault = vd; return this; }
"onChange" (fn) { $(document).on(`${this.#eventId}::change`, (_,v,i) => fn(v, i)); } "onChange" (fn) { $(document).on(`${this._eventId}::change`, (_,v,i) => fn(v, i)); }
__setIdPrefix (prefix) { __setIdPrefix (prefix) {
this.#id = `${prefix}_${this.#id}` this._id = `${prefix}_${this._id}`
this.#eventId = `lcnsetting::${this.#id}` this._eventId = `lcnsetting::${this._id}`
} }
} }
@ -407,10 +436,10 @@ globalThis.LCNToggleSetting = class LCNToggleSetting extends LCNSetting {
__builtinDOMConstructor () { __builtinDOMConstructor () {
const div = document.createElement("div") const div = document.createElement("div")
const chk = document.createElement("input") const chk = document.createElement("input")
const txt = document.createElement("label") const lbl = document.createElement("label")
const id = `lcnts::${this.id}` const id = `lcnts::${this.id}`
txt.id = id lbl.htmlFor = id
txt.innerText = this.getLabel() lbl.innerText = this.getLabel()
chk.id = id chk.id = id
chk.type = "checkbox" chk.type = "checkbox"
chk.checked = this.getValue() chk.checked = this.getValue()
@ -421,23 +450,17 @@ globalThis.LCNToggleSetting = class LCNToggleSetting extends LCNSetting {
this.onChange(v => chk.checked = v) this.onChange(v => chk.checked = v)
div.appendChild(chk) div.appendChild(chk)
div.appendChild(txt) div.appendChild(lbl)
return div return div
} }
} }
globalThis.LCNSettingsSubcategory = class LCNSettingsSubcategory { globalThis.LCNSettingsSubcategory = class LCNSettingsSubcategory {
#tab_id = null;
#id = null;
#fieldset = null;
#legend = null;
#label = null;
static "for" (tab_id, id) { static "for" (tab_id, id) {
const domid = `lcnssc_${tab_id}_${id}` const domid = `lcnssc_${tab_id}_${id}`
const inst = document.getElementById(domid)?.$LCNSettingsSubcategory const inst = cont(document.getElementById(domid), x => x.$LCNSettingsSubcategory)
if (inst == null) { if (inst == null) {
const fieldset = document.createElement("fieldset") const fieldset = document.createElement("fieldset")
const legend = document.createElement("legend") const legend = document.createElement("legend")
@ -446,7 +469,7 @@ globalThis.LCNSettingsSubcategory = class LCNSettingsSubcategory {
// XXX: extend_tab only takes a string so this hacky workaround is used to let us use the regular dom api // XXX: extend_tab only takes a string so this hacky workaround is used to let us use the regular dom api
Options.extend_tab(tab_id, `<div id="__${domid}" hidden></div>`) Options.extend_tab(tab_id, `<div id="__${domid}" hidden></div>`)
const div = document.getElementById(`__${domid}`)?.parentElement const div = cont(document.getElementById(`__${domid}`), x => x.parentElement)
assert.ok(div) assert.ok(div)
div.replaceChildren(fieldset) div.replaceChildren(fieldset)
@ -456,23 +479,23 @@ globalThis.LCNSettingsSubcategory = class LCNSettingsSubcategory {
} }
} }
"constructor" (tab_id, id, fieldset) { constructor (tab_id, id, fieldset) {
this.#tab_id = tab_id this._tab_id = tab_id
this.#id = id this._id = id
this.#fieldset = fieldset this._fieldset = fieldset
this.#legend = this.#fieldset.querySelector("legend") this._legend = this._fieldset.querySelector("legend")
this.#fieldset.$LCNSettingsSubcategory = this this._fieldset.$LCNSettingsSubcategory = this
} }
"getLabel" () { return this.#label; } "getLabel" () { return this._label; }
"setLabel" (label) { this.#legend.innerText = this.#label = label; return this; } "setLabel" (label) { this._legend.innerText = this._label = label; return this; }
"addSetting" (setting) { "addSetting" (setting) {
assert.ok(setting instanceof LCNSetting) assert.ok(setting instanceof LCNSetting)
setting.__setIdPrefix(`lcnsetting_${this.#tab_id}_${this.#id}`) setting.__setIdPrefix(`lcnsetting_${this._tab_id}_${this._id}`)
if (!setting.isHidden() && setting.__builtinDOMConstructor != null) { if (!setting.isHidden() && setting.__builtinDOMConstructor != null) {
const div = setting.__builtinDOMConstructor() const div = setting.__builtinDOMConstructor()
div.classList.add("lcn-setting-entry") div.classList.add("lcn-setting-entry")
this.#fieldset.appendChild(div) this._fieldset.appendChild(div)
} }
return this return this
@ -490,7 +513,7 @@ $().ready(() => {
clazz.forEach = (fn, node=document) => clazz.allNodes(node).forEach(elem => fn(clazz.assign(elem))) clazz.forEach = (fn, node=document) => clazz.allNodes(node).forEach(elem => fn(clazz.assign(elem)))
clazz.filter = (fn, node=document) => clazz.all(node).filter(fn) clazz.filter = (fn, node=document) => clazz.all(node).filter(fn)
clazz.find = fn => clazz.all().find(fn) clazz.find = fn => clazz.all().find(fn)
clazz.first = (node=document) => clazz.assign(node.querySelector(clazz.selector)) clazz.first = (node=document) => { return clazz.assign(node.querySelector(clazz.selector)); }
clazz.last = (node=document) => clazz.assign(Array.prototype.at.apply(clazz.allNodes(node), [ -1 ])) clazz.last = (node=document) => clazz.assign(Array.prototype.at.apply(clazz.allNodes(node), [ -1 ]))
} }

View File

@ -4,7 +4,6 @@
*/ */
$().ready(() => { $().ready(() => {
const kIsEnabled = LCNToggleSetting.build("enabled") const kIsEnabled = LCNToggleSetting.build("enabled")
const kUpdateOnReplyEnabled = LCNToggleSetting.build("updateOnReplyEnabled") const kUpdateOnReplyEnabled = LCNToggleSetting.build("updateOnReplyEnabled")
//const kIsBellEnabled = LCNToggleSetting.build("bellEnabled") //const kIsBellEnabled = LCNToggleSetting.build("bellEnabled")
@ -35,7 +34,7 @@ $().ready(() => {
const abortable = LCNSite.createAbortable() const abortable = LCNSite.createAbortable()
const threadStatsItems = [] const threadStatsItems = []
const updateDOMStatus = () => { const updateDOMStatus = () => {
const text = threadState ?? (secondsCounter >= 0 ? `${secondsCounter}s` : "…") const text = threadState || (secondsCounter >= 0 ? `${secondsCounter}s` : "…")
threadUpdateStatus.innerText = text threadUpdateStatus.innerText = text
} }
@ -64,7 +63,7 @@ $().ready(() => {
} }
const findMissingReplies = (thread_op, thread_dom, thread_latest) => { const findMissingReplies = (thread_op, thread_dom, thread_latest) => {
const lastPostTs = (thread_dom.at(-1)?.getInfo() ?? thread_op.getInfo()).getCreatedAt().getTime() const lastPostTs = (cont(thread_dom.at(-1), x => x.getInfo()) || thread_op.getInfo()).getCreatedAt().getTime()
const missing = [] const missing = []
for (const pc of thread_latest.reverse()) { for (const pc of thread_latest.reverse()) {
@ -135,6 +134,7 @@ $().ready(() => {
if (threadState == null) { if (threadState == null) {
if (secondsCounter < 0) { if (secondsCounter < 0) {
const thread = LCNThread.first() const thread = LCNThread.first()
try { try {
await updateStatsFn(thread) await updateStatsFn(thread)
if (threadState == null && threadStats.last_modified > (thread.getPosts().at(-1).getInfo().getCreatedAt().getTime() / 1000)) { if (threadState == null && threadStats.last_modified > (thread.getPosts().at(-1).getInfo().getCreatedAt().getTime() / 1000)) {
@ -154,6 +154,7 @@ $().ready(() => {
onTickId = setTimeout(onTickFn, 1000) onTickId = setTimeout(onTickFn, 1000)
} }
} }
const refreshFn = () => { const refreshFn = () => {
@ -244,7 +245,7 @@ $().ready(() => {
$(document).trigger("thread_manual_refresh") $(document).trigger("thread_manual_refresh")
} else { } else {
floaterLinkBox?.remove() cont(floaterLinkBox, x => x.remove())
floaterLinkBox = null floaterLinkBox = null
statReplies = null statReplies = null
statFiles = null statFiles = null

View File

@ -3,39 +3,71 @@
* @author jonsmy * @author jonsmy
*/ */
function cont(value_to_test, fn) {
if (value_to_test != null) {
return fn(value_to_test);
} else {
return null;
}
}
const assert = { const assert = {
"equal": (actual, expected, message="No message set") => { "equal": (actual, expected, message="No message set") => {
if (actual !== expected) { if (actual !== expected) {
const err = new Error(`Assertion Failed. ${message}`) const err = new Error(`Assertion Failed. ${message}`);
err.data = { actual, expected} err.data = { actual, expected}
Error.captureStackTrace?.(err, assert.equal) //Error.captureStackTrace?.(err, assert.equal);
debugger debugger;
throw err throw err;
} }
}, },
"ok": (actual, message="No message set") => { "ok": (actual, message="No message set") => {
if (!actual) { if (!actual) {
const err = new Error(`Assertion Failed. ${message}`) const err = new Error(`Assertion Failed. ${message}`);
err.data = { actual } err.data = { actual }
Error.captureStackTrace?.(err, assert.ok) //Error.captureStackTrace?.(err, assert.ok);
debugger debugger;
throw err throw err;
} }
} }
} };
if (AbortSignal.any == null) {
AbortSignal.any = (signals) => {
const controller = new AbortController();
const abortFn = () => {
for (const signal of signals) {
signal.removeEventListener("abort", abortFn);
}
controller.abort();
}
AbortSignal.any ??= function (signals) {
const controller = new AbortController()
const abortFn = () => {
for (const signal of signals) { for (const signal of signals) {
signal.removeEventListener("abort", abortFn) signal.addEventListener("abort", abortFn);
} }
controller.abort()
}
for (const signal of signals) { return controller.signal;
signal.addEventListener("abort", abortFn)
} }
}
return controller.signal
// polyfill for replaceChildren
if( Node.prototype.replaceChildren === undefined) {
Node.prototype.replaceChildren = function(addNodes) {
while(this.lastChild) {
this.removeChild(this.lastChild);
}
if (addNodes !== undefined) {
this.append(addNodes);
}
}
}
if (Array.prototype.at === undefined) {
Array.prototype.at = function(index) {
if (index >= 0) {
return this[index];
} else {
return this[this.length + index];
}
};
} }

View File

@ -25,7 +25,7 @@ $(document).ready(function(){
else else
return; return;
$post = $('#reply_' + id); $post = $('#reply_' + id + ', #op_' + id);
if($post.length == 0) if($post.length == 0)
return; return;
@ -46,9 +46,9 @@ $(document).ready(function(){
}); });
}; };
$('div.post.reply').each(showBackLinks); $('div.post').each(showBackLinks);
$(document).on('new_post', function(e, post) { $(document).on('new_post', function(e, post) {
if ($(post).hasClass("reply")) { if ($(post).hasClass("reply")) {
showBackLinks.call(post); showBackLinks.call(post);
} }

View File

@ -152,7 +152,7 @@ $(document).ready(function(){
$('.boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>'); $('.boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>');
$('.compact-boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>'); $('.compact-boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>');
//Append a watch thread button after every OP. //Append a watch thread button after every OP.
$('.op>.intro').append('<a class="watchThread" href="#">['+_('Watch Thread')+']</a>'); $('.op>.intro>a:last').after('<a class="watchThread" href="#">['+_('Watch Thread')+']</a>');
//Draw the watchlist, hidden. //Draw the watchlist, hidden.
watchlist.render(); watchlist.render();