function setPreference(cname, cvalue) { var params = "set=1" + "&name=" + cname + "&value=" + cvalue; var req = new XMLHttpRequest(); req.open('POST', '/preferences', true); req.setRequestHeader("X-CSRFToken", get_csrf_token()); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.onreadystatechange = function (aEvt) { if (req.readyState == 4 && req.status != 200) { alert('Error setting preference'); } }; req.send(params); } function getPreference(cname) { var params = "get=1" + "&name=" + cname; var req = new XMLHttpRequest(); req.open('POST', '/preferences', false); req.setRequestHeader("X-CSRFToken", get_csrf_token()); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.send(params); if(req.status == 200) return JSON.parse(req.responseText)[cname]; return null; } function set_visible(id, visible, display) { widget = document.getElementById(id); if (visible) { widget.style.display = display; widget.style.visibility = "visible"; } else { widget.style.display = "none"; widget.style.visibility = "hidden"; } return widget; } function updateHiddenCategories(cat_id, add) { if (hidden_categories == null) hidden_categories = []; for(i=0; i