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">
|
<ul class="nav">
|
||||||
<li class="active"><a href="#">Active Downloads</a></li>
|
<li class="active"><a href="#">Active Downloads</a></li>
|
||||||
<!-- <li><a href="#watiting_downloads">Passive 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>
|
<li><a id="newDownload" href="#">Add Download</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div><!--/.nav-collapse -->
|
</div><!--/.nav-collapse -->
|
||||||
|
@ -142,7 +143,7 @@
|
||||||
<!--{{{ Hidden dialogs and out of screen HTML elements -->
|
<!--{{{ Hidden dialogs and out of screen HTML elements -->
|
||||||
|
|
||||||
<!--{{{ error connection template -->
|
<!--{{{ error connection template -->
|
||||||
<div class="modal fade" id="error_connect">
|
<div class="modal hide" id="error_connect">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button class="close" data-dismiss="modal">x</button>
|
<button class="close" data-dismiss="modal">x</button>
|
||||||
<h3>Connection to Aria failed :( </h3>
|
<h3>Connection to Aria failed :( </h3>
|
||||||
|
@ -162,7 +163,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!--{{{ change aria2 rpc host and port template -->
|
<!--{{{ 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">
|
<div class="modal-header">
|
||||||
<button class="close" data-dismiss="modal">x</button>
|
<button class="close" data-dismiss="modal">x</button>
|
||||||
<h3>Please enter the aria2 RPC port and host</h3>
|
<h3>Please enter the aria2 RPC port and host</h3>
|
||||||
|
@ -205,7 +206,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!--{{{ add new Download template -->
|
<!--{{{ add new Download template -->
|
||||||
<div class="modal fade" id="newDownload_modal">
|
<div class="modal hide" id="newDownload_modal">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button class="close" data-dismiss="modal">x</button>
|
<button class="close" data-dismiss="modal">x</button>
|
||||||
<h3>Add a new Download</h3>
|
<h3>Add a new Download</h3>
|
||||||
|
@ -230,7 +231,7 @@
|
||||||
<button id="addNewDownload" class="btn">Add Download</button>
|
<button id="addNewDownload" class="btn">Add Download</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--{{{ add new Download template -->
|
<!-- add new Download template end }}}-->
|
||||||
|
|
||||||
<!-- }}} hidden modals end -->
|
<!-- }}} hidden modals end -->
|
||||||
|
|
||||||
|
|
62
js/script.js
62
js/script.js
|
@ -5,9 +5,9 @@ var modals = {
|
||||||
|
|
||||||
};
|
};
|
||||||
var clear_dialogs = function() {
|
var clear_dialogs = function() {
|
||||||
modals.err_connect = $('#error_connect').modal('hide');
|
modals.err_connect.modal('hide');
|
||||||
modals.change_conf = $('#change_conf').modal('hide');
|
modals.change_conf.modal('hide');
|
||||||
modals.newDownload_modal = $('#newDownload_modal').modal('hide');
|
modals.newDownload_modal.modal('hide');
|
||||||
};
|
};
|
||||||
var server_conf = {
|
var server_conf = {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
|
@ -42,19 +42,8 @@ function param_encode(param) {
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
var aria_syscall = function(conf, multicall) {
|
var aria_syscall = function(conf, multicall) {
|
||||||
var url = "";
|
|
||||||
if(server_conf.user.length) {
|
|
||||||
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';
|
|
||||||
}
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: 'http://' + server_conf.host + ':' + server_conf.port + '/jsonrpc',
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
data: {
|
data: {
|
||||||
jsonrpc: 2.0,
|
jsonrpc: 2.0,
|
||||||
|
@ -63,7 +52,40 @@ var aria_syscall = function(conf, multicall) {
|
||||||
params: param_encode(conf.params)
|
params: param_encode(conf.params)
|
||||||
},
|
},
|
||||||
success: conf.sucess,
|
success: conf.sucess,
|
||||||
error: conf.error,
|
error: function() {
|
||||||
|
if(server_conf.user.length) {
|
||||||
|
var url = 'http://' +
|
||||||
|
server_conf.user + ":" +
|
||||||
|
server_conf.pass + "@" +
|
||||||
|
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,
|
||||||
|
data: {
|
||||||
|
jsonrpc: 2.0,
|
||||||
|
id: 'webui',
|
||||||
|
method: multicall? conf.func:'aria2.' + conf.func,
|
||||||
|
params: param_encode(conf.params)
|
||||||
|
},
|
||||||
|
success: conf.sucess,
|
||||||
|
error: conf.error,
|
||||||
|
dataType: 'jsonp',
|
||||||
|
jsonp: 'jsoncallback'
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
else if(conf.error) {
|
||||||
|
conf.error();
|
||||||
|
}
|
||||||
|
},
|
||||||
dataType: 'jsonp',
|
dataType: 'jsonp',
|
||||||
jsonp: 'jsoncallback'
|
jsonp: 'jsoncallback'
|
||||||
});
|
});
|
||||||
|
@ -74,7 +96,13 @@ var update_ui = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
$(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();
|
update_ui();
|
||||||
$('#newDownload').click(function() {
|
$('#newDownload').click(function() {
|
||||||
$('#newDownload_url').val("");
|
$('#newDownload_url').val("");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user