Skip to content

Commit

Permalink
i did a thing that actually works, wow lol
Browse files Browse the repository at this point in the history
  • Loading branch information
MattheousDT committed Jul 3, 2018
1 parent 6084b2f commit b709036
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
61 changes: 44 additions & 17 deletions src/web/templates/dashboard/userscripts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@
<main>
<div class="col-12 mb-5">
<div class="row">
<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 class="accordion col-md-6 col-sm-12 pb-4" id="accordionEx" role="tablist" aria-multiselectable="true"></div>
<div class="col-md-6 col-sm-12">
<div id="advancedEditor" style="width:100%; height:600px"></div>
<button type="button" id="updateCode" class="btn btn-info float-right">Update</button>
</div>
</div>
</main>

Expand All @@ -109,7 +112,7 @@
</div>-->

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

</body>
<!--/.Footer-->

<!-- SCRIPTS -->
Expand Down Expand Up @@ -289,7 +292,8 @@
const editor = monaco.editor.create(document.getElementById('advancedEditor'), {
value: [].join('\n'),
language: 'javascript',
theme: "MattIsTrueWaifu"
theme: "MattIsTrueWaifu",
automaticLayout: true
});
const req = new XMLHttpRequest();
Expand Down Expand Up @@ -353,28 +357,51 @@
);
document.getElementById(`${script._id}-clicker`).onclick = () => {
if(document.getElementById(`${script._id}`).classList.contains("show")) {
if (document.getElementById(`${script._id}`).classList.contains("show")) {
return;
}
current_id = script._id;
editor.setValue(script.code);
};
};
let current_id = "rawrxd";
document.getElementById("updateCode").onclick = () => {
const upd = new XMLHttpRequest();
upd.open("PATCH", `/api/v3/scripts/@me/${current_id}`, false);
upd.setRequestHeader("Content-Type", "application/json");
upd.send(JSON.stringify({ code: editor.getValue() }));
const upd_res = JSON.parse(upd.response);
if (upd_res.status === 200) {
// success
toastr["success"]("Script updated successfully");
} else {
// failure
toastr["error"](typeof upd_res.error === "string" ? upd_res.error : `${upd_res.status} - ${upd_res.message}`);
}
}
});
</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()
}) */
$("#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>|

Expand Down

0 comments on commit b709036

Please sign in to comment.