Skip to content

Commit

Permalink
extract cookie reading
Browse files Browse the repository at this point in the history
  • Loading branch information
ppierre committed Mar 13, 2009
1 parent 9cd5a10 commit c96b411
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Support/txmt_pep8.js
Expand Up @@ -34,18 +34,22 @@ function view(el) {
save_cookie('view_pep');
}

function load_from_cookie(name) {
console.log(document.cookie);
function read_cookie(name) {
var cookie = document.cookie;
if (cookie && cookie.length > (name.length + 2)) {
var i_code = cookie.indexOf(name + '=');
var view_source = parseInt(cookie.substring(
i_code + name.length + 1, i_code + name.length + 2), 10);
toggle(name, view_source);
document.getElementById(name).checked = view_source;
return view_source;
}
}

function load_from_cookie(name) {
var view_source = read_cookie(name);
toggle(name, view_source);
document.getElementById(name).checked = view_source;
}

window.onload = function () {
load_from_cookie('view_source');
load_from_cookie('view_pep');
Expand Down

0 comments on commit c96b411

Please sign in to comment.