aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/nms-template.js
blob: c34ef34d5a863f5f260a68ca213cfb26a35bf673 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"use strict";

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;
		}
	});
}

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();
}