update: add 'hasCap(flag)' function to WTVClientSessionData for easier client-capabilities checking (see wtv-home/home.js for an example)

This commit is contained in:
zefie
2021-07-26 06:12:53 -04:00
parent 03a3337cd4
commit 41b4deb831
3 changed files with 25 additions and 7 deletions

View File

@@ -11,7 +11,7 @@ if (ssid_sessions[socket.ssid].get('box-does-psuedo-encryption')) {
}
data =`<html>
data = `<html>
<head>
<title>Home for minisrv</title>
<DISPLAY NoLogo hideoptions noscroll>
@@ -29,12 +29,22 @@ function go() {
<form name=access onsubmit="go()">
<ul>
<li><a href="client:relog">client:relog (direct)</a> ~ <a href="wtv-tricks:/blastcache?return_to=wtv-home:/home">Clear Cache</a></li>
<li><a href="client:diskhax">DiskHax</a> ~ <a href="client:vfathax">VFatHax</a></li>
<li><a href="wtv-flashrom:/willie" selected>Ultra Willies</a> ~ <a href="wtv-tricks:/info">Tricks Info</a></li>
<li><a href="wtv-music:/demo/index">MIDI Music Demo</a></li>
<li>Old MSNTV DealerDemo: <a href="wtv-update:/DealerDemo">Download</a> ~ <a href="file://Disk/Demo/index.html">Access (after Download)</a></li>
<li><a href="http://duckduckgo.com/lite/">DuckDuckGo Lite</a></li>`
if (ssid_sessions[socket.ssid].get('wtv-need-upgrade') != 'true') {
`;
if (ssid_sessions[socket.ssid].hasCap("client-has-disk")) {
// only show disk stuff if client has disk
data += "<li><a href=\"client:diskhax\">DiskHax</a> ~ <a href=\"client:vfathax\">VFatHax</a></li>\n";
if (ssid_sessions[socket.ssid].hasCap("client-can-do-macromedia-flash2")) {
// only show demo if client can do flash2
data += "<li>Old MSNTV DealerDemo: <a href=\"wtv-update:/DealerDemo\">Download</a> ~ <a href=\"file://Disk/Demo/index.html\"> Access (after Download)</a></li>\n";
}
}
data += `<li><a href="http://duckduckgo.com/lite/">DuckDuckGo Lite</a></li>`
if (ssid_sessions[socket.ssid].hasCap("client-can-do-javascript")) {
// URL access form requires javascript, hide if client does not support
data += `<li><input name=url `;
if (request_headers.query.url) {
@@ -43,7 +53,7 @@ if (ssid_sessions[socket.ssid].get('wtv-need-upgrade') != 'true') {
data += `width=250 height=10 bgcolor=#444444 text=#ffdd33 cursor=#cc9933>
<input type=submit value="Access URL">
</form>`
</form>`;
}
data += "</li >\n</ul>";

View File

@@ -9,11 +9,19 @@ class WTVClientSessionData {
\***********************************/
data_store = null;
capabilities = null;
constructor() {
this.data_store = new Array();
}
hasCap(cap) {
if (this.capabilities) {
return this.capabilities[cap] || false;
}
return false;
}
get(key = null) {
if (typeof (this.data_store) === 'undefined') return null;
else if (key === null) return this.data_store;

View File

@@ -730,7 +730,7 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
if (!ssid_sessions[socket.ssid]) {
ssid_sessions[socket.ssid] = new WTVClientSessionData();
}
if (!ssid_sessions[socket.ssid].data_store.capabilities) ssid_sessions[socket.ssid].data_store.capabilities = new WTVClientCapabilities(headers["wtv-capability-flags"]);
if (!ssid_sessions[socket.ssid].capabilities) ssid_sessions[socket.ssid].capabilities = new WTVClientCapabilities(headers["wtv-capability-flags"]);
}