more optimizations
This commit is contained in:
@@ -29,7 +29,7 @@ const WTVFlashrom = require(classPath + "/WTVFlashrom.js");
|
|||||||
const WTVIRC = require(classPath + "/WTVIRC.js");
|
const WTVIRC = require(classPath + "/WTVIRC.js");
|
||||||
const WTVFTP = require(classPath + "/WTVFTP.js");
|
const WTVFTP = require(classPath + "/WTVFTP.js");
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
const debug = require('debug')('minisrv_main');
|
const debug = require('debug')('app');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
|
||||||
let wtvirc = null;
|
let wtvirc = null;
|
||||||
@@ -1831,7 +1831,7 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
|
|||||||
if (!wtvshared.checkSSID(socket.ssid)) {
|
if (!wtvshared.checkSSID(socket.ssid)) {
|
||||||
if (!socket.ssid.startsWith("1SEGA") && !socket.ssid.startsWith("MSTVSIMU")) {
|
if (!socket.ssid.startsWith("1SEGA") && !socket.ssid.startsWith("MSTVSIMU")) {
|
||||||
// reject invalid SSIDs, but let Dreamcast and MSTV Sim through for now until we figure out their checksumming method.
|
// reject invalid SSIDs, but let Dreamcast and MSTV Sim through for now until we figure out their checksumming method.
|
||||||
const errpage = wtvshared.doErrorPage(400, "minisrv ran into a technical problem. Reason: Your SSID is not valid.");
|
const errpage = wtvshared.doErrorPage(400, `${minisrv_config.config.service_name} ran into a technical problem. Reason: Your SSID is not valid.`);
|
||||||
socket.close_me = true;
|
socket.close_me = true;
|
||||||
sendToClient(socket, errpage[0], errpage[1]);
|
sendToClient(socket, errpage[0], errpage[1]);
|
||||||
return;
|
return;
|
||||||
@@ -2091,7 +2091,7 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
|
|||||||
if (socket_sessions[socket.id].expecting_post_data) delete socket_sessions[socket.id].expecting_post_data;
|
if (socket_sessions[socket.id].expecting_post_data) delete socket_sessions[socket.id].expecting_post_data;
|
||||||
socket.setTimeout(minisrv_config.config.socket_timeout * 1000);
|
socket.setTimeout(minisrv_config.config.socket_timeout * 1000);
|
||||||
if (headers.length == 0) {
|
if (headers.length == 0) {
|
||||||
const errpage = wtvshared.doErrorPage(400, `${minisrv_config.config.service_name} ran into a technical problem, please try again.`);
|
const errpage = wtvshared.doErrorPage(400);
|
||||||
sendToClient(socket, errpage[0], errpage[1]);
|
sendToClient(socket, errpage[0], errpage[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ for(var loop = 0; loop < vCount; loop++) {
|
|||||||
<!-- draw Try It button if the info has been passed from the service -->
|
<!-- draw Try It button if the info has been passed from the service -->
|
||||||
appUrl = document.formInfo.tryItUrl.value;
|
appUrl = document.formInfo.tryItUrl.value;
|
||||||
if (appUrl != "" ) {
|
if (appUrl != "" ) {
|
||||||
if ( appUrl.substring(0,10) == "wtv-tricks" ) {
|
if ( appUrl.slice(0,10) == "wtv-tricks" ) {
|
||||||
if ( document.formInfo.tryItLabel.value.length == 4 ) {
|
if ( document.formInfo.tryItLabel.value.length == 4 ) {
|
||||||
document.write("<input onclick='tryApp()' value='Try " + document.formInfo.tryItLabel.value + "' borderimage='file://ROM/Borders/ButtonBorder2.bif' type=button usestyle width=110>");
|
document.write("<input onclick='tryApp()' value='Try " + document.formInfo.tryItLabel.value + "' borderimage='file://ROM/Borders/ButtonBorder2.bif' type=button usestyle width=110>");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -224,11 +224,11 @@ document.indexForm.indexSubcat.value = "0";
|
|||||||
drawAll();
|
drawAll();
|
||||||
}
|
}
|
||||||
function goToPage(a,b) { str = subCatUrl[a][b];
|
function goToPage(a,b) { str = subCatUrl[a][b];
|
||||||
if (str.substring(0,4) == "faq:") { goToStr = str.substring(4,str.length);
|
if (str.slice(0,4) == "faq:") { goToStr = str.slice(4,str.length);
|
||||||
goToHelpCenter(goToStr);
|
goToHelpCenter(goToStr);
|
||||||
} else if (str.substring(0,9) == "non-help:") { goToStr = str.substring(9,str.length);
|
} else if (str.slice(0,9) == "non-help:") { goToStr = str.slice(9,str.length);
|
||||||
goToUrl(goToStr);
|
goToUrl(goToStr);
|
||||||
} else if (str.substring(0,7) == "newFAQ:") { goToStr = str.substring(7,str.length);
|
} else if (str.slice(0,7) == "newFAQ:") { goToStr = str.slice(7,str.length);
|
||||||
goToFAQURL(goToStr);
|
goToFAQURL(goToStr);
|
||||||
} else { goToStr = ('wtv-guide:/help?' + str);
|
} else { goToStr = ('wtv-guide:/help?' + str);
|
||||||
goToUrl(goToStr);
|
goToUrl(goToStr);
|
||||||
@@ -279,13 +279,13 @@ go back to it. If not, just go to it. If wholeString is
|
|||||||
specified, it looks for perfect matches of the whole string.
|
specified, it looks for perfect matches of the whole string.
|
||||||
*/
|
*/
|
||||||
ind = gvnStr.indexOf("wtv-token");
|
ind = gvnStr.indexOf("wtv-token");
|
||||||
if (ind > -1) { gvnStr = gvnStr.substring(0,ind);
|
if (ind > -1) { gvnStr = gvnStr.slice(0,ind);
|
||||||
}
|
}
|
||||||
window.message("gvnStr=" + gvnStr);
|
window.message("gvnStr=" + gvnStr);
|
||||||
foundInBackList = false;
|
foundInBackList = false;
|
||||||
for (i=history.length; i--; i>0 ) { if ( wholeString != null ) { testStr = history[i];
|
for (i=history.length; i--; i>0 ) { if ( wholeString != null ) { testStr = history[i];
|
||||||
} else { str = history[i];
|
} else { str = history[i];
|
||||||
testStr = str.substring(0, gvnStr.length);
|
testStr = str.slice(0, gvnStr.length);
|
||||||
}
|
}
|
||||||
if ( testStr == gvnStr ) { i++;
|
if ( testStr == gvnStr ) { i++;
|
||||||
foundInBackList = true;
|
foundInBackList = true;
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ function getPatchDataType(type, invert = false) {
|
|||||||
|
|
||||||
function getResData(file) {
|
function getResData(file) {
|
||||||
var res_data = null;
|
var res_data = null;
|
||||||
if (file.substr(-2, 2).toLowerCase() == "gz") {
|
if (file.slice(-2, 2).toLowerCase() == "gz") {
|
||||||
var res_gz_data = wtvshared.getServiceDep("/viewergen/" + file);
|
var res_gz_data = wtvshared.getServiceDep("/viewergen/" + file);
|
||||||
res_data = zlib.gunzipSync(res_gz_data);
|
res_data = zlib.gunzipSync(res_gz_data);
|
||||||
} else {
|
} else {
|
||||||
@@ -228,34 +228,34 @@ function getPatchData(fname, client_data_obj, start_url = "client:GoToConn", def
|
|||||||
if (typeof val === 'string') {
|
if (typeof val === 'string') {
|
||||||
// start url override
|
// start url override
|
||||||
if (start_url != patch_defaults.start_url && start_url.length <= patch_limits.start_url) {
|
if (start_url != patch_defaults.start_url && start_url.length <= patch_limits.start_url) {
|
||||||
if (val.substr(0, patch_defaults.start_url.length) == patch_defaults.start_url)
|
if (val.slice(0, patch_defaults.start_url.length) == patch_defaults.start_url)
|
||||||
customized_patch_data[idx] = start_url + "\x00";
|
customized_patch_data[idx] = start_url + "\x00";
|
||||||
}
|
}
|
||||||
|
|
||||||
// default service ip override
|
// default service ip override
|
||||||
if (default_ip != patch_defaults.default_ip && default_ip.length <= patch_limits.default_ip) {
|
if (default_ip != patch_defaults.default_ip && default_ip.length <= patch_limits.default_ip) {
|
||||||
if (val.substr(0, patch_defaults.default_ip.length) == patch_defaults.default_ip)
|
if (val.slice(0, patch_defaults.default_ip.length) == patch_defaults.default_ip)
|
||||||
customized_patch_data[idx] = default_ip + "\x00";
|
customized_patch_data[idx] = default_ip + "\x00";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!val.byteLength) {
|
if (!val.byteLength) {
|
||||||
// not a buffer object
|
// not a buffer object
|
||||||
var block_length = val['length'];
|
var block_length = val['length'];
|
||||||
var patch_data = getPatchDataType(val['type'], (fname.substr(12, 3) != "1.1"));
|
var patch_data = getPatchDataType(val['type'], (fname.slice(12, 3) != "1.1"));
|
||||||
if (patch_data) {
|
if (patch_data) {
|
||||||
var patch_data_array = patch_data.split("\r\n");
|
var patch_data_array = patch_data.split("\r\n");
|
||||||
var patch_data_string = "";
|
var patch_data_string = "";
|
||||||
Object.keys(patch_data_array).forEach(function (didx) {
|
Object.keys(patch_data_array).forEach(function (didx) {
|
||||||
var header_end = patch_data_array[didx].indexOf(":");
|
var header_end = patch_data_array[didx].indexOf(":");
|
||||||
if (header_end) {
|
if (header_end) {
|
||||||
var patch_data_header = patch_data_array[didx].substr(0, header_end);
|
var patch_data_header = patch_data_array[didx].slice(0, header_end);
|
||||||
var client_value = client_data_obj[patch_data_header];
|
var client_value = client_data_obj[patch_data_header];
|
||||||
if (client_value)
|
if (client_value)
|
||||||
patch_data_string += patch_data_array[didx].replace("%s", client_value) + "\r\n";
|
patch_data_string += patch_data_array[didx].replace("%s", client_value) + "\r\n";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (fname.substr(12, 3) != "2.5") {
|
if (fname.slice(12, 3) != "2.5") {
|
||||||
var length_difference = block_length - patch_data_string.length;
|
var length_difference = block_length - patch_data_string.length;
|
||||||
if (length_difference > 0)
|
if (length_difference > 0)
|
||||||
patch_data_string += "\x00".repeat(length_difference - (val['type'].length + 1));
|
patch_data_string += "\x00".repeat(length_difference - (val['type'].length + 1));
|
||||||
@@ -493,8 +493,8 @@ if (request_headers.query.viewer &&
|
|||||||
var patched_file = patchBinary(patchDataObject);
|
var patched_file = patchBinary(patchDataObject);
|
||||||
var enabled_feature_bits = [];
|
var enabled_feature_bits = [];
|
||||||
Object.keys(request_headers.query).forEach((k) => {
|
Object.keys(request_headers.query).forEach((k) => {
|
||||||
if (k.substring(0, 12) === "feature_bit_") {
|
if (k.slice(0, 12) === "feature_bit_") {
|
||||||
enabled_feature_bits.push(parseInt(k.substring(12)));
|
enabled_feature_bits.push(parseInt(k.slice(12)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Object.keys(enabled_feature_bits).forEach((k) => {
|
Object.keys(enabled_feature_bits).forEach((k) => {
|
||||||
@@ -553,8 +553,8 @@ Content-Disposition: attachment; filename="${viewer_file.replace(".exe", ".zip")
|
|||||||
|
|
||||||
var embed_modpacks = [];
|
var embed_modpacks = [];
|
||||||
Object.keys(request_headers.query).forEach((k) => {
|
Object.keys(request_headers.query).forEach((k) => {
|
||||||
if (k.substring(0, 8) === "modpack_") {
|
if (k.slice(0, 8) === "modpack_") {
|
||||||
embed_modpacks.push(parseInt(k.substring(8)));
|
embed_modpacks.push(parseInt(k.slice(8)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -601,9 +601,9 @@ window.onload = function() {
|
|||||||
|
|
||||||
function getSSIDCRC(ssid) {
|
function getSSIDCRC(ssid) {
|
||||||
let crc = 0;
|
let crc = 0;
|
||||||
var ssid = ssid.substr(0, 14);
|
var ssid = ssid.slice(0, 14);
|
||||||
for (let i = 0; i < ssid.length; i += 2) {
|
for (let i = 0; i < ssid.length; i += 2) {
|
||||||
let inbyte = parseInt(ssid.substring(i, i+2), 16);
|
let inbyte = parseInt(ssid.slice(i, i+2), 16);
|
||||||
for (let ii = 8; ii > 0; ii--) {
|
for (let ii = 8; ii > 0; ii--) {
|
||||||
let mix = (crc ^ inbyte) & 0x01;
|
let mix = (crc ^ inbyte) & 0x01;
|
||||||
crc >>= 1;
|
crc >>= 1;
|
||||||
@@ -667,9 +667,9 @@ function validateSSID(ssid) {
|
|||||||
alert("Please choose a valid SSID and try again.");
|
alert("Please choose a valid SSID and try again.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((ssid.substr(0,1) != "0" && ssid.substr(0,1) != "8" && ssid.substr(0,1) != "9") ||
|
if ((ssid.slice(0,1) != "0" && ssid.slice(0,1) != "8" && ssid.slice(0,1) != "9") ||
|
||||||
(ssid.substr(6,1) != "0") ||
|
(ssid.slice(6,1) != "0") ||
|
||||||
(ssid.substr(9,5) != "0b002")) {
|
(ssid.slice(9,5) != "0b002")) {
|
||||||
alert("Your SSID is not proper, but I'll allow it.")
|
alert("Your SSID is not proper, but I'll allow it.")
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var minisrv_service_file = true;
|
var minisrv_service_file = true;
|
||||||
|
|
||||||
var mailto = request_headers.request_url;
|
var mailto = request_headers.request_url;
|
||||||
mailto = mailto.substring(mailto.indexOf(":") + 1);
|
mailto = mailto.slice(mailto.indexOf(":") + 1);
|
||||||
mailto = mailto.split("?")[0];
|
mailto = mailto.split("?")[0];
|
||||||
var subject = request_headers.query.subject || "";
|
var subject = request_headers.query.subject || "";
|
||||||
var body = request_headers.query.body || "";
|
var body = request_headers.query.body || "";
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ if (session_data.data_store.wtvsec_login) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socket.ssid.substr(0, 8) == "MSTVSIMU") {
|
if (socket.ssid.slice(0, 8) == "MSTVSIMU") {
|
||||||
prereg_contype = "text/dialscript";
|
prereg_contype = "text/dialscript";
|
||||||
var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/UTV/utv_hsd.tok", true);
|
var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/UTV/utv_hsd.tok", true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class WTVAuthor {
|
|||||||
this.debug("createPage","pages",pages)
|
this.debug("createPage","pages",pages)
|
||||||
var pagenums = [];
|
var pagenums = [];
|
||||||
for(let i = 0; i < pagelen; i++) {
|
for(let i = 0; i < pagelen; i++) {
|
||||||
var toarr = pages[i].substr(0, pages[i].indexOf('.'));
|
var toarr = pages[i].slice(0, pages[i].indexOf('.'));
|
||||||
pagenums.push(parseInt(toarr));
|
pagenums.push(parseInt(toarr));
|
||||||
}
|
}
|
||||||
pagenums = pagenums.sort()
|
pagenums = pagenums.sort()
|
||||||
@@ -469,7 +469,7 @@ this.fs.writeFile(destDir + this.wtvclient.session_store.subscriber_username + '
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "clipart":
|
case "clipart":
|
||||||
this.fs.mkdirSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + pagedata.publishname + "/" + atob(thisblock.photo).substr(0, atob(thisblock.photo).lastIndexOf("/")), { recursive: true })
|
this.fs.mkdirSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + pagedata.publishname + "/" + atob(thisblock.photo).slice(0, atob(thisblock.photo).lastIndexOf("/")), { recursive: true })
|
||||||
this.fs.copyFile('includes/ServiceVault/wtv-author/' + atob(thisblock.photo), destDir + this.wtvclient.session_store.subscriber_username + '/' + pagedata.publishname + "/" + atob(thisblock.photo), (err) => {
|
this.fs.copyFile('includes/ServiceVault/wtv-author/' + atob(thisblock.photo), destDir + this.wtvclient.session_store.subscriber_username + '/' + pagedata.publishname + "/" + atob(thisblock.photo), (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
});
|
});
|
||||||
@@ -840,7 +840,7 @@ html += `">next page</a>
|
|||||||
var publishname = null;
|
var publishname = null;
|
||||||
|
|
||||||
if (pagedata.published != true) {
|
if (pagedata.published != true) {
|
||||||
publishname = pagedata.title.substring(0, 50).replaceAll(" ", "").replace(/[^A-Za-z0-9]/g, "-");
|
publishname = pagedata.title.slice(0, 50).replaceAll(" ", "").replace(/[^A-Za-z0-9]/g, "-");
|
||||||
pagedata.publishname = publishname;
|
pagedata.publishname = publishname;
|
||||||
this.editPage(pagedata, pagenum);
|
this.editPage(pagedata, pagenum);
|
||||||
if (this.fs.existsSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + publishname)) {
|
if (this.fs.existsSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + publishname)) {
|
||||||
@@ -867,7 +867,7 @@ html += `">next page</a>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (let i = 0; i < this.stylemedia.length; i++) {
|
for (let i = 0; i < this.stylemedia.length; i++) {
|
||||||
this.fs.mkdirSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + publishname + this.stylemedia[i].substr(0, this.stylemedia[i].lastIndexOf("/")), { recursive: true })
|
this.fs.mkdirSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + publishname + this.stylemedia[i].slice(0, this.stylemedia[i].lastIndexOf("/")), { recursive: true })
|
||||||
this.fs.copyFile('includes/ServiceVault/wtv-author' + this.stylemedia[i], destDir + this.wtvclient.session_store.subscriber_username + '/' + publishname + this.stylemedia[i], (err) => {
|
this.fs.copyFile('includes/ServiceVault/wtv-author' + this.stylemedia[i], destDir + this.wtvclient.session_store.subscriber_username + '/' + publishname + this.stylemedia[i], (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1331,10 +1331,10 @@ class WTVBGMusic {
|
|||||||
getSongCategory(songid) {
|
getSongCategory(songid) {
|
||||||
if (String(songid).length === 3) {
|
if (String(songid).length === 3) {
|
||||||
// 3 digit song id
|
// 3 digit song id
|
||||||
return parseInt(String(songid).substr(0, 1));
|
return parseInt(String(songid).slice(0, 1));
|
||||||
} else if (String(songid).length === 4) {
|
} else if (String(songid).length === 4) {
|
||||||
// 4 digit song id
|
// 4 digit song id
|
||||||
return parseInt(String(songid).substr(0, 2));
|
return parseInt(String(songid).slice(0, 2));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1353,10 +1353,10 @@ class WTVBGMusic {
|
|||||||
musiclist[k].id = k;
|
musiclist[k].id = k;
|
||||||
if (String(category).length === 1) {
|
if (String(category).length === 1) {
|
||||||
// 3 digit song id
|
// 3 digit song id
|
||||||
if (parseInt(k.substr(0, 1)) == parseInt(category) && String(k).length === 3) songList.push(musiclist[k]);
|
if (parseInt(k.slice(0, 1)) == parseInt(category) && String(k).length === 3) songList.push(musiclist[k]);
|
||||||
} else if (String(category).length === 2) {
|
} else if (String(category).length === 2) {
|
||||||
// 4 digit song id
|
// 4 digit song id
|
||||||
if (parseInt(k.substr(0, 2)) == parseInt(category) && String(k).length === 4) songList.push(musiclist[k]);
|
if (parseInt(k.slice(0, 2)) == parseInt(category) && String(k).length === 4) songList.push(musiclist[k]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return songList.filter(value => Object.keys(value).length !== 0);
|
return songList.filter(value => Object.keys(value).length !== 0);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class WTVClientCapabilities {
|
|||||||
//In case remaining hex length (or initial) is not multiple of 8
|
//In case remaining hex length (or initial) is not multiple of 8
|
||||||
var blockSize = remainingSize < 8 ? remainingSize : 8;
|
var blockSize = remainingSize < 8 ? remainingSize : 8;
|
||||||
|
|
||||||
binary += parseInt(hex.substr(p * 8, blockSize), 16).toString(2);
|
binary += parseInt(hex.slice(p * 8, blockSize), 16).toString(2);
|
||||||
|
|
||||||
remainingSize -= blockSize;
|
remainingSize -= blockSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ class WTVClientSessionData {
|
|||||||
Object.keys(cookie_data).forEach(function (k) {
|
Object.keys(cookie_data).forEach(function (k) {
|
||||||
outstring += k + "=" + escape(cookie_data[k]) + "&";
|
outstring += k + "=" + escape(cookie_data[k]) + "&";
|
||||||
});
|
});
|
||||||
return outstring.substring(0, outstring.length - 1);
|
return outstring.slice(0, outstring.length - 1);
|
||||||
*/
|
*/
|
||||||
return cookie_data.cookie;
|
return cookie_data.cookie;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class WTVDownloadList {
|
|||||||
this.download_list += `file-permission: ${file_permission}\n`;
|
this.download_list += `file-permission: ${file_permission}\n`;
|
||||||
if (checksum != null) this.download_list += `wtv-checksum: ${checksum}\n`;
|
if (checksum != null) this.download_list += `wtv-checksum: ${checksum}\n`;
|
||||||
if (uncompressed_size != null) this.download_list += `wtv-uncompressed-filesize: ${uncompressed_size}\n`;
|
if (uncompressed_size != null) this.download_list += `wtv-uncompressed-filesize: ${uncompressed_size}\n`;
|
||||||
this.download_list += `service-source-location: /webtv/content/${source.substring(source.indexOf('-') + 1, source.indexOf(':/'))}d/${source.substring(source.indexOf(':/') + 2)}\n`;
|
this.download_list += `service-source-location: /webtv/content/${source.slice(source.indexOf('-') + 1, source.indexOf(':/'))}d/${source.slice(source.indexOf(':/') + 2)}\n`;
|
||||||
this.download_list += `client-dest-location: ${path}\n\n`;
|
this.download_list += `client-dest-location: ${path}\n\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ class WTVDownloadList {
|
|||||||
if (typeof post_data == 'string') post_data = post_data.split("\n\n");
|
if (typeof post_data == 'string') post_data = post_data.split("\n\n");
|
||||||
const group_data = [];
|
const group_data = [];
|
||||||
post_data.forEach(function (v) {
|
post_data.forEach(function (v) {
|
||||||
if (v.substring(0, 4) == "file") {
|
if (v.slice(0, 4) == "file") {
|
||||||
const block_split = v.split("\n");
|
const block_split = v.split("\n");
|
||||||
const group_data_entry = {};
|
const group_data_entry = {};
|
||||||
group_data_entry.path = block_split[0];
|
group_data_entry.path = block_split[0];
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class WTVFlashrom {
|
|||||||
|
|
||||||
if (this.minisrv_config.config.debug_flags.debug && this.minisrv_config.config.debug_flags.quiet) console.log(" # Sending", (flashrom_info.is_last_part) ? "Last Flashrom" : "Flashrom", "Part", flashrom_info.part_number, "- Bytes Sent:", flashrom_info.byte_progress + flashrom_info.part_total_size, "of", flashrom_info.total_parts_size, "(" + flashrom_info.percent_complete + " % complete)");
|
if (this.minisrv_config.config.debug_flags.debug && this.minisrv_config.config.debug_flags.quiet) console.log(" # Sending", (flashrom_info.is_last_part) ? "Last Flashrom" : "Flashrom", "Part", flashrom_info.part_number, "- Bytes Sent:", flashrom_info.byte_progress + flashrom_info.part_total_size, "of", flashrom_info.total_parts_size, "(" + flashrom_info.percent_complete + " % complete)");
|
||||||
// read current part display message from part header
|
// read current part display message from part header
|
||||||
flashrom_info.message = new Buffer.from(part_header.toString('hex').substring(36 * 2, 68 * 2), 'hex').toString('ascii').replace(/[^0-9a-z\ \.\-]/gi, "");
|
flashrom_info.message = new Buffer.from(part_header.toString('hex').slice(36 * 2, 68 * 2), 'hex').toString('ascii').replace(/[^0-9a-z\ \.\-]/gi, "");
|
||||||
flashrom_info.rompath = `wtv-flashrom:/${path}`;
|
flashrom_info.rompath = `wtv-flashrom:/${path}`;
|
||||||
|
|
||||||
if (flashrom_info.is_last_part && this.bf0app_update) {
|
if (flashrom_info.is_last_part && this.bf0app_update) {
|
||||||
|
|||||||
@@ -70,28 +70,28 @@ class WTVGuide {
|
|||||||
var start = start + search.length;
|
var start = start + search.length;
|
||||||
original_start = start;
|
original_start = start;
|
||||||
// handle <word="whatever">
|
// handle <word="whatever">
|
||||||
if (definition.substr(start, 1) != ">") {
|
if (definition.slice(start, 1) != ">") {
|
||||||
start++; // +1 to skip =
|
start++; // +1 to skip =
|
||||||
end = definition.indexOf(">", start);
|
end = definition.indexOf(">", start);
|
||||||
link_word_override = definition.substring(start, end);
|
link_word_override = definition.slice(start, end);
|
||||||
// strip any quotes
|
// strip any quotes
|
||||||
if (link_word_override.substr(0, 1).match(/[\"\']/)) link_word_override = link_word_override.substring(1);
|
if (link_word_override.slice(0, 1).match(/[\"\']/)) link_word_override = link_word_override.slice(1);
|
||||||
if (link_word_override.substr(link_word_override.length - 1, 1).match(/[\"\']/)) link_word_override = link_word_override.substr(0, link_word_override.length - 1);
|
if (link_word_override.slice(link_word_override.length - 1, 1).match(/[\"\']/)) link_word_override = link_word_override.slice(0, link_word_override.length - 1);
|
||||||
|
|
||||||
link_word_for_link = link_word_override.replace(/ /g, '').replace(/\'/g, '').replace(/\"/g, '').toLowerCase();
|
link_word_for_link = link_word_override.replace(/ /g, '').replace(/\'/g, '').replace(/\"/g, '').toLowerCase();
|
||||||
link_word_start_letter = link_word_for_link.substr(0, 1).toUpperCase();
|
link_word_start_letter = link_word_for_link.slice(0, 1).toUpperCase();
|
||||||
start = end + 1; // update start pos for rest of processing
|
start = end + 1; // update start pos for rest of processing
|
||||||
} else {
|
} else {
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
end = definition.indexOf("</word>", start);
|
end = definition.indexOf("</word>", start);
|
||||||
var link_word = definition.substring(start, end);
|
var link_word = definition.slice(start, end);
|
||||||
if (!link_word_for_link) link_word_for_link = link_word.replace(/ /g, '').replace(/\'/g,'').replace(/\"/g,'').toLowerCase();
|
if (!link_word_for_link) link_word_for_link = link_word.replace(/ /g, '').replace(/\'/g,'').replace(/\"/g,'').toLowerCase();
|
||||||
if (!link_word_start_letter) link_word_start_letter = link_word.substr(0, 1).toUpperCase();
|
if (!link_word_start_letter) link_word_start_letter = link_word.slice(0, 1).toUpperCase();
|
||||||
if (!link_word_override) link_word_override = link_word;
|
if (!link_word_override) link_word_override = link_word;
|
||||||
|
|
||||||
var link_url = `wtv-guide:/help?topic=Glossary&subtopic=${link_word_start_letter}&page=${link_word_for_link}&word=${encodeURIComponent(link_word_override)}`
|
var link_url = `wtv-guide:/help?topic=Glossary&subtopic=${link_word_start_letter}&page=${link_word_for_link}&word=${encodeURIComponent(link_word_override)}`
|
||||||
var new_definition = definition.substring(0, original_start - search.length) + `<a href="${link_url}">${link_word}</a>` + definition.substring(end + 7);
|
var new_definition = definition.slice(0, original_start - search.length) + `<a href="${link_url}">${link_word}</a>` + definition.slice(end + 7);
|
||||||
definition = new_definition;
|
definition = new_definition;
|
||||||
}
|
}
|
||||||
// replaces <boxname> with the friendly name of the type of unit the user has
|
// replaces <boxname> with the friendly name of the type of unit the user has
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ class WTVMail {
|
|||||||
else return a.time - b.time;
|
else return a.time - b.time;
|
||||||
})
|
})
|
||||||
.map(function (v) {
|
.map(function (v) {
|
||||||
if (v.name.substring((v.name.length - self.msgFileExt.length)) === self.msgFileExt) return v.name.substring(0, (v.name.length - 5));
|
if (v.name.slice((v.name.length - self.msgFileExt.length)) === self.msgFileExt) return v.name.slice(0, (v.name.length - 5));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (files.length == 0) return false; // no messages
|
if (files.length == 0) return false; // no messages
|
||||||
@@ -398,7 +398,7 @@ class WTVMail {
|
|||||||
var path_after_replace = search_dir.replace(accounts_dir, '');
|
var path_after_replace = search_dir.replace(accounts_dir, '');
|
||||||
// Remove leading path separator if present
|
// Remove leading path separator if present
|
||||||
if (path_after_replace.startsWith(self.path.sep)) {
|
if (path_after_replace.startsWith(self.path.sep)) {
|
||||||
path_after_replace = path_after_replace.substring(1);
|
path_after_replace = path_after_replace.slice(1);
|
||||||
}
|
}
|
||||||
var path_split = path_after_replace.split(self.path.sep);
|
var path_split = path_after_replace.split(self.path.sep);
|
||||||
// The path should be like "ssid/user0", so extract ssid and user_id
|
// The path should be like "ssid/user0", so extract ssid and user_id
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ class WTVMinifyingProxy {
|
|||||||
for (const [selector, styles] of cssRules) {
|
for (const [selector, styles] of cssRules) {
|
||||||
if (selector.startsWith('.')) {
|
if (selector.startsWith('.')) {
|
||||||
// Handle class selectors (e.g., .lst)
|
// Handle class selectors (e.g., .lst)
|
||||||
const className = selector.substring(1);
|
const className = selector.slice(1);
|
||||||
const regex = new RegExp(`<(input[^>]*class\\s*=\\s*["'][^"']*\\b${className}\\b[^"']*["'][^>]*)>`, 'gi');
|
const regex = new RegExp(`<(input[^>]*class\\s*=\\s*["'][^"']*\\b${className}\\b[^"']*["'][^>]*)>`, 'gi');
|
||||||
html = html.replace(regex, (match, tagContent) => {
|
html = html.replace(regex, (match, tagContent) => {
|
||||||
// Convert CSS styles to attributes for this element (input tag)
|
// Convert CSS styles to attributes for this element (input tag)
|
||||||
@@ -545,7 +545,7 @@ class WTVMinifyingProxy {
|
|||||||
// No body tag found, extract everything after head or use all content
|
// No body tag found, extract everything after head or use all content
|
||||||
const headEndMatch = html.match(/<\/head>/i);
|
const headEndMatch = html.match(/<\/head>/i);
|
||||||
if (headEndMatch) {
|
if (headEndMatch) {
|
||||||
bodyContent = html.substring(html.indexOf(headEndMatch[0]) + headEndMatch[0].length);
|
bodyContent = html.slice(html.indexOf(headEndMatch[0]) + headEndMatch[0].length);
|
||||||
} else {
|
} else {
|
||||||
bodyContent = html;
|
bodyContent = html;
|
||||||
}
|
}
|
||||||
@@ -711,19 +711,19 @@ ${bodyContent}
|
|||||||
intelligentTruncate(content, maxLength) {
|
intelligentTruncate(content, maxLength) {
|
||||||
if (content.length <= maxLength) return content;
|
if (content.length <= maxLength) return content;
|
||||||
|
|
||||||
let truncated = content.substring(0, maxLength);
|
let truncated = content.slice(0, maxLength);
|
||||||
|
|
||||||
// Try to cut at a tag boundary
|
// Try to cut at a tag boundary
|
||||||
const lastCloseTag = truncated.lastIndexOf('>');
|
const lastCloseTag = truncated.lastIndexOf('>');
|
||||||
const lastOpenTag = truncated.lastIndexOf('<');
|
const lastOpenTag = truncated.lastIndexOf('<');
|
||||||
|
|
||||||
if (lastCloseTag > lastOpenTag) {
|
if (lastCloseTag > lastOpenTag) {
|
||||||
truncated = truncated.substring(0, lastCloseTag + 1);
|
truncated = truncated.slice(0, lastCloseTag + 1);
|
||||||
} else {
|
} else {
|
||||||
// Cut at word boundary
|
// Cut at word boundary
|
||||||
const lastSpace = truncated.lastIndexOf(' ');
|
const lastSpace = truncated.lastIndexOf(' ');
|
||||||
if (lastSpace > maxLength * 0.8) { // Only if we don't lose too much
|
if (lastSpace > maxLength * 0.8) { // Only if we don't lose too much
|
||||||
truncated = truncated.substring(0, lastSpace);
|
truncated = truncated.slice(0, lastSpace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,7 +769,7 @@ ${bodyContent}
|
|||||||
// No body tag found, extract content after head or use transformed content
|
// No body tag found, extract content after head or use transformed content
|
||||||
const headEndMatch = transformed.match(/<\/head>/i);
|
const headEndMatch = transformed.match(/<\/head>/i);
|
||||||
if (headEndMatch) {
|
if (headEndMatch) {
|
||||||
bodyContent = transformed.substring(transformed.indexOf(headEndMatch[0]) + headEndMatch[0].length);
|
bodyContent = transformed.slice(transformed.indexOf(headEndMatch[0]) + headEndMatch[0].length);
|
||||||
} else {
|
} else {
|
||||||
bodyContent = transformed;
|
bodyContent = transformed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class WTVNewsServer {
|
|||||||
Object.keys(message.headers).forEach((k) => {
|
Object.keys(message.headers).forEach((k) => {
|
||||||
if (k.length > 0) out += `${k}: ${message.headers[k]}\r\n`;
|
if (k.length > 0) out += `${k}: ${message.headers[k]}\r\n`;
|
||||||
});
|
});
|
||||||
out = out.substr(0, out.length - 2);
|
out = out.slice(0, out.length - 2);
|
||||||
return out;
|
return out;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class WTVTellyScriptTokenizer {
|
|||||||
// Process as a constant.
|
// Process as a constant.
|
||||||
let hexString = "";
|
let hexString = "";
|
||||||
if (checkSequence.startsWith("0x") || checkSequence.startsWith("0X")) {
|
if (checkSequence.startsWith("0x") || checkSequence.startsWith("0X")) {
|
||||||
hexString = checkSequence.substring(2);
|
hexString = checkSequence.slice(2);
|
||||||
} else {
|
} else {
|
||||||
hexString = parseInt(checkSequence, 10).toString(16).toUpperCase();
|
hexString = parseInt(checkSequence, 10).toString(16).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user