From fef5855bd63d8c7033e2d2d48e2d478d3f632580 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 14 Nov 2016 17:13:52 +0100 Subject: Provide basic UI for template-testing Still leaves a lot to be desired, but is a good start. References #151 --- web/js/nms-template.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 web/js/nms-template.js (limited to 'web/js/nms-template.js') diff --git a/web/js/nms-template.js b/web/js/nms-template.js new file mode 100644 index 0000000..cad92b0 --- /dev/null +++ b/web/js/nms-template.js @@ -0,0 +1,37 @@ +"use strict"; + +var nmsTemplate = nmsTemplate || { + +} + +nmsTemplate.test = function() { + var input = document.getElementById("template-input"); + var output = document.getElementById("template-output"); + $.ajax({ + type: "POST", + url: "/api/templates/test", + async: false, + data: input.value, + dataType: "text", + success: function (indata, textStatus, jqXHR) { + var output = document.getElementById("template-output"); + output.value = indata; + } + }); +} + +nmsTemplate.fromFile = function(template) { + var input = document.getElementById("template-input"); + var output = document.getElementById("template-output"); + $.ajax({ + type: "GET", + url: "/templates/" + template, + async: false, + data: input.value, + dataType: "text", + success: function (indata, textStatus, jqXHR) { + var output = document.getElementById("template-input"); + output.value = indata; + } + }); +} -- cgit v1.2.3