2018-09-03 23:28:45 +02:00
|
|
|
|
function setTitle(user, page)
|
|
|
|
|
{
|
|
|
|
|
document.title = `Brutaldon (${user}) – ${page}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function afterPage(user, page)
|
|
|
|
|
{
|
|
|
|
|
setTitle(user,page);
|
2018-09-04 01:47:06 +02:00
|
|
|
|
var menu = document.querySelector('#navMenu');
|
|
|
|
|
menu.classList.remove('is-active');
|
2018-09-04 02:10:35 +02:00
|
|
|
|
var burger = document.querySelector('.navbar-burger');
|
|
|
|
|
burger.classList.remove('is-active');
|
2018-09-03 23:28:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function menuPrepare() {
|
|
|
|
|
// Remove is-active from navbar menu
|
|
|
|
|
var menu = document.querySelector('#navMenu');
|
|
|
|
|
menu.classList.remove('is-active');
|
|
|
|
|
|
|
|
|
|
// Add the burger
|
|
|
|
|
var brand = document.querySelector('.navbar-brand');
|
|
|
|
|
var burger = document.createElement('a');
|
|
|
|
|
burger.classList.toggle('navbar-burger');
|
|
|
|
|
burger.setAttribute("aria-label", "menu");
|
|
|
|
|
burger.setAttribute("aria-expanded", "false");
|
|
|
|
|
burger.setAttribute("data-target", "navMenu");
|
|
|
|
|
for (var index = 0; index < 3; index++)
|
|
|
|
|
{
|
|
|
|
|
var span = document.createElement('span');
|
|
|
|
|
span.setAttribute('aria-hidden', "true");
|
|
|
|
|
burger.appendChild(span);
|
|
|
|
|
}
|
|
|
|
|
brand.appendChild(burger);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get all "navbar-burger" elements
|
|
|
|
|
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
|
|
|
|
|
|
|
|
|
// Check if there are any navbar burgers
|
|
|
|
|
if ($navbarBurgers.length > 0) {
|
|
|
|
|
|
|
|
|
|
// Add a click event on each of them
|
|
|
|
|
$navbarBurgers.forEach(function ($el) {
|
|
|
|
|
$el.addEventListener('click', function () {
|
|
|
|
|
|
|
|
|
|
// Get the target from the "data-target" attribute
|
|
|
|
|
var target = $el.dataset.target;
|
|
|
|
|
var $target = document.getElementById(target);
|
|
|
|
|
|
|
|
|
|
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
|
|
|
|
|
$el.classList.toggle('is-active');
|
|
|
|
|
$target.classList.toggle('is-active');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2018-09-06 18:07:31 +02:00
|
|
|
|
|
|
|
|
|
function expandCWButtonPrepare()
|
|
|
|
|
{
|
2018-09-06 19:36:27 +02:00
|
|
|
|
var theButton = document.querySelector('#expandCWs');
|
|
|
|
|
if (!theButton) {
|
|
|
|
|
theButton = document.createElement('p');
|
|
|
|
|
theButton.id = "expandCWs";
|
|
|
|
|
theButton.textContent = "Expand CWs";
|
|
|
|
|
theButton.classList.toggle('button');
|
2018-09-16 01:49:28 +02:00
|
|
|
|
var title = document.querySelector('#title');
|
|
|
|
|
if (title)
|
|
|
|
|
{
|
|
|
|
|
title.insertAdjacentElement('afterend', theButton);
|
|
|
|
|
var details = document.querySelectorAll('details');
|
|
|
|
|
var openState = false;
|
|
|
|
|
|
|
|
|
|
if (details != null) {
|
|
|
|
|
theButton.addEventListener('click', function() {
|
|
|
|
|
openState = details.item(0).hasAttribute('open');
|
|
|
|
|
details.forEach(function ($el) {
|
|
|
|
|
if (openState)
|
|
|
|
|
{
|
|
|
|
|
$el.removeAttribute('open');
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
$el.setAttribute('open', '');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
openState = !openState;
|
|
|
|
|
if (openState) { theButton.textContent = 'Collapse CWs'; }
|
|
|
|
|
else { theButton.textContent = "Expand CWs"; };
|
|
|
|
|
theButton.classList.toggle('is-active');
|
2018-09-06 19:36:27 +02:00
|
|
|
|
});
|
2018-09-16 01:49:28 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-06 19:36:27 +02:00
|
|
|
|
}
|
2018-09-06 18:07:31 +02:00
|
|
|
|
}
|
2018-09-06 18:12:49 +02:00
|
|
|
|
|
|
|
|
|
function fileButtonUpdaters()
|
|
|
|
|
{
|
|
|
|
|
var file1 = document.getElementById("id_media_file_1");
|
|
|
|
|
file1.onchange = function(){
|
|
|
|
|
if (file1.files.length > 0)
|
|
|
|
|
{
|
|
|
|
|
document.getElementById('media_filename_1').innerHTML = file1.files[0].name;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var file2 = document.getElementById("id_media_file_2");
|
|
|
|
|
file2.onchange = function(){
|
|
|
|
|
if (file2.files.length > 0)
|
|
|
|
|
{
|
|
|
|
|
document.getElementById('media_filename_2').innerHTML = file2.files[0].name;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var file3 = document.getElementById("id_media_file_3");
|
|
|
|
|
file3.onchange = function(){
|
|
|
|
|
if (file3.files.length > 0)
|
|
|
|
|
{
|
|
|
|
|
document.getElementById('media_filename_3').innerHTML = file3.files[0].name;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var file4 = document.getElementById("id_media_file_4");
|
|
|
|
|
file4.onchange = function(){
|
|
|
|
|
if (file4.files.length > 0)
|
|
|
|
|
{
|
|
|
|
|
document.getElementById('media_filename_4').innerHTML = file4.files[0].name;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
2018-09-07 22:28:33 +02:00
|
|
|
|
|
|
|
|
|
function characterCountSetup()
|
|
|
|
|
{
|
2018-09-16 01:49:28 +02:00
|
|
|
|
if ($("#id_status").length) {
|
2018-09-07 22:28:33 +02:00
|
|
|
|
$("#status_count").text(characterCount());
|
2018-09-16 01:49:28 +02:00
|
|
|
|
$("#id_status").keyup(function(){
|
|
|
|
|
$("#status_count").text(characterCount());
|
|
|
|
|
});
|
|
|
|
|
$("#id_spoiler_text").keyup(function(){
|
|
|
|
|
$("#status_count").text(characterCount());
|
|
|
|
|
});
|
|
|
|
|
}
|
2018-09-07 22:28:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function characterCount()
|
|
|
|
|
{
|
|
|
|
|
return $("#id_status").val().length + $("#id_spoiler_text").val().length;
|
|
|
|
|
}
|
2018-09-18 02:12:53 +02:00
|
|
|
|
|
|
|
|
|
function savePlace()
|
|
|
|
|
{
|
|
|
|
|
sessionStorage.setItem("lastScrollPos", window.scrollY);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function restorePlace(ev)
|
|
|
|
|
{
|
|
|
|
|
var lastScrollPos = sessionStorage.getItem('lastScrollPos');
|
|
|
|
|
Intercooler.ready(function (elt)
|
|
|
|
|
{
|
2018-09-18 16:53:21 +02:00
|
|
|
|
if (elt[0].id == 'main')
|
2018-09-18 02:12:53 +02:00
|
|
|
|
{
|
|
|
|
|
window.scrollTo(0, lastScrollPos);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|