Commit 591969d5 authored by Erik Huelsmann's avatar Erik Huelsmann

Merge branch 'master' into 'master'

Added announcement box

See merge request !76
parents de560e64 7511e474
Pipeline #602 passed with stages
in 11 seconds
......@@ -6,6 +6,32 @@ body{
min-height:100%;
padding-top:4.5rem;
}
#header {
display: flex;
flex-direction: column;
}
#message-box {
width: 100%;
padding: 8px;
background-color: #ba1e0d;
color: white;
display: none;
flex-direction: row;
}
#message-box-close {
align-self: center;
}
#message-hidden-btn {
align-self: flex-end;
display: none;
color: #ba1e0d;
font-weight: bold;
padding-top: 10px;
padding-right: 10px;
}
#message-box-text {
flex-grow: 1;
}
.main {
padding-top: 20px;
font-size: 0.9rem;
......@@ -22,7 +48,6 @@ body{
}
.cl-navbar {
border-width: 0px;
box-shadow: 0px 1px 10px lightgrey;
font-weight: bold;
padding-top: 0;
padding-bottom: 0;
......
$(document).ready(function () {
$("span.menu-link").click(function (event) {
var nextMenu = $(this).next(".menu");
console.log(nextMenu.siblings(".menu").slideUp());
nextMenu.siblings(".menu").slideUp();
$('span.menu-link').click(function (event) {
var nextMenu = $(this).next('.menu');
console.log(nextMenu.siblings('.menu').slideUp());
nextMenu.siblings('.menu').slideUp();
nextMenu.slideToggle();
});
......@@ -13,4 +13,64 @@ $(document).ready(function () {
var $quote = $($quotes[Math.floor(Math.random() * $quotes.length)]);
$('#lisp-quote').html($quote.html());
/* Announcement box */
let announcementUrl = "https://common-lisp.net/broadcast.html";
let closeMessageBoxBtn = $('#message-box-close');
let openMessasgeBoxBtn = $('#message-hidden-btn');
let messageBox = $('#message-box');
let messageText = $('#message-box-text');
let initialBodyPadding = $('body').outerHeight() - $('body').height();
function calculateNewPadding(isMessageShowing) {
let messageHeight = $('#message-box').outerHeight();
return isMessageShowing ? initialBodyPadding + messageHeight : initialBodyPadding;
}
function closeMessageBox() {
messageBox.css('display', 'none');
openMessasgeBoxBtn.css('display', 'block');
localStorage.setItem('was_message_closed', true);
$('body').css('padding-top', calculateNewPadding(false));
}
function openMessageBox() {
messageBox.css('display', 'flex');
openMessasgeBoxBtn.css('display', 'none');
localStorage.removeItem('was_message_closed');
$('body').css('padding-top', calculateNewPadding(true));
}
closeMessageBoxBtn.click(function (event) {
event.preventDefault();
closeMessageBox();
});
openMessasgeBoxBtn.click(function (event) {
event.preventDefault();
openMessageBox();
});
$.ajax({
url: announcementUrl,
success: function (resp) {
if (resp == null || resp.length < 1) { return; }
messageText.html(resp);
let previousMessage = localStorage.getItem('previous_message');
if (previousMessage == null || previousMessage !== resp) {
localStorage.setItem('previous_message', resp);
openMessageBox();
return;
}
let wasMessageClosed = localStorage.getItem('was_message_closed');
if (wasMessageClosed) {
closeMessageBox();
} else {
openMessageBox();
}
}
})
});
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment