- numerous bug fixes - add UTV tellyscripts - BREAKING CHANGE: doErrorPage moved to wtvshared.doErrorPage - but I fixed flashrom error handling.. - added a passthrough for old scripts - added eMac's lzpf compression - Bump vm2 from 3.9.3 to 3.9.5 in /zefie_wtvp_minisrv
153 lines
5.0 KiB
JavaScript
153 lines
5.0 KiB
JavaScript
var minisrv_service_file = true;
|
|
|
|
const WTVFlashrom = require("./WTVFlashrom.js");
|
|
var wtvflashrom;
|
|
request_is_async = true;
|
|
|
|
if (!request_headers.query.path) {
|
|
var errpage = wtvshared.doErrorPage(400);
|
|
headers = errpage[0];
|
|
data = errpage[1];
|
|
} else {
|
|
var wtvflashrom = new WTVFlashrom(minisrv_config, service_vaults, service_name, minisrv_config.services[service_name].use_zefie_server, false, true);
|
|
var request_path = request_headers.query.path;
|
|
|
|
// read flashrom header info into array using WTVFlashrom class
|
|
wtvflashrom.getFlashromMeta(request_path, function (data) {
|
|
processLC2DownloadPage(request_headers.query.path, data, (request_headers.query.numparts || null));
|
|
});
|
|
}
|
|
|
|
async function processLC2DownloadPage(path, flashrom_info, numparts = null) {
|
|
if (numparts != null) flashrom_info.part_count = parseInt(numparts);
|
|
if (!flashrom_info.part_count) flashrom_info.part_count = parseInt(flashrom_info.message.substring(flashrom_info.message.length - 4).replace(/\D/g, ''));
|
|
if (!flashrom_info.part_number || !flashrom_info.is_last_part || !flashrom_info.rompath || !flashrom_info.next_rompath || !flashrom_info.is_bootrom) {
|
|
if (!flashrom_info.is_last_part) {
|
|
flashrom_info.next_rompath = request_headers.request_url.replace(escape(request_headers.query.path), escape(flashrom_info.next_rompath.replace(service_name+":/","")));
|
|
}
|
|
|
|
headers = `200 OK
|
|
Content-type: text/html`
|
|
|
|
data = `<html>
|
|
<head>
|
|
<title>
|
|
Updating
|
|
</title>
|
|
<display switchtowebmode transition=none nostatus nooptions skipback clearback>
|
|
</head>
|
|
<body noscroll bgcolor="#191919" text="#42CC55" link="36d5ff"
|
|
hspace=0 vspace=0 fontsize="large">
|
|
<table cellspacing=0 cellpadding=0>
|
|
<tr>
|
|
<td width=104 height=74 valign=middle align=center bgcolor="3B3A4D">
|
|
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
|
|
<td width=20 valign=top align=left bgcolor="3B3A4D">
|
|
<img src="${service_name}:/ROMCache/Spacer.gif" width=1 height=1>
|
|
<td colspan=10 width=436 valign=middle align=left bgcolor="3B3A4D">
|
|
<font color="D6DFD0" size="+2">
|
|
<blackface>
|
|
<shadow>
|
|
<img src="${service_name}:/ROMCache/Spacer.gif" width=1 height=4>
|
|
<br>
|
|
Updating now
|
|
</shadow>
|
|
</blackface>
|
|
</font>
|
|
<tr>
|
|
<td colspan=12 width=560 height=10 valign=top align=left>
|
|
<img src="${service_name}:/ROMCache/S40H1.gif" width=560 height=6>
|
|
<tr>
|
|
<td width=104 height=10 valign=top align=left>
|
|
<td width=20 valign=top align=left>
|
|
<td width=67 valign=top align=left>
|
|
<td width=20 valign=top align=left>
|
|
<td width=67 valign=top align=left>
|
|
<td width=20 valign=top align=left>
|
|
<td width=67 valign=top align=left>
|
|
<td width=20 valign=top align=left>
|
|
<td width=67 valign=top align=left>
|
|
<td width=20 valign=top align=left>
|
|
<td width=68 valign=top align=left>
|
|
<td width=20 valign=top align=left>
|
|
<form action="client:poweroff">
|
|
<tr>
|
|
<td width=104 valign=middle align=center>
|
|
<td width=20 valign=middle align=center>
|
|
<td colspan=9 width=100 height=258 valign=top align=left>
|
|
<font size=+1>
|
|
Your WebTV Unit is being<br>updated automatically.
|
|
<p> <font size=+1>
|
|
This will take a while, and<br>then you can use your WebTV again.
|
|
`;
|
|
if (flashrom_info.is_bootrom && flashrom_info.part_number == 16) {
|
|
data += `<p>
|
|
The system will pause for about 30 seconds at the end of this
|
|
update. Please <strong>do not</strong> interrupt the system
|
|
during this time.
|
|
`
|
|
}
|
|
data += `
|
|
</font>
|
|
<br><br><br><br><br>
|
|
<upgradeblock width=280 height=15
|
|
nexturl="${flashrom_info.next_rompath}"
|
|
errorurl="${service_name}:/lc2-download-failed?"
|
|
blockurl="${flashrom_info.rompath}"`;
|
|
|
|
data += `
|
|
lastblock="${flashrom_info.is_last_part}"
|
|
curblock="` + (flashrom_info.part_number + 1) + `"
|
|
`;
|
|
if (flashrom_info.part_count) {
|
|
data += `totalblocks="${flashrom_info.part_count}"`;
|
|
}
|
|
data += `>
|
|
<font size="-1" color="#D6DFD0">
|
|
<br>
|
|
<img src="${service_name}:/ROMCache/Spacer.gif" width=2 height=10><br>
|
|
${flashrom_info.message}
|
|
<br><br>
|
|
<tr>
|
|
<td width=104 valign=middle align=center>
|
|
<td width=20 valign=middle align=center>
|
|
<td colspan=10 height=2 valign=middle align=center bgcolor="#191919">
|
|
<img src="${service_name}:/ROMCache/Spacer.gif" width=436 height=1>
|
|
<tr>
|
|
<td width=104 valign=middle align=center>
|
|
<td width=20 valign=middle align=center>
|
|
<td colspan=9 height=1 valign=top align=left>
|
|
<tr>
|
|
<td width=104 valign=middle align=center>
|
|
<td width=20 valign=middle align=center>
|
|
<td colspan=10 height=2 valign=top align=left bgcolor="#191919">
|
|
<img src="${service_name}:/ROMCache/Spacer.gif" width=436 height=1>
|
|
<tr>
|
|
<td width=104 valign=middle align=center>
|
|
<td width=20 valign=middle align=center>
|
|
<td colspan=9 height=4 valign=top align=left>
|
|
<tr>
|
|
<td width=104 valign=middle align=center>
|
|
<td width=20 valign=middle align=center>
|
|
<td colspan=9 width=416 valign=top align=right>
|
|
<table cellspacing=0 cellpadding=0>
|
|
<tr>
|
|
<td width=306 valign=top align=left>
|
|
<font size="-1"><i>
|
|
</i></font><td width=112 valign=top align=right>
|
|
<font size="-1" color="#191919">
|
|
</font>
|
|
</form>
|
|
</table>
|
|
<td width=20 valign=middle align=center>
|
|
</table>
|
|
</body>
|
|
</html>`;
|
|
} else {
|
|
var errpage = wtvshared.doErrorPage(400)
|
|
headers = errpage[0];
|
|
data = errpage[1];
|
|
}
|
|
sendToClient(socket, headers, data);
|
|
}
|