aboutsummaryrefslogtreecommitdiffstats
path: root/web/js
diff options
context:
space:
mode:
authorroot <root@colazero.tele.tg18.gathering.org>2018-03-22 02:15:07 +0100
committerroot <root@colazero.tele.tg18.gathering.org>2018-03-22 02:15:07 +0100
commit9ddfd86b4f54ba3f178fde9f8cb959baa02da718 (patch)
tree0cf1e0b1e2c04d2180a343e31da9ee07d35c097f /web/js
parent05e09f3b63269a48d1beb0dc9900b180101cec7f (diff)
Commit diverse av Ole Mathias sitt template-greier
Diffstat (limited to 'web/js')
-rw-r--r--web/js/nms-template.js76
1 files changed, 47 insertions, 29 deletions
diff --git a/web/js/nms-template.js b/web/js/nms-template.js
index c34ef34..6159f5b 100644
--- a/web/js/nms-template.js
+++ b/web/js/nms-template.js
@@ -4,36 +4,54 @@ var nmsTemplate = nmsTemplate || {
}
nmsTemplate.test = function() {
- var input = document.getElementById("template-input");
- var output = document.getElementById("template-output");
- var qp = document.getElementById("template-query-params");
- $.ajax({
- type: "POST",
- url: "/api/templates/test" + qp.value,
- async: false,
- data: input.value,
- dataType: "text",
- success: function (indata, textStatus, jqXHR) {
- var output = document.getElementById("template-output");
- output.value = jqXHR.responseText;
- },
- error: function (jqXHR, textStatus) {
- var output = document.getElementById("template-output");
- output.value = jqXHR.responseText;
- }
- });
+ var input = document.getElementById("template-input");
+ var output = document.getElementById("template-output");
+ var qp = document.getElementById("template-query-params");
+ $.ajax({
+ type: "POST",
+ url: "/api/templates/test" + qp.value,
+ async: false,
+ data: input.value,
+ dataType: "text",
+ success: function (indata, textStatus, jqXHR) {
+ var output = document.getElementById("template-output");
+ output.value = jqXHR.responseText;
+ },
+ error: function (jqXHR, textStatus) {
+ var output = document.getElementById("template-output");
+ output.value = jqXHR.responseText;
+ }
+ });
}
nmsTemplate.fromFile = function(template) {
- $.ajax({
- type: "GET",
- url: "/templates/" + template,
- async: false,
- dataType: "text",
- success: function (indata, textStatus, jqXHR) {
- var output = document.getElementById("template-input");
- output.value = indata;
- }
- });
- nmsTemplate.test();
+ if(template == '') { return; }
+ $.ajax({
+ type: "GET",
+ url: "/templates/" + template,
+ async: false,
+ dataType: "text",
+ success: function (indata, textStatus, jqXHR) {
+ var output = document.getElementById("template-input");
+ output.value = indata;
+ }
+ });
+ nmsTemplate.test();
}
+
+nmsTemplate.getTemplates = function() {
+ $.ajax({
+ type: "GET",
+ url: "/api/read/template-list",
+ async: false,
+ dataType: "json",
+ success: function (indata, textStatus, jqXHR) {
+ console.log(indata['templates']);
+ $.each( indata['templates'], function( value ) {
+ $('#nmsTemplate-select').append($("<option></option>").attr("value",indata['templates'][value]['file']).text(indata['templates'][value]['file']));
+ });
+ }
+ });
+}
+
+nmsTemplate.getTemplates();