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

@@ -10,7 +10,7 @@ const oldPosition = request_headers.query.oldBlockNum;
const editing = request_headers.query.editing;
let page;
if (editing == "true"){
if (editing === "true"){
session_data.pagestore.editPhotoBlock(docName, request_headers.query.blockNum, request_headers.query.newBlockNum, null, null, request_headers.query.blockTitle, request_headers.query.photoBlockCaption);
headers = `300 OK
wtv-expire-all: wtv-author:/block-preview
@@ -22,14 +22,14 @@ Location: wtv-author:/show-blocks?docName=${docName}`
} else {
const page = session_data.pagestore.loadPage(docName);
const blockNum = request_headers.query.blockNum;
if (request_headers.query.scrapbookID != undefined) {
if (request_headers.query.scrapbookID !== undefined) {
const image = session_data.pagestore.getScrapbookImage(parseInt(request_headers.query.scrapbookID));
if (page.blocks[blockNum] != undefined)
if (page.blocks[blockNum] !== undefined)
session_data.pagestore.editPhotoBlock(docName, request_headers.query.blockNum, request_headers.query.blockNum, image, "scrapbook", null, null);
else
session_data.pagestore.createPhotoBlock(docName, image, "scrapbook");
} else {
if (page.blocks[blockNum] != undefined)
if (page.blocks[blockNum] !== undefined)
session_data.pagestore.editPhotoBlock(docName, request_headers.query.blockNum, request_headers.query.blockNum, request_headers.query.mediaPath, "clipart", null, null);
else
session_data.pagestore.createPhotoBlock(docName, request_headers.query.mediaPath, "clipart");

View File

@@ -3,7 +3,7 @@ const minisrv_service_file = true;
const pagestore_exists = session_data.pagestore.pagestoreExists();
const docName = request_headers.query.docName;
if (pagestore_exists != true)
if (pagestore_exists !== true)
{
session_data.pagestore.createPagestore();
headers = `300 OK
@@ -129,7 +129,7 @@ ${page.title}
</B></font>
<P>
<font size=2 color=AEBFD1>`
if (page.published == true)
if (page.published === true)
data += `published ${page.publishdate}`
else
data += "not published"
@@ -163,7 +163,7 @@ Change how your page is listed
<tr>
<td>
<img src=wtv-author:/ROMCache/pointer.gif align=absmiddle width=13 height=22 hspace=0> `
if (page.published != true)
if (page.published !== true)
data += `<a href=publish?docName=${docName}
><font effect=shadow><B>Publish page</B></font></a>
<BR><spacer type=block width=18 height=30 align=top>

View File

@@ -4,7 +4,7 @@ const pagestore_exists = session_data.pagestore.pagestoreExists();
const site = session_data.pagestore.getPublishDomain();
if (pagestore_exists != true)
if (pagestore_exists !== true)
session_data.pagestore.createPagestore();
const pagearray = session_data.pagestore.listPages();
@@ -163,7 +163,7 @@ data = `<HTML>
`
for (let i = 0; i < numofpages; i++) {
data += `<tr> <td rowspan=2 valign=top>`
if (i == 0)
if (i === 0)
data += `<img src="/ROMCache/left_mark.gif" width=5 height=9>
<td colspan=4><img src="/ROMCache/horiz_line_top.gif" width=347 height=9>
<td rowspan=2 valign=top><img src="/ROMCache/right_mark.gif" width=5 height=9>`
@@ -181,7 +181,7 @@ ${pagearray[i].description}
</I></font>
<P>
<font size=1 color=AEBFD1>`
if (pagearray[i].published == true)
if (pagearray[i].published === true)
data += `published ${pagearray[i].publishdate}`
else
data += "not published"

View File

@@ -203,7 +203,7 @@ Add text to your document
<TD>Text size:`
const textsize = pagedata.blocks[oldBlockNum].size
if (textsize == "-1")
if (textsize === "-1")
{
data += `<TD><INPUT type=radio value=-1 name=textBlockSize checked onClick=ReWrite()>
<font size=-1>Small</font></TD>
@@ -211,7 +211,7 @@ if (textsize == "-1")
Medium</TD>
<TD><INPUT type=radio value=+1 name=textBlockSize onClick=ReWrite()>
<font size=+1>Large</font></TD>`
} else if (textsize == "+1")
} else if (textsize === "+1")
{
data += `<TD><INPUT type=radio value=-1 name=textBlockSize onClick=ReWrite()>
<font size=-1>Small</font></TD>
@@ -233,7 +233,7 @@ data += `
<TD>Text style:`
const textstyle = pagedata.blocks[oldBlockNum].style
if (textstyle == "B")
if (textstyle === "B")
{
data += `
<TD><INPUT type=radio name=textBlockStyle onClick=ReWrite()>
@@ -243,7 +243,7 @@ Plain</TD>
<TD><INPUT type=radio value=I name=textBlockStyle onClick=ReWrite()>
<I>Italic</I></TD>
</TABLE>`
} else if (textstyle == "I") {
} else if (textstyle === "I") {
data += `
<TD><INPUT type=radio name=textBlockStyle onClick=ReWrite()>
Plain</TD>
@@ -461,11 +461,11 @@ if (showIt)
{ document.viewOptionEmbed.document.write('
<BODY text=AEBFD1 link=B8BDC7 vlink=B8BDC7>
<img src=wtv-author:/ROMCache/pointer.gif align=absmiddle width=13 height=22 hspace=0> `
if (blockType == "snapshot" || blockType == "scrapbook") {
if (blockType === "snapshot" || blockType === "scrapbook") {
data += `<a href=wtv-author:/get-photo?docName=${docName}&blockNum=${oldBlockNum}
><font effect=shadow><B>View this picture</B></font></a>
</BODY>`
} else if (blockType == "clipart")
} else if (blockType === "clipart")
data += `<a href=wtv-author:/${photo}
><font effect=shadow><B>View this picture</B></font></a>
</BODY>`
@@ -551,9 +551,9 @@ vspace=0
<table cellspacing=0 cellpadding=0>
<tr>
<td height=100 valign=middle rowspan=5>`
if (blockType == "snapshot") {
if (blockType === "snapshot") {
data += `<img src=wtv-author:/get-photo?docName=${docName}&blockNum=${oldBlockNum} width=131 height=100 border=1 onError="DisplayViewOption(false)">`
} else if (blockType == "clipart") {
} else if (blockType === "clipart") {
data += `<img src=wtv-author:/${thumbnail} width=64 height=64 border=1 onError="DisplayViewOption(false)">`
}
data += `
@@ -579,7 +579,7 @@ DisplayViewOption(true);
<tr>
<td colspan=2 absheight=28>
<input type=text name="blockTitle" id="blockTitle" value="`
if (pagedata.blocks[oldBlockNum].title != null)
if (pagedata.blocks[oldBlockNum].title !== null)
data += `${pagedata.blocks[oldBlockNum].title}`
data += `" selected width=100% text=CACA4A bgcolor=192133 font=proportional autoactivate>
<tr>
@@ -597,7 +597,7 @@ autohiragana
growable
width=100%
value="`
if (pagedata.blocks[oldBlockNum].caption != null)
if (pagedata.blocks[oldBlockNum].caption !== null)
data += `${pagedata.blocks[oldBlockNum].caption}`
data += `"
cols=45 rows=3></TEXTAREA>
@@ -837,14 +837,14 @@ Add a heading to your document
<TABLE>
<TR>
<TD>Text size:`
if (pagedata.blocks[oldBlockNum].size == "H3")
if (pagedata.blocks[oldBlockNum].size === "H3")
data += `<TD><INPUT type=radio value=H3 name=headingBlockSize checked onClick=ReWrite()>
<FONT size=-1>Small</FONT></TD>
<TD><INPUT type=radio value=H2 name=headingBlockSize onClick=ReWrite()>
Medium</TD>
<TD><INPUT type=radio value=H1 name=headingBlockSize onClick=ReWrite()>
<FONT size=+1>Large</FONT></TD>`
else if (pagedata.blocks[oldBlockNum].size == "H1")
else if (pagedata.blocks[oldBlockNum].size === "H1")
data += `<TD><INPUT type=radio value=H3 name=headingBlockSize onClick=ReWrite()>
<FONT size=-1>Small</FONT></TD>
<TD><INPUT type=radio value=H2 name=headingBlockSize onClick=ReWrite()>
@@ -862,7 +862,7 @@ data += `
<TR>
<TD>Add a divider line:</TD>
<TD colspan=3><INPUT type=checkbox name=headingBlockDividerBefore `
if (pagedata.blocks[oldBlockNum].dividerBefore == "on")
if (pagedata.blocks[oldBlockNum].dividerBefore === "on")
data += "checked"
data += `>
Before the heading</TD>
@@ -870,7 +870,7 @@ Before the heading</TD>
<TR>
<TD></TD>
<TD colspan=3><INPUT type=checkbox name=headingBlockDividerAfter `
if (pagedata.blocks[oldBlockNum].dividerAfter == "on")
if (pagedata.blocks[oldBlockNum].dividerAfter === "on")
data += "checked"
data += `>
After the heading</TD>
@@ -1204,7 +1204,7 @@ function SetListItems()
for (let i = 0; i < pagedata.blocks[oldBlockNum].items.length; i++) {
data += `ListElements[${i}] = new Object;`
if (pagedata.blocks[oldBlockNum].items[i].name == undefined)
if (typeof pagedata.blocks[oldBlockNum].items[i].name === 'undefined')
data += `ListElements[${i}].desc = "";`
else
data += `ListElements[${i}].desc = "${pagedata.blocks[oldBlockNum].items[i].name}";`

View File

@@ -7,7 +7,7 @@ headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`
if (request_headers.query.publishing == "true") {
if (request_headers.query.publishing === "true") {
data = `<HTML>
<HEAD>
<DISPLAY fontsize=medium>
@@ -110,7 +110,7 @@ cols=45 rows=4 MAXLENGTH=128></TEXTAREA>
</BODY>
</HTML>
`
} else if (request_headers.query.titleOnly == "true") {
} else if (request_headers.query.titleOnly === "true") {
data = `<HTML>
<HEAD>
<DISPLAY fontsize=medium>
@@ -194,7 +194,7 @@ as well as in the list of your pages.
<tr><td colspan=2>
<input type=hidden name="hideTitle" value="">
<input type=checkbox value=${!page.showtitle} `
if (page.showtitle == true)
if (page.showtitle === true)
data += "checked"
data += `
onChange="SetHideTitle(this.checked)">

View File

@@ -4,7 +4,7 @@ const docName = request_headers.query.docName;
const page = session_data.pagestore.loadPage(docName);
const site = session_data.pagestore.getPublishDomain();
if (request_headers.query.publishStage == "1") {
if (request_headers.query.publishStage === "1") {
headers = `200 OK
Content-Type: text/html`
@@ -77,7 +77,7 @@ Your public list of pages will be at:<BR>
<tr>
<td colspan=3 valign=top>
<input type=checkbox name="includeInPublicList" value=${page.inlist} `
if (page.inlist == true)
if (page.inlist === true)
data += "checked"
data += `>
Include in public list
@@ -116,24 +116,24 @@ Include in public list
</BODY>
</HTML>
`
} else if (request_headers.query.publishStage == "2") {
} else if (request_headers.query.publishStage === "2") {
let inlist;
if (request_headers.query.includeInPublicList != undefined) {
if (typeof request_headers.query.includeInPublicList !== 'undefined') {
inlist = true;
} else {
inlist = false;
}
const result = session_data.pagestore.publishPage(docName, inlist);
if (result == true) {
if (result === true) {
headers = `300 OK
wtv-expire-all: wtv-author:/documents
Location: wtv-author:/congrats?docName=${docName}`
} else {
headers = `400 ${result}`
}
} else if (request_headers.query.unpublish == "1") {
} else if (request_headers.query.unpublish === "1") {
const result = session_data.pagestore.unpublishPage(docName);
if (result == true) {
if (result === true) {
headers = `300 OK
wtv-expire-all: wtv-author:/documents
wtv-expire-all: wtv-author:/doc-info

View File

@@ -11,9 +11,9 @@ const editing = request_headers.query.editing;
const blockClass = request_headers.query.blockClass;
switch(blockClass) {
case "23":
if (editing == "true") {
if (editing === "true") {
const photo = request_headers.query.photoBlockPhoto;
if (request_headers.query.toSnapshot == "true")
if (request_headers.query.toSnapshot === "true")
session_data.pagestore.editPhotoBlock(docName, request_headers.query.blockNum, request_headers.query.newBlockNum, photo, "snapshot", request_headers.query.blockTitle, request_headers.query.photoBlockCaption);
else
session_data.pagestore.editPhotoBlock(docName, request_headers.query.blockNum, request_headers.query.newBlockNum, null, null, request_headers.query.blockTitle, request_headers.query.photoBlockCaption);
@@ -36,14 +36,14 @@ Location: ${request_headers.query.returnPageURL + "&numOfBlocks=" + page.blocks.
}
break;
case "21":
if (caption.length == 0) {
if (caption.length === 0) {
headers = "400 You must enter a caption. Please enter a caption and try again."
} else {
if (editing == "true") {
if (size.length == 0)
if (editing === "true") {
if (size.length === 0)
size = null;
if (style.length == 0)
if (style.length === 0)
style = null;
session_data.pagestore.editTextBlock(docName, title, caption, size, style, position, oldPosition);
headers = `300 OK
@@ -53,10 +53,10 @@ Location: ${request_headers.query.returnPageURL + "&numOfBlocks=" + page.blocks.
wtv-expire-all: wtv-author:/edit-block
Location: wtv-author:/show-blocks?docName=${docName}`
} else {
if (size.length == 0)
if (size.length === 0)
size = null;
if (style.length == 0)
if (style.length === 0)
style = null;
session_data.pagestore.createTextBlock(docName, title, caption, size, style, position);
headers = `300 OK
@@ -72,10 +72,10 @@ Location: ${request_headers.query.returnPageURL + "&numOfBlocks=" + page.blocks.
size = request_headers.query.headingBlockSize
const dividerBefore = request_headers.query.headingBlockDividerBefore
const dividerAfter = request_headers.query.headingBlockDividerAfter
if (header.length == 0) {
if (header.length === 0) {
headers = "400 You must enter a header. Please enter a header and try again."
} else {
if (editing == "true") {
if (editing === "true") {
session_data.pagestore.editHeaderBlock(docName, header, size, dividerBefore, dividerAfter, position, request_headers.query.blockNum);
headers = `300 OK
wtv-expire-all: wtv-author:/block-preview
@@ -94,7 +94,7 @@ Location: wtv-author:/show-blocks?docName=${docName}`
}
break;
case "24":
if (editing == "true") {
if (editing === "true") {
const listItems = request_headers.query.listItemText.filter(function(e){ return e.replace(/(\r\n|\n|\r)/gm,"")});
session_data.pagestore.editListBlock(docName, title, listItems, position, request_headers.query.blockNum);
headers = `300 OK
@@ -114,7 +114,7 @@ Location: wtv-author:/show-blocks?docName=${docName}`
}
break;
case "25":
if (editing == "true") {
if (editing === "true") {
const listItems = request_headers.query.listItemText;
const linkItems = request_headers.query.linkItemURL;
session_data.pagestore.editLinkBlock(docName, title, listItems, linkItems, position, request_headers.query.blockNum);
@@ -137,7 +137,7 @@ Location: wtv-author:/show-blocks?docName=${docName}`
break;
case "27":
if (editing == "true") {
if (editing === "true") {
session_data.pagestore.editBreakBlock(docName, position, request_headers.query.blockNum);
headers = `300 OK
wtv-expire-all: wtv-author:/block-preview

View File

@@ -3,7 +3,7 @@ const minisrv_service_file = true;
const docName = request_headers.query.docName;
const docTitle = request_headers.query.docTitle;
if (docTitle.length == 0) {
if (docTitle.length === 0) {
headers = "400 You must enter a title for your page. Please enter a title and try again."
} else {
const pagedata = session_data.pagestore.loadPage(docName);

View File

@@ -48,7 +48,7 @@ if (!request_headers.query.mediaData && !request_headers.query.mediaPath) {
function isValidImageType(contentType, url) {
// Check content-type header or file extension
if (contentType) {
return contentType === 'image/jpeg' || contentType == 'image/jpg' || contentType === 'image/gif';
return contentType === 'image/jpeg' || contentType === 'image/jpg' || contentType === 'image/gif';
}
return url.endsWith('.jpg') || url.endsWith('.jpeg') || url.endsWith('.gif');
}