diff options
author | Git <git@what.cd> | 2012-11-14 08:00:19 +0000 |
---|---|---|
committer | Git <git@what.cd> | 2012-11-14 08:00:19 +0000 |
commit | d3fa17b905c43693b55609dbb0bad18ac985f0de (patch) | |
tree | 4e9b99e8a051318cf058ead1230230ba4142c335 /static/functions/multiformat_uploader.js | |
parent | a26061ad5c6b3fb34918964d1d334a43d70344cc (diff) | |
download | Gazelle-d3fa17b905c43693b55609dbb0bad18ac985f0de.zip Gazelle-d3fa17b905c43693b55609dbb0bad18ac985f0de.tar.gz Gazelle-d3fa17b905c43693b55609dbb0bad18ac985f0de.tar.bz2 |
Empty commit
Diffstat (limited to 'static/functions/multiformat_uploader.js')
-rw-r--r-- | static/functions/multiformat_uploader.js | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/static/functions/multiformat_uploader.js b/static/functions/multiformat_uploader.js new file mode 100644 index 0000000..9730156 --- /dev/null +++ b/static/functions/multiformat_uploader.js @@ -0,0 +1,114 @@ +(function ($) { + var count = 1; + var MAX_EXTRAS = 5; + var FORMATS = [ 'MP3', 'FLAC', 'Ogg Vorbis', 'AAC', 'AC3', 'DTS' ]; + var BITRATES = [ '192', 'APS (VBR)', 'V2 (VBR)', 'V1 (VBR)', '256', 'APX (VBR)', 'V0 (VBR)', 'q8.x (VBR)', '320', 'Lossless', '24bit Lossless']; + var filenames = new Array(); + $(document).ready(function () { + $("#add_format").click(function () { + createRow(); + }); + + $("#remove_format").click(function () { + removeRow(); + }); + }); + + function createRow() { + if (count >= 1) { + $("#remove_format").show(); + } + if (count == MAX_EXTRAS) { + $("#add_format").hide(); + } + var after = count > 1 ? "#extra_format_row_" + (count - 1) : '#placeholder_row_top'; + var master = $(document.createElement("tr")).attr({ + id:'extra_format_row_' + count + }).insertAfter(after); + + $(document.createElement("td")).addClass('label').html("Extra Format " + count).appendTo(master); + var row = $(document.createElement("td")).appendTo(master); + addFile(row); + addFormats(row); + addBitrates(row); + addReleaseDescription(row); + count++; + } + + function addFile(row) { + var id = count; + $(document.createElement("input")).attr({ + id:"extra_file_" + count, + type:'file', + name:"extra_file_" + count, + size:'30' + }).appendTo(row); + + } + + function addFormats(row) { + $(document.createElement("span")).html(" Format: ").appendTo(row); + $(document.createElement("select")).attr({ + id:"format_" + count, + name:'extra_format[]' + }).html(createDropDownOptions(FORMATS)).appendTo(row); + } + + function addBitrates(row) { + $(document.createElement("span")).html(" Bitrate: ").appendTo(row); + $(document.createElement("select")).attr({ + id:"bitrate_" + count, + name:'extra_bitrate[]' + }).html(createDropDownOptions(BITRATES)).appendTo(row); + /*change( + function () { + var id = $(this).attr('id'); + if ($(this).val() == 'Other') { + $(this).after( + '<span id="other_bitrate_span_' + id + + '" class=""> <input type="text" name="extra_other_bitrate[]" size="5" id="other_bitrate_' + id + + '"><input type="checkbox" id="vbr_' + id + '" name="extra_vbr[]"><label for="vbr_' + id + + '"> (VBR)</label> </span>'); + } else { + $("#other_bitrate_span_" + id).remove(); + } + });*/ + } + + function addReleaseDescription(row) { + var id = count; + var desc_row = $(document.createElement("tr")).attr({ id:"desc_row"}).css('cursor', 'pointer').appendTo(row); + $(document.createElement("a")).html(" [Add Release Description]").css('marginLeft', '-5px').appendTo(desc_row).click(function () { + $("#extra_release_desc_" + id).toggle(300); + }); + $(document.createElement("textarea")).attr({ + id:"extra_release_desc_" + id, + name:"extra_release_desc[]", + cols:60, + rows:4, + style:'display:none; margin-left: 5px; margin-top: 10px; margin-bottom: 10px;' + }).appendTo(desc_row); + } + + function createDropDownOptions(array) { + s = "<option value='0'>---</option>"; + for (var i in array) { + s += ("<option value=\"" + array[i] + "\">" + array[i] + "</option>"); + } + return s; + } + + function removeRow() { + if (count > 1) { + $("#placeholder_row_bottom").prev().remove(); + $("#add_format").show(); + filenames.pop(); + count--; + } + if (count == 1) { + $("#remove_format").hide(); + } + + } + +})(jQuery);
\ No newline at end of file |