blob: 296d3bf730c21edf592b6b906a1a6baa816105ff (
plain) (
tree)
|
|
<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="ruleid" value="{{ruleid}}" id="ruleid">
<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>
|