Titivillus/static/base.js

32 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-09-20 13:09:24 -04:00
function toggle_cookie(cookie, state) {
2018-09-19 15:56:59 -04:00
let xhr = new XMLHttpRequest();
xhr.open('POST', api_url + '/set_session', true);
2018-09-19 15:56:59 -04:00
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2018-09-20 13:09:24 -04:00
xhr.setRequestHeader('X-CSRFToken', csrf_token);
xhr.send(cookie + '=' + state);
}
2018-09-20 13:09:24 -04:00
function toggle_header() {
2018-09-30 01:30:50 -04:00
if (document.getElementById('header').style.display == 'flex') {
2018-09-19 15:56:59 -04:00
document.getElementById('header').style.display = 'none';
2018-10-02 11:35:39 -04:00
document.getElementById('headerHidden').style.display = 'flex';
2018-09-20 13:09:24 -04:00
toggle_cookie('hide_header', 'on');
2018-09-19 15:56:59 -04:00
}
else {
2018-09-30 01:30:50 -04:00
document.getElementById('header').style.display = 'flex';
2018-09-19 15:56:59 -04:00
document.getElementById('headerHidden').style.display = 'none';
2018-09-20 13:09:24 -04:00
toggle_cookie('hide_header', 'off');
2018-09-19 15:56:59 -04:00
}
}
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;
}