improved aria2 connection handling
This commit is contained in:
parent
2bc0f3a90a
commit
b20ad0d04e
|
@ -565,7 +565,7 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label" for="input_host">Enter the host:</label>
|
||||
<div class="controls">
|
||||
<div class="input-prepend"><span class="add-on">http://</span><input type="text" class="input-xlarge" id="input_host" placeholder="localhost"/></div>
|
||||
<div class="input-prepend"><span class="add-on">http(s)://</span><input type="text" class="input-xlarge" id="input_host" placeholder="localhost"/></div>
|
||||
<p class="help-block">Enter the ip or dns name of the server on which the rpc for aria2 is running (default = localhost)</p>
|
||||
</div>
|
||||
<label class="control-label" for="input_port">Enter the port:</label>
|
||||
|
|
|
@ -87,7 +87,7 @@ var SocketRPC = function(conf) {
|
|||
rpc.initialized = true;
|
||||
};
|
||||
rpc.sock.onclose = rpc.sock.onerror = function() {
|
||||
_.each(handles, function(h) { h.error() });
|
||||
_.each(rpc.handles, function(h) { h.error() });
|
||||
rpc.handles = [];
|
||||
};
|
||||
rpc.sock.onmessage = function(message) {
|
||||
|
|
12
js/script.js
12
js/script.js
|
@ -25,16 +25,18 @@ var server_conf = {
|
|||
port: 6800,
|
||||
user: "",
|
||||
pass: "",
|
||||
encryption: false
|
||||
encryption: false,
|
||||
dirty: false
|
||||
};
|
||||
|
||||
var ariaConnection = new AriaConnection(server_conf);
|
||||
var ariaConnection;
|
||||
var set_conf_cookie = function() {
|
||||
setCookie('aria2_server_conf', JSON.stringify(server_conf), 30 * 12);
|
||||
}
|
||||
var get_conf_cookie = function() {
|
||||
if (getCookie( $.trim('aria2_server_conf'))) {
|
||||
server_conf = JSON.parse(getCookie('aria2_server_conf'));
|
||||
server_conf.dirty = false;
|
||||
}
|
||||
}
|
||||
var custom_aria2_connect = function() {
|
||||
|
@ -58,6 +60,7 @@ var update_server_conf = function() {
|
|||
if(port.length !== 0) {
|
||||
server_conf.port = port;
|
||||
}
|
||||
server_conf.dirty = false;
|
||||
set_conf_cookie();
|
||||
ariaConnection = new AriaConnection(server_conf);
|
||||
clear_dialogs();
|
||||
|
@ -69,7 +72,8 @@ var aria_syscall = function(conf, multicall, old) {
|
|||
ariaConnection.invoke(conf);
|
||||
}
|
||||
var update_ui = function() {
|
||||
updateDownloads();
|
||||
if (!server_conf.dirty)
|
||||
updateDownloads();
|
||||
};
|
||||
|
||||
$(function() {
|
||||
|
@ -93,6 +97,7 @@ $(function() {
|
|||
modals.new_torrent_modal = $('#new_torrent').modal(modal_conf);
|
||||
modals.new_metalink_modal = $('#new_metalink').modal(modal_conf);
|
||||
|
||||
ariaConnection = new AriaConnection(server_conf)
|
||||
update_ui();
|
||||
globalGraphData = {
|
||||
downSpeed: [],
|
||||
|
@ -931,6 +936,7 @@ function updateDownloads() {
|
|||
updateGlobalStatistics(data.result[3][0]);
|
||||
},
|
||||
error: function() {
|
||||
server_conf.dirty = true;
|
||||
modals.err_connect.modal('show');
|
||||
}
|
||||
}, true);
|
||||
|
|
Loading…
Reference in New Issue
Block a user