I have written a jQuery script. This should, as I've thought it, take the number of templateTotal
(the total number of Templates which exist on USB) from the JSON and generate as many buttons, as templateTotal
indicates.
For example if templateTotal
is 6, then the script should generate 6 buttons.
(function poll() {
setTimeout(function () {
$.ajax({
type: "GET",
url: "/api/status",
processData: true,
dataType: 'text',
cache: false,
success: function (data, textStatus, request) {
var template = jQuery.parseJSON(data);
var templateButton = "";
for (i = 1; i > templateTotal; i++);
templateButton += '<button class="templateButton" id="T' + i + '" formaction="/api/template" post="template=' + i + '">T' + i + '</button>'
},
complete: poll
});
});
})();