diff --git a/src/views/channel.ejs b/src/views/channel.ejs
index f8a5762..cac60d7 100644
--- a/src/views/channel.ejs
+++ b/src/views/channel.ejs
@@ -121,6 +121,7 @@ along with this program. If not, see .-->
<%- include('partial/scripts', {user}); %>
+
diff --git a/www/js/channel/chat.js b/www/js/channel/chat.js
index 8e7ce96..ce18a6f 100644
--- a/www/js/channel/chat.js
+++ b/www/js/channel/chat.js
@@ -24,6 +24,9 @@ class chatBox{
//clickDragger object
this.clickDragger = new canopyUXUtils.clickDragger("#chat-panel-drag-handle", "#chat-panel-div");
+
+ //Preprocessor objects
+ this.commandPreprocessor = new commandPreprocessor(client);
this.chatPreprocessor = new chatPreprocessor();
//Element Nodes
@@ -115,9 +118,9 @@ class chatBox{
this.resizeAspect();
}
- async send(event){
+ send(event){
if((!event || !event.key || event.key == "Enter") && this.chatPrompt.value){
- this.client.socket.emit("chatMessage",{msg: this.chatPrompt.value});
+ this.commandPreprocessor.preprocess(this.chatPrompt.value);
this.chatPrompt.value = "";
}
}
diff --git a/www/js/channel/chatPreprocessor.js b/www/js/channel/chatPreprocessor.js
index b434fcd..74601f8 100644
--- a/www/js/channel/chatPreprocessor.js
+++ b/www/js/channel/chatPreprocessor.js
@@ -23,7 +23,7 @@ class chatPreprocessor{
//Create an empty array to hold the body
this.bodyArray = [];
//Split string by words
- const splitString = this.chatBody.innerHTML.split(/(\W)+/g); //Group not-words together
+ const splitString = this.chatBody.innerHTML.split(/\b/g); //Group words together
//for each word in the splitstring
splitString.forEach((string) => {
@@ -61,9 +61,9 @@ class chatPreprocessor{
//this.bodyArray[index].string = wordObj.string.split("").join("ㅤ");
this.bodyArray[wordIndex].string.split("").forEach((char, charIndex) => {
wordArray.push(char);
- //Every eight characters
- if(charIndex != 0 && charIndex % 8 == 0){
- //Push an invisible line-break character
+ //After eight characters
+ if(charIndex > 8){
+ //Push an invisible line-break character between every character
wordArray.push("ㅤ");
}
diff --git a/www/js/channel/commandPreprocessor.js b/www/js/channel/commandPreprocessor.js
new file mode 100644
index 0000000..1c067b5
--- /dev/null
+++ b/www/js/channel/commandPreprocessor.js
@@ -0,0 +1,66 @@
+class commandPreprocessor{
+ constructor(client){
+ this.client = client;
+ this.commandProcessor = new commandProcessor(client);
+ }
+
+ preprocess(command){
+ //Set command and sendFlag
+ this.command = command;
+ this.sendFlag = true;
+
+ this.splitBody();
+ this.processLocalCommand();
+ this.sendRemoteCommand();
+ }
+
+ splitBody(){
+ //Create an empty array to hold the command
+ this.commandArray = [];
+ //Split string by words
+ const splitString = this.command.split(/\b/g); //Group words together
+
+ //for each word in the splitstring
+ splitString.forEach((string) => {
+ //Add it to our command array
+ this.commandArray.push(string);
+ });
+ }
+
+ processLocalCommand(){
+ //If this is a local command
+ if(this.commandArray[0] == '/'){
+ //If the command exists
+ if(this.commandProcessor[this.commandArray[1]] != null){
+ //Don't send it to the server
+ this.sendFlag = false;
+
+ this.commandProcessor[this.commandArray[1]](this.commandArray);
+ }
+ }
+ }
+
+ sendRemoteCommand(){
+ if(this.sendFlag){
+ this.client.socket.emit("chatMessage",{msg: this.commandArray.join("")});
+ }
+ }
+
+
+}
+
+class commandProcessor{
+ constructor(client){
+ this.client = client
+ }
+
+ high(commandArray){
+ //If we have an argument
+ if(commandArray[3]){
+ //Use it to set our high level
+ //Technically this is less of a local command than it would be if it where telling the select to do this
+ //but TTN used to treat this as a local command so fuck it
+ this.client.socket.emit("setHighLevel", {highLevel: commandArray[3]});
+ }
+ }
+}
\ No newline at end of file