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 -->
|
||||||
|
|
||||||
|
|
48
js/script.js
48
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,17 +42,30 @@ function param_encode(param) {
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
var aria_syscall = function(conf, multicall) {
|
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) {
|
if(server_conf.user.length) {
|
||||||
url = 'http://' +
|
var url = 'http://' +
|
||||||
server_conf.user + ":" +
|
server_conf.user + ":" +
|
||||||
server_conf.pass + "@" +
|
server_conf.pass + "@" +
|
||||||
server_conf.host + ':' +
|
server_conf.host + ':' +
|
||||||
server_conf.port + '/jsonrpc';
|
server_conf.port + '/jsonrpc';
|
||||||
}
|
|
||||||
else {
|
/* hack for http authentication */
|
||||||
url = 'http://' + server_conf.host + ':' + server_conf.port + '/jsonrpc';
|
var img = $('<img/>').attr("src", url);
|
||||||
}
|
$('body').append(img);
|
||||||
|
img.remove();
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
|
@ -67,6 +80,15 @@ var aria_syscall = function(conf, multicall) {
|
||||||
dataType: 'jsonp',
|
dataType: 'jsonp',
|
||||||
jsonp: 'jsoncallback'
|
jsonp: 'jsoncallback'
|
||||||
});
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
else if(conf.error) {
|
||||||
|
conf.error();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dataType: 'jsonp',
|
||||||
|
jsonp: 'jsoncallback'
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
var update_ui = function() {
|
var update_ui = function() {
|
||||||
|
@ -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