added initial cookie support
This commit is contained in:
parent
a85d6b41e0
commit
a9fbb8a148
|
@ -61,5 +61,28 @@ var base64 = (function (obj) {
|
|||
|
||||
return obj;
|
||||
}({}));
|
||||
function setCookie(c_name,value,exdays)
|
||||
{
|
||||
var exdate=new Date();
|
||||
exdate.setDate(exdate.getDate() + exdays);
|
||||
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
|
||||
document.cookie=c_name + "=" + c_value;
|
||||
}
|
||||
|
||||
function getCookie(c_name)
|
||||
{
|
||||
var i,x,y,ARRcookies=document.cookie.split(";");
|
||||
for (i=0;i<ARRcookies.length;i++)
|
||||
{
|
||||
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
|
||||
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
|
||||
x=x.replace(/^\s+|\s+$/g,"");
|
||||
if (x==c_name)
|
||||
{
|
||||
return unescape(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
11
js/script.js
11
js/script.js
|
@ -24,6 +24,15 @@ var server_conf = {
|
|||
user: "",
|
||||
pass: ""
|
||||
};
|
||||
|
||||
var set_conf_cookie = function() {
|
||||
setCookie('aria2_server_conf', JSON.stringify(server_conf));
|
||||
}
|
||||
var get_conf_cookie = function() {
|
||||
if (getCookie('aria2_server_conf'.trim())) {
|
||||
server_conf = JSON.parse(getCookie('aria2_server_conf'));
|
||||
}
|
||||
}
|
||||
var custom_aria2_connect = function() {
|
||||
clear_dialogs();
|
||||
modals.change_conf.modal('show');
|
||||
|
@ -40,6 +49,7 @@ var update_server_conf = function() {
|
|||
server_conf.port = port;
|
||||
}
|
||||
web_sock = undefined;
|
||||
set_conf_cookie();
|
||||
clear_dialogs();
|
||||
update_ui();
|
||||
};
|
||||
|
@ -169,6 +179,7 @@ var update_ui = function() {
|
|||
};
|
||||
|
||||
$(function() {
|
||||
get_conf_cookie();
|
||||
var modal_conf = {
|
||||
show: false,
|
||||
backdrop: false
|
||||
|
|
Loading…
Reference in New Issue
Block a user