diff --git a/src/main/resources/static/javascript/script-editor.js b/src/main/resources/static/javascript/script-editor.js index 6210c47..13a1832 100644 --- a/src/main/resources/static/javascript/script-editor.js +++ b/src/main/resources/static/javascript/script-editor.js @@ -5,3 +5,27 @@ editor.session.setMode("ace/mode/lua"); // set script body // editor.setValue(jobj.scriptBody); +const snippets = ["player", "players[index]", "genders[index]", "hobbies[index]", "healths[index]", "luggages[index]", "works[index]"]; + +$.urlParam = function(name){ + var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href); + if (results==null) { + return null; + } + return decodeURI(results[1]) || 0; +}; + +function pasteSnippet(index) { + editor.insert(snippets[index]); +} + +function getActionScript() { + $.post("/api/edit_entry", "section="+_ss+"&entry_id="+($.urlParam("script_id")), function(data, status) { + var jobj = JSON.parse(data); + editor.setValue(jobj.scriptBody); + }); +} + +if ($.urlParam("script_id") != "-1") { + getActionScript(); +} \ No newline at end of file diff --git a/src/main/resources/templates/script-editor.html b/src/main/resources/templates/script-editor.html index 19dd980..7ce3daf 100644 --- a/src/main/resources/templates/script-editor.html +++ b/src/main/resources/templates/script-editor.html @@ -11,14 +11,17 @@
Below is an example form built entirely with Bootstrap's form controls. Each required form group has a validation state that can be triggered by attempting to submit the form without completing it.
+Below you can write a script for Bunker's action card. On the left side you will find code snippets, that will help with it. Happy coding!