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