functionality for adding multiple links to new download added

This commit is contained in:
Hamza Zia 2012-06-06 01:24:15 +08:00
parent c7c1ccd4c4
commit 71ea9b22ce
2 changed files with 34 additions and 6 deletions

View File

@ -61,7 +61,7 @@
<div class="span2">
<div style="float:right">
<button class="btn btn-mini download_play"><i class="icon-play"></i> Play</button>
<button class="btn btn-mini btn-danger download_remove"><i class="icon-remove"></i> Remove</button>
<button class="btn btn-mini btn-danger download_remove"><i class="icon-fire"></i> Purge</button>
</div>
</div>
<br><br>
@ -140,7 +140,7 @@
<!--{{{ Hidden dialogs and out of screen HTML elements -->
<!-- error connection template -->
<!--{{{ error connection template -->
<div class="modal fade" id="error_connect">
<div class="modal-header">
<button class="close" data-dismiss="modal">x</button>
@ -157,9 +157,10 @@
<a href="#" onclick="custom_aria2_connect()" class="btn btn-primary">Use custom IP and port settings</a>
</div>
</div>
<!-- error connection end }}}-->
<!-- change aria2 rpc host and port template -->
<!--{{{ change aria2 rpc host and port template -->
<div class="modal fade" id="change_conf">
<div class="modal-header">
<button class="close" data-dismiss="modal">x</button>
@ -189,9 +190,10 @@
<a href="#" onclick="update_server_conf()" class="btn btn-primary">Use custom IP and port settings</a>
</div>
</div>
<!-- change aria2 rpc host and port template }}}-->
<!-- new Download template -->
<!--{{{ add new Download template -->
<div class="modal fade" id="newDownload_modal">
<div class="modal-header">
<button class="close" data-dismiss="modal">x</button>
@ -205,7 +207,9 @@
<label class="control-label" for="newDownload_url">Enter url for the Download:</label>
<div class="controls">
<input type="text" class="input-xlarge" id="newDownload_url" placeholder="http://example.com"/>
<button class="btn" id="multiple_uris"><i class="icon-plus-sign"></i></button>
<span class="help-block">URI can be HTTP(S)/FTP/BitTorrent Magnet URI</span>
<ol class="download_urls"></ol>
</div>
</div>
</fieldset>
@ -215,6 +219,8 @@
<button id="addNewDownload" class="btn">Add Download</button>
</div>
</div>
<!--{{{ add new Download template -->
<!-- }}} hidden modals end -->
<script src="js/plugins.js"></script>

View File

@ -55,8 +55,24 @@ $(function() {
clear_dialogs();
update_ui();
$('#newDownload').click(function() {
$('#newDownload_url').val("");
$('.download_urls').html("");
modals.newDownload_modal.modal('show');
});
$('#multiple_uris').click(function() {
var url = $('#newDownload_url').val();
var html = '<li>';
html += '<span class="uris">';
html += url;
html += '</span>';
html += ' ';
html += '<a href="#"><i class="icon-trash"></i></a></li>';
$(html).appendTo('.download_urls');
$('#newDownload_url').val("");
$('.download_urls a').click(function() {
$(this).parents('li').remove();
});
});
$('#addNewDownload').click(newDownload);
});
@ -74,8 +90,14 @@ function addDownload(uris) {
}
function newDownload() {
var url = $('#newDownload_url').val();
addDownload([[url]]);
var li = $('.download_urls li');
var urls = [];
for(var i = 0; i < li.length; i++) {
urls.push($(li[i]).text().trim());
}
alert(JSON.stringify(urls));
addDownload([urls]);
}
var d_files = {