update the whole chain upon changes and also when the conversion method
changes
This commit is contained in:
parent
c2d9dc9e38
commit
0996aee7a7
1 changed files with 15 additions and 18 deletions
31
dencoder.js
31
dencoder.js
|
@ -56,8 +56,9 @@
|
|||
}
|
||||
}
|
||||
];
|
||||
|
||||
var optiontemplate = "<option name='{identifier}'>{name}</option>";
|
||||
var template = "<div id='wrapper-{index}' class='wrapper'><textarea id='input-{index}' class='input'>{content}</textarea>"
|
||||
var template = "<div id='wrapper-{index}' class='wrapper'><textarea id='input-{index}' class='input' onchange='den.update(this);'>{content}</textarea>"
|
||||
+ "<select id='type-{index}' class='conversion' onchange='den.convert(this);'>"
|
||||
+ "{options}"
|
||||
+ "</select></div>";
|
||||
|
@ -110,29 +111,25 @@
|
|||
$("body").append($output);
|
||||
} else {
|
||||
$output.val(output);
|
||||
update($output);
|
||||
}
|
||||
}
|
||||
|
||||
clean(outputIndex);
|
||||
function update(textarea) {
|
||||
var $textarea = $(textarea);
|
||||
var areaid = $textarea.attr("id");
|
||||
var inputindex = +areaid.split("-")[1];
|
||||
var $select = $("#type-" + inputindex);
|
||||
var conversion = $select.find(":selected").attr("name");
|
||||
var plugin = getPluginById(conversion);
|
||||
if (plugin !== null) {
|
||||
convert($select);
|
||||
}
|
||||
|
||||
function clean(index) {
|
||||
var found = true;
|
||||
var $wrapper;
|
||||
$("#type-" + index + " option[name=CHOOSE]").prop("selected", true);
|
||||
index++;
|
||||
do {
|
||||
$wrapper = $("#wrapper-" + index);
|
||||
if ($wrapper.length > 0) {
|
||||
$wrapper.remove();
|
||||
index++;
|
||||
} else {
|
||||
found = false;
|
||||
}
|
||||
} while (found);
|
||||
}
|
||||
|
||||
var den = {};
|
||||
den.convert = convert;
|
||||
den.update = update;
|
||||
window.den = window.den || den;
|
||||
|
||||
})(jQuery);
|
||||
|
|
Loading…
Reference in a new issue