-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You can now add, edit and remove commands from the admin section.
- Loading branch information
Showing
9 changed files
with
166 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
var create = document.getElementsByClassName("create"); | ||
var remove = document.getElementsByClassName("remove"); | ||
var edit = document.getElementsByClassName("edit"); | ||
var update = document.getElementById("update") | ||
var add = document.getElementById("add") | ||
var socket = io.connect(); | ||
|
||
for (var i = 0; i < create.length; i++) { | ||
create[i].addEventListener('click', function() { | ||
window.location.href = "/admin/commands/create" | ||
}, false); | ||
} | ||
|
||
for (var i = 0; i < remove.length; i++) { | ||
remove[i].addEventListener('click', function() { | ||
var comm = this.id | ||
socket.emit('removeComm', comm) | ||
alert("Succesfully removed the following command: " + comm) | ||
window.location.reload() | ||
}, false); | ||
} | ||
|
||
for (var i = 0; i < edit.length; i++) { | ||
edit[i].addEventListener('click', function() { | ||
window.location.href = "/admin/commands/edit/" + this.id | ||
}, false); | ||
} | ||
|
||
if (update) { | ||
update.addEventListener('click', function() { | ||
var updatedComm = { | ||
commName: window.location.href.split("/").pop(), | ||
response: document.getElementById('response').value, | ||
level: document.getElementById('level').value, | ||
cdType: document.getElementById('cdType').value, | ||
cd: document.getElementById('cd').value | ||
} | ||
socket.emit('updateComm', updatedComm) | ||
window.location.href = "/admin/commands" | ||
}, false); | ||
} | ||
|
||
if (add) { | ||
add.addEventListener('click', function() { | ||
var newComm = { | ||
commName: document.getElementById('command').value, | ||
response: document.getElementById('response').value, | ||
level: document.getElementById('level').value, | ||
cdType: document.getElementById('cdType').value, | ||
cd: document.getElementById('cd').value | ||
} | ||
socket.emit('addCom', newComm) | ||
window.location.href = "/admin/commands" | ||
}, false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<% include adminheader.ejs %> | ||
<div class="top"><h1>Add command</h1></div> | ||
<div class="search"><input id="searchBar" type="text"></div> | ||
<div class="main"> | ||
<p> | ||
Command: <input type="text" id="command" size=10 value="!"> <br> | ||
Response: <input type="text" id="response" size=100> <br> | ||
Level: <input type="number" min=100 max=500 size=3 id="level" value=100> <br> | ||
Cooldown type: <select id="cdType"><option value="global" selected>Global</option><option value="user">User</option></select> <br> | ||
Cooldown: <input type="number" min=1 max=3600 size=4 id="cd" value=10> <br> | ||
</p> | ||
<button id="add">Submit</button> | ||
</div> | ||
<script type="text/javascript" src="/../js/yucisite.js"></script> | ||
<script type="text/javascript" src="/../js/commands.js"></script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<% include adminheader.ejs %> | ||
<div class="top"><h1>Manage commands</h1></div> | ||
<div class="search"><input id="searchBar" type="text"></div> | ||
<div class="main"> | ||
<p><button class="create">Create command</button></p> | ||
<% commands.forEach(function(commands) { %> | ||
<div class="commands"><p> | ||
<b>Command:</b> <%= commands.commName %> <br> | ||
<% if (commands.commDesc != null) { %> <b>Description:</b> <%= commands.commDesc %> <br> <% } %> | ||
<% if (commands.response != null) { %><b>Response:</b> <%= commands.response %> <br> <% } %> | ||
<% if (commands.commUse != null) { %> <b>Usage:</b><br> <%= commands.commUse %> <br> <% } %> | ||
<b>Cooldown type:</b> <%= commands.cdType %> <br> | ||
<b>Cooldown:</b> <%= commands.cd %> seconds <br> | ||
<b>User level:</b> <%= commands.level %> <br> | ||
<button class="remove" id=<%= commands.commName %>>Remove command</button> <button class="edit" id=<%= commands.commName %>>Edit command</button> | ||
</p></div> | ||
<% }) %> | ||
</div> | ||
<script type="text/javascript" src="/../js/yucisite.js"></script> | ||
<script type="text/javascript" src="/../js/commands.js"></script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<% include adminheader.ejs %> | ||
<div class="top"><h1>Edit command</h1></div> | ||
<div class="search"><input id="searchBar" type="text"></div> | ||
<div class="main"> | ||
<% if (commands[0] != undefined) { %> | ||
<p> | ||
Command: <%= commands[0].commName %> <br> | ||
Response: <input type="text" id="response" size=100 value="<%= commands[0].response %>"> <br> | ||
Level: <input type="number" min=100 max=500 size=3 id="level" value=<%= commands[0].level %>> <br> | ||
Cooldown type: <select id="cdType"><option value="global" selected>Global</option><option value="user">User</option></select> <br> | ||
Cooldown: <input type="number" min=1 max=3600 size=4 id="cd" value=<%= commands[0].cd %>> <br> | ||
</p> | ||
<button id="update">Submit</button> | ||
<% } else { %> | ||
<p>Couldn't find a command with that name. Please try again</p> | ||
<% } %> | ||
</div> | ||
<script type="text/javascript" src="/../js/yucisite.js"></script> | ||
<script type="text/javascript" src="/../js/commands.js"></script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters