misuzu/views/nova/home/landing.twig

212 lines
8.2 KiB
Twig

{% extends '@nova/home/master.twig' %}
{% set banner_classes = 'banner--insane landing__banner' %}
{% set banner = 'https://static.flash.moe/images/banner-clouds.png' %}
{% block banner_content %}
<div id="countdown"></div>
<style>
#countdown {
width: 100%;
height: 100%;
}
.countdown-container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
transition: transform .5s;
}
.countdown-digit {
background: url('https://static.flash.moe/images/countdown-sprite.png');
width: 68px;
height: 80px;
display: inline-block;
z-index: 1;
position: relative;
transition: background-position-y .2s;
}
.countdown-digit[data-digit="0"] { background-position: 0px 0px; }
.countdown-digit[data-digit="1"] { background-position: 0px -86px; }
.countdown-digit[data-digit="2"] { background-position: 0px -172px; }
.countdown-digit[data-digit="3"] { background-position: 0px -259px; }
.countdown-digit[data-digit="4"] { background-position: 0px -345px; }
.countdown-digit[data-digit="5"] { background-position: 0px -432px; }
.countdown-digit[data-digit="6"] { background-position: 0px -518px; }
.countdown-digit[data-digit="7"] { background-position: 0px -604px; }
.countdown-digit[data-digit="8"] { background-position: 0px -691px; }
.countdown-digit[data-digit="9"] { background-position: 0px -777px; }
.countdown-digit[data-digit=";"] { transition: background-position-y 0s; background-position: -56px 0px; }
.countdown-digit[data-digit=":"] { transition: background-position-y 0s; background-position: -56px -86px; }
.countdown-digit[data-digit=","] { transition: background-position-y 0s; background-position: -56px -172px; }
.countdown-digit[data-digit="."] { transition: background-position-y 0s; background-position: -56px -259px; }
.countdown-digit[data-digit="+"] { transition: background-position-y 0s; background-position: -56px -345px; }
.countdown-digit[data-digit="-"] { transition: background-position-y 0s; background-position: -56px -432px; }
.countdown-digit[data-digit=" "] { transition: background-position-y 0s; background-position: -56px -518px; }
</style>
<script>
var countdownTarget,
countdownDigits = [],
countdownContainer,
countdownInterval,
countdownFlashingTicks = 0,
countdownLastString = '',
countdownFinish,
countdownIgnoreHidden = false,
continueChecking = true,
checkClient = null,
checkTimeout;
function countdownSetup(container, target, finish) {
countdownFinish = finish || null;
countdownContainer = container;
countdownTarget = target.getTime();
countdownResize(10);
countdownInterval = setInterval(function () { countdownUpdate(countdownIgnoreHidden); }, 100);
countdownUpdate(countdownIgnoreHidden);
}
function countdownStop() {
clearInterval(countdownInterval);
countdownResize(0);
countdownTarget = 0;
countdownContainer.parentNode.removeChild(countdownContainer);
countdownFinish = null;
}
function countdownResize(num) {
if (num == countdownDigits.length)
return;
if (num < countdownDigits.length) {
num = countdownDigits.length - num;
for (var i = 0; i < num; i++)
countdownContainer.removeChild(countdownDigits.pop());
return;
}
if (num > countdownDigits.length) {
num = num - countdownDigits.length;
for (var i = 0; i < num; i++) {
var elem = document.createElement('div');
elem.className = 'countdown-digit';
elem.setAttribute('data-digit', i);
countdownDigits.push(elem);
countdownContainer.appendChild(elem);
}
return;
}
}
function countdownUpdate(ignoreHidden) {
if (!ignoreHidden && document.hidden)
return;
var now = Date.now();
if (countdownTarget < now) {
if ((typeof countdownFinish) === 'function') {
countdownFinish.call();
countdownFinish = null;
}
countdownWrite(++countdownFlashingTicks % 10 < 5 ? '00:00:00' : '00 00 00');
return;
}
var milliseconds = now - countdownTarget;
var days = Math.ceil(milliseconds / 86400000);
milliseconds -= days * 86400000;
var hours = Math.ceil(milliseconds / 3600000);
milliseconds -= hours * 3600000;
var minutes = Math.ceil(milliseconds / 60000);
milliseconds -= minutes * 60000;
var seconds = Math.ceil(milliseconds / 1000);
milliseconds -= seconds * 1000;
var cdString = '';
if (days < 0)
cdString += Math.abs(days) + ' ';
if (days < 0 || hours < 0)
cdString += Math.abs(hours) + ':';
if (days < 0 || hours < 0 || minutes < 0)
cdString += Math.abs(minutes).toString().padStart(2, '0') + ':';
cdString += Math.abs(seconds).toString().padStart(2, '0');
countdownWrite(cdString);
if (days >= 0 && hours >= 0 && minutes >= 0 && seconds <= 0) {
var scale = 1;
if (seconds < 0)
scale += 4 * Math.pow((60 + seconds) / 60, 2);
countdownContainer.style.transform = 'scale(' + scale + ')';
}
}
function countdownWrite(str) {
if ((typeof str) !== 'string')
str = str.toString();
countdownLastString = str;
countdownResize(str.length);
for (var i = 0; i < str.length; i++)
countdownDigits[i].setAttribute('data-digit', str[i]);
}
function checkIfFlashiiReady(continuous) {
continueChecking = !(!continuous);
if (checkClient === null) {
checkClient = new XMLHttpRequest();
checkClient.addEventListener('readystatechange', function () {
if (checkClient.readyState === 4 && checkClient.responseText !== 'no')
location.reload(true);
});
}
checkClient.open('GET', '/is_ready?' + Date.now(), true);
checkClient.send();
if (continueChecking)
checkTimeout = setTimeout(function () { checkIfFlashiiReady(continueChecking); }, 1000);
}
window.addEventListener("load", function () {
var container = document.createElement('div');
container.className = 'countdown-container';
document.getElementById('countdown').appendChild(container);
countdownSetup(container, new Date("Mon, 2 01 2018 1:00:00 +0100"), function () {
checkIfFlashiiReady(true);
});
});
</script>
{% endblock %}
{% block content %}
<div class="platform" style="text-align: left;">
<p>So I have to be honest, when the timer runs out you shouldn't expect a fully functional site. A chat, registration, login and a basic session system will most likely be at most in place though. On the position side of things you get to see the site evolve, so yay!!</p>
<p>In any case I hope you all will enjoy what I have in store going forward. I've also decided to push launch back to the 1st or February because I'll need the time.</p>
<p>Lastly I'd like to add that none of the designs are final, most of this I put together ages ago as an eventual redesign for the old site, since then I haven't done much aside from the work in the last month.</p>
</div>
{% endblock %}