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
This commit is contained in:
zefie
2021-07-26 07:07:05 -04:00
parent 7826891070
commit 012c0114e1
7 changed files with 185 additions and 152 deletions

View File

@@ -22,6 +22,30 @@ class WTVClientSessionData {
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;