- minor update: app.js: fix found file path in log on windows
 - update: WTVClientCapabilities.js: allow setting flags to false, to prevent potential issue with changing cap flags
 - update: add 'hasCap(flag)' function to WTVClientSessionData for easier client-capabilities checking (see wtv-home/home.js for an example)
 - update: add isMiniBrowser() to WTVClientSessionData for easier detection of MiniBrowser.
 - update: add 'setIRCNick()' function to WTVClientSessionData for ease of use
 - update: add primative getMaxUsernameLength() to overcome username limitation in older builds
 - update: wtv-chat:/home template
 - update: app.js: add logging errors to file
This commit is contained in:
zefie
2021-07-25 10:12:36 -04:00
parent e591d255b7
commit c4e3e0fb99
11 changed files with 248 additions and 174 deletions

View File

@@ -9,11 +9,48 @@ 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;
}
getMaxUsernameLength() {
if (parseInt(this.data_store['wtv-system-version'] < 4000)) {
// older builds may crash with nicknames longer than 16 chars.
// actual build where support started is yet unknown
return 16;
} else {
// newer builds supported up to 32 chars, I think
return 32;
}
}
setIRCNick(nick) {
// strip out unsupported chars
nick = nick.replace(/[^a-zA-Z0-9\-\_\`\^]/g, "");
// limit nick length based on build support
nick = nick.substring(0, this.getMaxUsernameLength());
// returns headers to send to client, while storing the new data in our session data.
this.data_store['wtv-user-name'] = nick;
this.data_store['wtv-irc-nick'] = nick;
return "wtv-irc-nick: " + nick + "\nwtv-user-nick: " + nick;
}
isMiniBrowser() {
if (this.data_store['wtv-need-upgrade'] || this.data_store['wtv-used-8675309']) return true;
return false;
}
get(key = null) {
if (typeof (this.data_store) === 'undefined') return null;
else if (key === null) return this.data_store;