diff --git a/layout/static/css/layout_2018.css b/layout/static/css/layout_2018.css index 83cb1e907fbedb23bab5f7b24fbb48a4681e9b55..9cdc2a25c92a276ce2319aaa004cd1b10a55b7d8 100644 --- a/layout/static/css/layout_2018.css +++ b/layout/static/css/layout_2018.css @@ -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; diff --git a/layout/static/js/scripts.js b/layout/static/js/scripts.js index 7447e3f76375aa352f88d2b6c12d8b80db0edca4..2bc439db0fc5fb69f96b6c56fc1cffb7c07611bd 100644 --- a/layout/static/js/scripts.js +++ b/layout/static/js/scripts.js @@ -1,9 +1,9 @@ $(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(); + } + } + }) }); diff --git a/layout/templates/layout_2018.html b/layout/templates/layout_2018.html index 419751a58beb42b00ff9275e7da7fe64fb501c7a..b9c30d37e711f76ca41044db419abe0cc14ed6e2 100644 --- a/layout/templates/layout_2018.html +++ b/layout/templates/layout_2018.html @@ -1,194 +1,224 @@ - - - - {{title}} - - - - - - - - -