exit output bugfix and nickname in pretext
This commit is contained in:
parent
af092439a3
commit
168d42398e
@ -5,14 +5,14 @@ function runCommand(input) {
|
||||
return "";
|
||||
|
||||
// Exit current level
|
||||
if (input.toLowerCase().startsWith("exit")) {
|
||||
const modeSplit = chatMode.split(' ')[0];
|
||||
if (input.toLowerCase().startsWith("exit") && modeSplit !== "default") {
|
||||
cmd_exit();
|
||||
return "";
|
||||
}
|
||||
|
||||
// Handle different chat modes
|
||||
const modeSplit = chatMode.split(' ');
|
||||
switch (modeSplit[0]) {
|
||||
switch (modeSplit) {
|
||||
case "msg":
|
||||
directMessage(modeSplit[1], input);
|
||||
renameToSelf();
|
||||
@ -88,6 +88,10 @@ function cmd_clear() {
|
||||
for (let i = tbc.length-3; i > 1; i--)
|
||||
tbDiv.removeChild(tbc[i]);
|
||||
|
||||
const prelink = document.createElement("a");
|
||||
prelink.innerHTML = pretext.original;
|
||||
tbDiv.replaceChild(prelink, tbc[1]);
|
||||
|
||||
pretext.current = pretext.original;
|
||||
cursorPosition = 0;
|
||||
cursorYOffset = 7;
|
||||
@ -173,8 +177,10 @@ function cmd_msg(input) {
|
||||
// Exit current level (example: chat -> main)
|
||||
function cmd_exit(error) {
|
||||
const level = chatMode.split(' ')[0];
|
||||
if (level === "default")
|
||||
if (level === "default") {
|
||||
console.log("Test!");
|
||||
return "Already at top-level!";
|
||||
}
|
||||
|
||||
// Set mode to default and reset pretext
|
||||
chatMode = "default";
|
||||
|
@ -42,6 +42,7 @@ function connect(name) {
|
||||
// Save provided id
|
||||
const { id } = res;
|
||||
user.id = id;
|
||||
pretext.original = pretext.current = `${user.name}@baipyr.us:~# `;
|
||||
outputText({output: `Connected as '${name}#${id}'.`});
|
||||
});
|
||||
}
|
||||
@ -49,6 +50,7 @@ function connect(name) {
|
||||
|
||||
// Send nickname to server, receive verification
|
||||
function sendNickname(name) {
|
||||
user.name = name;
|
||||
fetch('/nickname', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -69,8 +71,8 @@ function sendNickname(name) {
|
||||
return;
|
||||
// Receive name and save it
|
||||
const { id } = res;
|
||||
user.name = name;
|
||||
user.id = id;
|
||||
pretext.original = pretext.current = `${user.name}@baipyr.us:~# `;
|
||||
// Reply whether name is taken or not
|
||||
outputText({output: `Applied name '${name}#${id}'.`});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user