more optimizations, remove WTVIRC for now, upgrade test.js

This commit is contained in:
zefie
2025-08-13 21:42:22 -04:00
parent 54bb975f1a
commit 22c7229e38
162 changed files with 1002 additions and 5539 deletions

View File

@@ -4,7 +4,7 @@ request_is_async = true;
let errpage = null;
const group = request_headers.query.group;
const attachment_id = parseInt(request_headers.query.attachment_id);
if ((!attachment_id && attachment_id != 0) || !group || !request_headers.query.article) {
if ((!attachment_id && attachment_id !== 0) || !group || !request_headers.query.article) {
errpage = wtvshared.doErrorPage(400, "Attachment ID required.");
sendToClient(socket, errpage[0], errpage[1]);
} else {
@@ -32,13 +32,13 @@ if ((!attachment_id && attachment_id != 0) || !group || !request_headers.query.a
wtvnews.selectGroup(group).then((response) => {
wtvnews.getArticle(article).then((response) => {
wtvnews.quitUsenet();
if (response.code == 220) {
if (response.code === 220) {
const message_data = wtvnews.parseAttachments(response);
if (message_data.attachments) {
if (attachment_id < message_data.attachments.length) {
const attachment = message_data.attachments[attachment_id];
const encoding = attachment.content_encoding.toLowerCase()
if (encoding == 'base64') {
if (encoding === 'base64') {
data = Buffer.from(attachment.data, encoding);
headers = "200 OK\n"
headers += "Content-Type: " + attachment.content_type + "\n";

View File

@@ -117,12 +117,12 @@ function printGroup(group) {
}
// evens
Object.keys(featuredGroups).forEach((k) => { if (k % 2 == 0) { data += printGroup(featuredGroups[k]); } });
Object.keys(featuredGroups).forEach((k) => { if (k % 2 === 0) { data += printGroup(featuredGroups[k]); } });
if (featuredGroups.length > 1) data += `<td WIDTH=20><td WIDTH=198 HEIGHT=220 VALIGN=top ALIGN=left>`;
// odds
Object.keys(featuredGroups).forEach((k) => { if (k % 2 != 0) data += printGroup(featuredGroups[k]); });
Object.keys(featuredGroups).forEach((k) => { if (k % 2 !== 0) data += printGroup(featuredGroups[k]); });
data += `

View File

@@ -28,9 +28,9 @@ async function throwError(e) {
function isToday (chkdate) {
const today = new Date()
return chkdate.getDate() == today.getDate() &&
chkdate.getMonth() == today.getMonth() &&
chkdate.getFullYear() == today.getFullYear()
return chkdate.getDate() === today.getDate() &&
chkdate.getMonth() === today.getMonth() &&
chkdate.getFullYear() === today.getFullYear()
}
async function WebTVListGroup(group) {
@@ -47,7 +47,7 @@ async function WebTVListGroup(group) {
limit_per_page = (page_end - (limit_per_page / (page + 1))) + limit_per_page;
}
wtvnews.listGroup(group, page, limit_per_page).then((response) => {
if (response.code == 211) {
if (response.code === 211) {
const NGCount = response.group.number;
const NGArticles = response.group.articleNumbers;
page_start = (limit_per_page * page) + 1;
@@ -193,11 +193,11 @@ Group: ${request_headers.query.group}
<td height=33 width=256 valign=bottom>
<font size=4>
`
if (NGCount == 0) {
if (NGCount === 0) {
data += `This group has no postings`;
} else {
data += NGCount + " posting";
if (NGCount != 1)
if (NGCount !== 1)
data += "s"
}
data += `
@@ -210,7 +210,7 @@ Group: ${request_headers.query.group}
<td width=180 valign=bottom align=right>
<table cellspacing=0 cellpadding=0>
<td rowspan=4 height=26 width=30>
${(page > 0) ? `<a href="wtv-news:/news?group=${group}&chunk=${page - 1}${(limit_per_page != page_limit_default) ? `&limit=${limit_per_page}` : ''}"><img src="wtv-news:/images/ListPrevious.gif"></a>` : `<img src="wtv-news:/images/ListPrevious_D.gif">`}
${(page > 0) ? `<a href="wtv-news:/news?group=${group}&chunk=${page - 1}${(limit_per_page !== page_limit_default) ? `&limit=${limit_per_page}` : ''}"><img src="wtv-news:/images/ListPrevious.gif"></a>` : `<img src="wtv-news:/images/ListPrevious_D.gif">`}
<td rowspan=4 height=26 width=11>
<img src="wtv-news:/images/ListLeftEdge.gif">
<td height=2 valign=top align=left bgcolor="2b2b2b">
@@ -218,7 +218,7 @@ ${(page > 0) ? `<a href="wtv-news:/news?group=${group}&chunk=${page - 1}${(limit
<td rowspan=4 height=26 width=11>
<img src="wtv-news:/images/ListRightEdge.gif">
<td rowspan=4 height=26 width=30>
${(page_end < NGCount) ? `<a href="wtv-news:/news?group=${group}&chunk=${page + 1}${(limit_per_page != page_limit_default) ? `&limit=${limit_per_page}` : ''}"><img src="wtv-news:/images/ListNext.gif"></a>` : `<img src="wtv-news:/images/ListNext_D.gif">`}
${(page_end < NGCount) ? `<a href="wtv-news:/news?group=${group}&chunk=${page + 1}${(limit_per_page !== page_limit_default) ? `&limit=${limit_per_page}` : ''}"><img src="wtv-news:/images/ListNext.gif"></a>` : `<img src="wtv-news:/images/ListNext_D.gif">`}
<td rowspan=4 width=5>
<tr>
<td height=2 valign=top align=left>
@@ -337,7 +337,7 @@ wtv-expire-all: wtv-news:/news?group=${group}&article=`;
if (attachments) {
if (Object.keys(attachments).length > 0) {
Object.keys(attachments).forEach((k) => {
if (attachments[k].filename == "wtv_signature.html" && attachments[k].content_type.match(/text\/html/)) {
if (attachments[k].filename === "wtv_signature.html" && attachments[k].content_type.match(/text\/html/)) {
signature = attachments[k].data;
signature_index = k;
return false;
@@ -350,7 +350,7 @@ wtv-expire-all: wtv-news:/news?group=${group}&article=`;
if (message_body.indexOf("<body")) {
const default_colors = session_data.mailstore.defaultColors;
message_colors = session_data.mailstore.getSignatureColors(message_body);
if ((message_colors == default_colors) && signature) message_colors = null;
if ((message_colors === default_colors) && signature) message_colors = null;
}
if (!message_colors && signature) message_colors = session_data.mailstore.getSignatureColors(signature);
@@ -591,7 +591,7 @@ ${strftime("%a, %b %e, %Y, %I:%M%P", new Date(Date.parse(response.article.header
<td valign=top>
From:
<td>`;
if (message.from_name != message.from_addr) {
if (message.from_name !== message.from_addr) {
data += `<a href="client:showalert?sound=none&message=Would%20you%20like%20to%20add%20%3Cblackface%3E${wtvshared.htmlEntitize(message.from_name)}%3C%2Fblackface%3E%20to%20your%20address%20list%3F&buttonlabel2=No&buttonaction2=client:donothing&buttonlabel1=Yes&buttonaction1=wtv-mail:/addressbook%3Faction%3Deditfromheader%26noresponse%3Dtrue%26nickname%3D${encodeURIComponent(encodeURIComponent(message.from_name))}%26address%3D${encodeURIComponent(encodeURIComponent(message.from_addr))}%26new_address%3Dtrue">${wtvshared.htmlEntitize(message.from_addr)} </a>`;
} else {
data += `${wtvshared.htmlEntitize(response.article.headers.FROM)}`;
@@ -630,7 +630,7 @@ From:
if (attachments) {
if (attachments[0]) {
if (attachments[0].filename == "message.html") {
if (attachments[0].filename === "message.html") {
body_data += wtvshared.sanitizeSignature(attachments[0].data);
delete attachments[0];
}
@@ -789,14 +789,14 @@ vspace=0>
<tr>
<td valign=center absheight=80>
<font size="+2" color="E7CE4A"><blackface><shadow>
${(response.length == 0) ? "No " : ""}Discussion groups found
${(response.length === 0) ? "No " : ""}Discussion groups found
</table>
<td abswidth=20>
<tr>
<td>
<td WIDTH=198 HEIGHT=200 VALIGN=top ALIGN=left>`;
if (response.length == 0) {
if (response.length === 0) {
data += `There are no discussion groups that match your request. Do you want to look for something else?`;
} else {
response.forEach((group) => {