Skip to content

Commit

Permalink
some vs code shit
Browse files Browse the repository at this point in the history
  • Loading branch information
MattheousDT committed Jul 3, 2018
1 parent 5799872 commit 6084b2f
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 93 deletions.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
16 changes: 8 additions & 8 deletions src/web/routes/api/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,19 @@ router.route("/@me/:object_id").get(authUser, async (req, res) => {
const match_type = req.body.match_type === undefined ? null : req.body.match_type;
const code = req.body.code === undefined ? null : req.body.code;

if (type !== null && type !== "js" && type !== "basic") {
if (type !== null && (type !== "js" && type !== "basic")) {
return res.json({ status: 400, message: "Bad Request", error: "Type needs to be either js or basic" });
}

if (permissions !== null && isNaN(parseInt(permissions)) === true) {
return res.json({ status: 400, message: "Bad Request", error: "Permissions needs to be a number" });
}

if (match !== null && typeof match !== "string" || match.length === 0) {
if (match !== null && (typeof match !== "string" || match.length === 0)) {
return res.json({ status: 400, message: "Bad Request", error: "Match cannot be 0 length" });
}

if (match_type !== null && match_type !== "command" && match_type !== "startswith" && match_type !== "contains" && match_type !== "exactmatch") {
if (match_type !== null && (match_type !== "command" && match_type !== "startswith" && match_type !== "contains" && match_type !== "exactmatch")) {
return res.json({ status: 400, message: "Bad Request", error: "Match type needs to be either command, startswith, contains or exactmatch" });
}

Expand Down Expand Up @@ -432,27 +432,27 @@ router.route("/:object_id").get(authAdmin, async (req, res) => {
const match_type = req.body.match_type === undefined ? null : req.body.match_type;
const code = req.body.code === undefined ? null : req.body.code;

if (local !== null && local !== true && local !== false) {
if (local !== null && (local !== true && local !== false)) {
return res.json({ status: 400, message: "Bad Request", error: "Local needs to be a boolean" });
}

if (local !== null && local === false && code === null) {
if (local !== null && (local === false && code === null)) {
return res.json({ status: 400, message: "Bad Request", error: "Code needs to be specified if local is set to false" });
}

if (type !== null && type !== "js" && type !== "basic") {
if (type !== null && (type !== "js" && type !== "basic")) {
return res.json({ status: 400, message: "Bad Request", error: "Type needs to be either js or basic" });
}

if (permissions !== null && isNaN(parseInt(permissions)) === true) {
return res.json({ status: 400, message: "Bad Request", error: "Permissions needs to be a number" });
}

if (match !== null && typeof match !== "string" || match.length === 0) {
if (match !== null && (typeof match !== "string" || match.length === 0)) {
return res.json({ status: 400, message: "Bad Request", error: "Match cannot be 0 length" });
}

if (match_type !== null && match_type !== "command" && match_type !== "startswith" && match_type !== "contains" && match_type !== "exactmatch") {
if (match_type !== null && (match_type !== "command" && match_type !== "startswith" && match_type !== "contains" && match_type !== "exactmatch")) {
return res.json({ status: 400, message: "Bad Request", error: "Match type needs to be either command, startswith, contains or exactmatch" });
}

Expand Down
179 changes: 94 additions & 85 deletions src/web/templates/dashboard/userscripts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,16 @@
<main>
<div class="col-12 mb-5">
<div class="row">
<div class="accordion col-12" id="accordionEx" role="tablist" aria-multiselectable="true">

</div>
<div class="accordion col-6" id="accordionEx" role="tablist" aria-multiselectable="true"></div>
<div id="advancedEditor" class="col-6" style="width: 100%; height:600px"></div>
</div>
</main>

<!-- Central Modal Small -->
<!-- Central Modal Small
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div id="editorHolder" class="modal-dialog modal-lg" role="document">
</div>
</div>
</div>-->

<%- include ../partials/footer.ejs %>

Expand Down Expand Up @@ -153,70 +152,6 @@
})
</script>

<script>
"use strict";
const req = new XMLHttpRequest();
req.open("GET", "/api/v3/scripts/@me", false);
req.send();
const scripts = $("#accordionEx");
for (let script of JSON.parse(req.response)) {
scripts.append(
`
<div class="card">
<div class="card-header" role="tab" id="headingOne">
<a data-toggle="collapse" href="#${script._id}" aria-expanded="false" aria-controls="collapseOne">
<h5 class="mb-0 black-text">
${script.name}
<i class="fa fa-angle-down rotate-icon"></i>
</h5>
</a>
</div>
<!-- Card body -->
<div id="${script._id}" class="collapse" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordionEx">
<div class="card-body">
<!--Table-->
<table class="table">
<col width="25%">
<col width="35%">
<col width="25%">
<col width="15%">
<!--Table head-->
<thead class="feinwaru white-text">
<tr>
<th>Command</th>
<th>Description</th>
<th>Type</th>
<th></th>
</tr>
</thead>
<!--Table head-->
<!--Table body-->
<tbody>
<tr>
<td>${script.match}</td>
<td>${script.description}</th>
<td>${script.type}</td>
<td class="text-right">
<a id="edit" type="button" class="btn-floating orange"><i class="fa fa-pencil" aria-hidden="true" data-toggle="modal" data-target="#editModal"></i></a>
<a type="button" class="btn-floating red"><i class="fa fa-trash" aria-hidden="true"></i></a>
</td>
</tr>
</tbody>
<!--Table body-->
</table>
<!--Table-->
</div>
</div>
</div>`
);
};
</script>
<script src="/monaco/min/vs/loader.js"></script>
<script>
require.config({
Expand Down Expand Up @@ -351,22 +286,96 @@
"titleBar.inactiveForeground": "#6B717D"
}
});
const editor = monaco.editor.create(document.getElementById('advancedEditor'), {
value: [].join('\n'),
language: 'javascript',
theme: "MattIsTrueWaifu"
});
const req = new XMLHttpRequest();
req.open("GET", "/api/v3/scripts/@me", false);
req.send();
const scripts = $("#accordionEx");
for (let script of JSON.parse(req.response)) {
scripts.append(
`
<div class="card">
<div class="card-header" role="tab" id="headingOne">
<a id="${script._id}-clicker" data-toggle="collapse" href="#${script._id}" aria-expanded="false" aria-controls="collapseOne">
<h5 class="mb-0 black-text">
${script.name}
<i class="fa fa-angle-down rotate-icon"></i>
</h5>
</a>
</div>
<!-- Card body -->
<div id="${script._id}" class="collapse" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordionEx">
<div class="card-body">
<!--Table-->
<table class="table">
<col width="25%">
<col width="35%">
<col width="15%">
<col width="25%">
<!--Table head-->
<thead class="feinwaru white-text">
<tr>
<th>Command</th>
<th>Description</th>
<th>Type</th>
<th></th>
</tr>
</thead>
<!--Table head-->
<!--Table body-->
<tbody>
<tr>
<td>${script.match}</td>
<td>${script.description}</th>
<td>${script.type}</td>
<td class="text-right">
<a type="button" class="btn-floating btn-sm red"><i class="fa fa-trash" aria-hidden="true"></i></a>
</td>
</tr>
</tbody>
<!--Table body-->
</table>
<!--Table-->
</div>
</div>
</div>
`
);
document.getElementById(`${script._id}-clicker`).onclick = () => {
if(document.getElementById(`${script._id}`).classList.contains("show")) {
return;
}
editor.setValue(script.code);
};
};
});
$("#editModal").on("shown.bs.modal", e => {
$("#editorHolder").append(`<div id="advancedEditor" style="width: 100%; height:600px"></div>`)
var editor = monaco.editor.create(document.getElementById('advancedEditor'), {
value: [].join('\n'),
language: 'javascript',
theme: "MattIsTrueWaifu"
})
})
$("#editModal").on("hidden.bs.modal", e => {
$("#advancedEditor").remove()
})
</script>
</body>
</script>
<script>
/* $("#editModal").on("shown.bs.modal", e => {
$("#editorHolder").append(`<div id="advancedEditor" class="card" style="width: 100%; height:600px"></div>`)
var editor = monaco.editor.create(document.getElementById('advancedEditor'), {
value: [].join('\n'),
language: 'javascript',
theme: "MattIsTrueWaifu"
})
})
$("#editModal").on("hidden.bs.modal", e => {
$("#advancedEditor").remove()
}) */
</script>
</body>|

</html>

0 comments on commit 6084b2f

Please sign in to comment.