diff --git a/dencoder.js b/dencoder.js index 158ebd2..2d7c18a 100644 --- a/dencoder.js +++ b/dencoder.js @@ -56,8 +56,9 @@ } } ]; + var optiontemplate = ""; - var template = "
" + var template = "
" + "
"; @@ -109,30 +110,26 @@ $output = $(template.replace(/\{index\}/g, "" + outputIndex).replace(/\{content\}/g, output)); $("body").append($output); } else { - $output.val(output); + $output.val(output); + update($output); } - - clean(outputIndex); } - 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); + 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); + } } var den = {}; den.convert = convert; + den.update = update; window.den = window.den || den; })(jQuery);