Add eggs, as well as example egg and config
This commit is contained in:
parent
23fc71bd45
commit
7ff5447388
1
server/chookchat.eggs.config
Normal file
1
server/chookchat.eggs.config
Normal file
|
@ -0,0 +1 @@
|
||||||
|
notepad
|
4
server/eggs/notepad/index.html
Normal file
4
server/eggs/notepad/index.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="egg" id="egg-notepad" style="display: none;">
|
||||||
|
<button id="egg-notepad-close" class="redbutton" onclick="closeEggNotepad()">Close</button><br>
|
||||||
|
<textarea id="egg-notepad-textarea" placeholder="Start typing..." style="height: 500px"></textarea>
|
||||||
|
</div>
|
21
server/eggs/notepad/index.js
Normal file
21
server/eggs/notepad/index.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
function eggNotepad() {
|
||||||
|
const eggsList = document.getElementById("eggs-list");
|
||||||
|
eggsList.style.display = "none";
|
||||||
|
const eggNotepad = document.getElementById("egg-notepad");
|
||||||
|
eggNotepad.style.display = "block";
|
||||||
|
const eggNotepadTextArea = document.getElementById("egg-notepad-textarea");
|
||||||
|
eggNotepadTextArea.addEventListener('input', function(event) {
|
||||||
|
const eggNotepadMessage = {
|
||||||
|
"type": "egg-notepad",
|
||||||
|
"username": username,
|
||||||
|
"token": md5(password),
|
||||||
|
"content": event.target.value
|
||||||
|
};
|
||||||
|
ws.send(JSON.stringify(eggNotepadMessage));
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeEggNotepad() {
|
||||||
|
const eggNotepad = document.getElementById("egg-notepad");
|
||||||
|
eggNotepad.style.display = "none";
|
||||||
|
}
|
4
server/eggs/notepad/message.js
Normal file
4
server/eggs/notepad/message.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
else if (message.type == "egg-notepad") {
|
||||||
|
const eggNotepadTextArea = document.getElementById("egg-notepad-textarea");
|
||||||
|
eggNotepadTextArea.value = message.content
|
||||||
|
}
|
|
@ -34,6 +34,10 @@ object config {
|
||||||
var serviceName = ""
|
var serviceName = ""
|
||||||
|
|
||||||
fun getConfig() {
|
fun getConfig() {
|
||||||
|
address = ""
|
||||||
|
port = ""
|
||||||
|
security = ""
|
||||||
|
serviceName = ""
|
||||||
val configFile = File("chookchat.config")
|
val configFile = File("chookchat.config")
|
||||||
try {
|
try {
|
||||||
val config = configFile.readLines()
|
val config = configFile.readLines()
|
||||||
|
@ -395,10 +399,21 @@ fun buildHTML(): String {
|
||||||
editedhtml += """ <input type="checkbox" id="securityStatus">"""
|
editedhtml += """ <input type="checkbox" id="securityStatus">"""
|
||||||
} else if (line == """ <h3>Chookchat</h3>""") {
|
} else if (line == """ <h3>Chookchat</h3>""") {
|
||||||
editedhtml += """ <h3>${config.serviceName}</h3>"""
|
editedhtml += """ <h3>${config.serviceName}</h3>"""
|
||||||
|
} else if (line == """ <!-- Eggs Start Here -->""") {
|
||||||
|
val eggsFile = File("chookchat.eggs.config")
|
||||||
|
val eggs = eggsFile.readLines()
|
||||||
|
for (line in eggs) {
|
||||||
|
val eggHTMLFile = File("eggs/$line/index.html")
|
||||||
|
if (eggHTMLFile.exists()) {
|
||||||
|
val eggHTML = eggHTMLFile.readText()
|
||||||
|
editedhtml += eggHTML
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
editedhtml += line
|
editedhtml += line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(editedhtml)
|
return(editedhtml)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
println(e)
|
println(e)
|
||||||
|
@ -407,6 +422,42 @@ fun buildHTML(): String {
|
||||||
return("dingus")
|
return("dingus")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun buildJS(): String {
|
||||||
|
try {
|
||||||
|
val eggsFile = File("chookchat.eggs.config")
|
||||||
|
val eggs = eggsFile.readLines()
|
||||||
|
val jsFile = File("resources/index.js")
|
||||||
|
val js = jsFile.readLines()
|
||||||
|
var editedJS = ""
|
||||||
|
for (line in js) {
|
||||||
|
if (line == " // Egg message logic") {
|
||||||
|
for (line in eggs) {
|
||||||
|
val eggJSMessageFile = File("eggs/$line/message.js")
|
||||||
|
if (eggJSMessageFile.exists()) {
|
||||||
|
val eggJSMessage = eggJSMessageFile.readText()
|
||||||
|
editedJS += eggJSMessage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
editedJS += "$line\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//editedJS += js
|
||||||
|
for (line in eggs) {
|
||||||
|
val eggJSFile = File("eggs/$line/index.js")
|
||||||
|
if (eggJSFile.exists()) {
|
||||||
|
val eggJS = eggJSFile.readText()
|
||||||
|
editedJS += eggJS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(editedJS)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e)
|
||||||
|
return("console.log(`There was an error! If you're the server's admin, here are the details: $e`)")
|
||||||
|
}
|
||||||
|
return("dingus")
|
||||||
|
}
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
WsSessionManager.peopleOnline.removeAt(0)
|
WsSessionManager.peopleOnline.removeAt(0)
|
||||||
WsSessionManager.sessionsList.removeAt(0)
|
WsSessionManager.sessionsList.removeAt(0)
|
||||||
|
@ -416,6 +467,9 @@ fun main(args: Array<String>) {
|
||||||
ctx.html(buildHTML())
|
ctx.html(buildHTML())
|
||||||
//ctx.redirect("/index.html")
|
//ctx.redirect("/index.html")
|
||||||
}
|
}
|
||||||
|
.get("/index.js") { ctx ->
|
||||||
|
ctx.result(buildJS())
|
||||||
|
}
|
||||||
.get("/api/createaccount/{content}") { ctx -> ctx.result(createAccount(ctx.pathParam("content")))}
|
.get("/api/createaccount/{content}") { ctx -> ctx.result(createAccount(ctx.pathParam("content")))}
|
||||||
.post("/api/upload") { ctx ->
|
.post("/api/upload") { ctx ->
|
||||||
val uploadedFiles = ctx.uploadedFiles()
|
val uploadedFiles = ctx.uploadedFiles()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user