diff options
Diffstat (limited to 'modules-available/usblockoff/templates/usb-edit-rule.html')
-rw-r--r-- | modules-available/usblockoff/templates/usb-edit-rule.html | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/modules-available/usblockoff/templates/usb-edit-rule.html b/modules-available/usblockoff/templates/usb-edit-rule.html new file mode 100644 index 00000000..ec14d5ab --- /dev/null +++ b/modules-available/usblockoff/templates/usb-edit-rule.html @@ -0,0 +1,82 @@ +<form method="post" action="?do=usblockoff" id="editRuleForm"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="editRule"> + <input type="hidden" name="configid" value="{{configid}}" id="configid"> + <input type="hidden" name="attributes" value="" id="attributes"> + + <div class="panel panel-default"> + <div class="panel-heading">{{lang_editRules}}</div> + <div class="panel-body"> + <div class="list-group"> + + {{#attributes}} + {{{attributesHtml}}} + {{/attributes}} + + </div> + </div> + </div> + + <div class="pull-right"> + <a href="?do=usblockoff&show=edit-config&configid={{configid}}" class="btn btn-default">Cancel</a> + + <button id="addButton" class="btn btn-primary" type="submit"> + <span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}} + </button> + </div> + +</form> + +<script> + var idArray = {{{usbJson}}}; + + document.addEventListener("DOMContentLoaded", function(event) { + $('.switch-input').click(function() { + var $op = $(this).parent().find('select'); + var val = $op.val(); + $op.replaceWith($('<input class="form-control" type="text">').attr('name', $op.attr('name')).val(val)); + }); + + var vid = $('#prop-vid').val(); + var pid = $('#prop-pid').val(); + $('#prop-vid').empty(); + + + $('[id^="prop-"]').change(function () { + updateAttributes(); + }); + + $('#prop-vid').change(function () { + var $this = $(this); + var vid = $this.val(); + var pid = $('#prop-pid').val(); + $('#prop-pid').empty(); + $.each(idArray[vid]['products'], function(key, value) { + $('#prop-pid').append($('<option></option>').val(key).html(value)); + }); + $("#prop-pid").val(pid); + }); + + $.each(idArray, function(key, value) { + $('#prop-vid').append($('<option></option>').val(key).html(value['name'])); + }); + + $("#prop-vid").val(vid); + $("#prop-vid").change(); + }); + + function updateAttributes() { + var attributes = []; + + $.each($('[id^="prop-"]'), function () { + var attr = {}; + attr['prop'] = $(this).attr('id'); + attr['value'] = $(this).val(); + + attributes.push(attr); + }); + $('#attributes').val(JSON.stringify(attributes)); + } + + +</script> |