35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
function toggle_cookie(cookie, state) {
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open('POST', api_url + '/set_session', true);
|
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
xhr.setRequestHeader('X-CSRFToken', csrf_token);
|
|
xhr.send(cookie + '=' + state);
|
|
}
|
|
function toggle_header() {
|
|
if (document.getElementById('header').style.display == 'flex') {
|
|
document.getElementById('header').style.display = 'none';
|
|
document.getElementById('headerHidden').style.display = 'flex';
|
|
toggle_cookie('hide_header', 'on');
|
|
}
|
|
else {
|
|
document.getElementById('header').style.display = 'flex';
|
|
document.getElementById('headerHidden').style.display = 'none';
|
|
toggle_cookie('hide_header', 'off');
|
|
}
|
|
}
|
|
function clear_notification(msg_id) {
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open('POST', api_url + '/clear_notification', true);
|
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
xhr.setRequestHeader('X-CSRFToken', csrf_token);
|
|
xhr.send('msg_id=' + msg_id);
|
|
|
|
let elem = document.getElementById('notification-' + msg_id);
|
|
elem.parentNode.removeChild(elem);
|
|
elem = document.getElementById('subbtn');
|
|
elem.innerText = elem.innerText - 1;
|
|
if (elem.innerText === '0') {
|
|
elem.className = 'noNewSubs';
|
|
}
|
|
}
|