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