hack for http authentication for all browsers added over JSONP!!
This commit is contained in:
parent
b1f297aa7b
commit
433663a584
|
@ -117,6 +117,7 @@
|
|||
<ul class="nav">
|
||||
<li class="active"><a href="#">Active Downloads</a></li>
|
||||
<!-- <li><a href="#watiting_downloads">Passive Downloads</a></li> -->
|
||||
<li><a href="#">Aria2 connection configuration</a></li>
|
||||
<li><a id="newDownload" href="#">Add Download</a></li>
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
|
@ -142,7 +143,7 @@
|
|||
<!--{{{ Hidden dialogs and out of screen HTML elements -->
|
||||
|
||||
<!--{{{ error connection template -->
|
||||
<div class="modal fade" id="error_connect">
|
||||
<div class="modal hide" id="error_connect">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3>Connection to Aria failed :( </h3>
|
||||
|
@ -162,7 +163,7 @@
|
|||
|
||||
|
||||
<!--{{{ change aria2 rpc host and port template -->
|
||||
<div class="modal fade" id="change_conf">
|
||||
<div class="modal hide" id="change_conf">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3>Please enter the aria2 RPC port and host</h3>
|
||||
|
@ -205,7 +206,7 @@
|
|||
|
||||
|
||||
<!--{{{ add new Download template -->
|
||||
<div class="modal fade" id="newDownload_modal">
|
||||
<div class="modal hide" id="newDownload_modal">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3>Add a new Download</h3>
|
||||
|
@ -230,7 +231,7 @@
|
|||
<button id="addNewDownload" class="btn">Add Download</button>
|
||||
</div>
|
||||
</div>
|
||||
<!--{{{ add new Download template -->
|
||||
<!-- add new Download template end }}}-->
|
||||
|
||||
<!-- }}} hidden modals end -->
|
||||
|
||||
|
|
48
js/script.js
48
js/script.js
|
@ -5,9 +5,9 @@ var modals = {
|
|||
|
||||
};
|
||||
var clear_dialogs = function() {
|
||||
modals.err_connect = $('#error_connect').modal('hide');
|
||||
modals.change_conf = $('#change_conf').modal('hide');
|
||||
modals.newDownload_modal = $('#newDownload_modal').modal('hide');
|
||||
modals.err_connect.modal('hide');
|
||||
modals.change_conf.modal('hide');
|
||||
modals.newDownload_modal.modal('hide');
|
||||
};
|
||||
var server_conf = {
|
||||
host: 'localhost',
|
||||
|
@ -42,17 +42,30 @@ function param_encode(param) {
|
|||
return param;
|
||||
}
|
||||
var aria_syscall = function(conf, multicall) {
|
||||
var url = "";
|
||||
$.ajax({
|
||||
url: 'http://' + server_conf.host + ':' + server_conf.port + '/jsonrpc',
|
||||
timeout: 1000,
|
||||
data: {
|
||||
jsonrpc: 2.0,
|
||||
id: 'webui',
|
||||
method: multicall? conf.func:'aria2.' + conf.func,
|
||||
params: param_encode(conf.params)
|
||||
},
|
||||
success: conf.sucess,
|
||||
error: function() {
|
||||
if(server_conf.user.length) {
|
||||
url = 'http://' +
|
||||
var url = 'http://' +
|
||||
server_conf.user + ":" +
|
||||
server_conf.pass + "@" +
|
||||
server_conf.host + ':' +
|
||||
server_conf.port + '/jsonrpc';
|
||||
}
|
||||
else {
|
||||
url = 'http://' + server_conf.host + ':' + server_conf.port + '/jsonrpc';
|
||||
}
|
||||
|
||||
/* hack for http authentication */
|
||||
var img = $('<img/>').attr("src", url);
|
||||
$('body').append(img);
|
||||
img.remove();
|
||||
|
||||
setTimeout(function() {
|
||||
$.ajax({
|
||||
url: url,
|
||||
timeout: 1000,
|
||||
|
@ -67,6 +80,15 @@ var aria_syscall = function(conf, multicall) {
|
|||
dataType: 'jsonp',
|
||||
jsonp: 'jsoncallback'
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
else if(conf.error) {
|
||||
conf.error();
|
||||
}
|
||||
},
|
||||
dataType: 'jsonp',
|
||||
jsonp: 'jsoncallback'
|
||||
});
|
||||
|
||||
}
|
||||
var update_ui = function() {
|
||||
|
@ -74,7 +96,13 @@ var update_ui = function() {
|
|||
};
|
||||
|
||||
$(function() {
|
||||
clear_dialogs();
|
||||
var modal_conf = {
|
||||
show: false
|
||||
};
|
||||
modals.err_connect = $('#error_connect').modal(modal_conf);
|
||||
modals.change_conf = $('#change_conf').modal(modal_conf);
|
||||
modals.newDownload_modal = $('#newDownload_modal').modal(modal_conf);
|
||||
|
||||
update_ui();
|
||||
$('#newDownload').click(function() {
|
||||
$('#newDownload_url').val("");
|
||||
|
|
Loading…
Reference in New Issue
Block a user