updated deploy scripts and fixed countdown

This commit is contained in:
Benjamin Jones 2020-09-09 12:59:50 +02:00
parent f3b1599857
commit a9ed350d54
6 changed files with 55 additions and 1440 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -5,10 +5,11 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "run-p start-jekyll start-parcel", "start": "run-p start-jekyll start-parcel",
"build": "JEKYLL_ENV=production jekyll build", "build": "yarn build-jekyll && yarn build-parcel",
"start-jekyll": "bundle exec jekyll serve", "start-jekyll": "bundle exec jekyll serve",
"start-parcel": "parcel src/index.js -d assets/js", "start-parcel": "parcel src/index.js -d assets/js",
"build-jekyll": "JEKYLL_ENV=production jekyll build", "build-jekyll": "JEKYLL_ENV=production jekyll build",
"build-parcel": "parcel build src/index.js -d ./_site/assets/js",
"deploy-dev": "yarn build && scp -r -P 7833 ./_site/* amemasu@185.203.114.165:/var/www/dev.reclaimfutures.org", "deploy-dev": "yarn build && scp -r -P 7833 ./_site/* amemasu@185.203.114.165:/var/www/dev.reclaimfutures.org",
"deploy-prod": "yarn build && scp -r -P 7833 ./_site/* amemasu@185.203.114.165:/var/www/reclaimfutures.org" "deploy-prod": "yarn build && scp -r -P 7833 ./_site/* amemasu@185.203.114.165:/var/www/reclaimfutures.org"
}, },
@ -19,7 +20,6 @@
"parcel-bundler": "^1.12.4" "parcel-bundler": "^1.12.4"
}, },
"dependencies": { "dependencies": {
"countdown": "^2.6.0",
"spacetime": "^6.6.3" "spacetime": "^6.6.3"
} }
} }

View File

@ -1,11 +1,13 @@
import scrollHandler from './modules/scrollHandler'; import scrollHandler from './modules/scrollHandler';
import clock from './modules/clock'; import clock from './modules/clock';
import countdownBanner from './modules/countdown'; import countdownTimer from './modules/countdown';
const app = () => { const app = () => {
scrollHandler(); scrollHandler();
clock(); clock();
countdownBanner();
countdownTimer();
setInterval(countdownTimer, 1000);
}; };
app(); app();

View File

@ -1,37 +1,32 @@
import countdown from 'countdown';
const banner = document.getElementById('full-banner'); const banner = document.getElementById('full-banner');
const cdTime = banner?.querySelector('.cd-time'); const cdTime = banner?.querySelector('.cd-time');
let bannerVisible = false;
function getCountdown() { const targetDate = new Date('Wed Sep 18 2020 10:30:00 GMT+0200 (Central European Summer Time)');
return countdown(
new Date(),
new Date('Wed Sep 18 2020 10:30:00 GMT+0200 (Central European Summer Time)'),
0,
3)
.toString();
}
function setCountdown() {
const cd = getCountdown(); function countdownTimer() {
if (cdTime.innerHTML !== cd) { const difference = +new Date(targetDate) - +new Date();
cdTime.innerHTML = cd; let remaining = '';
if (difference > 0) {
const parts = {
days: Math.floor(difference / (1000 * 60 * 60 * 24)),
hours: Math.floor((difference / (1000 * 60 * 60)) % 24),
minutes: Math.floor((difference / 1000 / 60) % 60),
seconds: Math.floor((difference / 1000) % 60),
};
remaining = Object.keys(parts)
.map((part) => {
if (!parts[part]) return;
return `${parts[part]} ${part}`;
})
.join(' ');
cdTime.innerText = remaining;
} else {
banner.querySelector('h1').innerHTML = `ReclaimFutures is now <span class="now-live">[LIVE]</span> <a href="/watch">→ click here to watch</a>`;
} }
} }
const countdownBanner = () => { export default countdownTimer;
if (banner) {
banner.classList.add('hidden');
getCountdown();
if (!bannerVisible) {
banner.classList.remove('hidden');
bannerVisible = true;
}
setInterval(setCountdown, 1000);
}
}
export default countdownBanner;

View File

@ -1633,11 +1633,6 @@ cosmiconfig@^5.0.0:
js-yaml "^3.13.1" js-yaml "^3.13.1"
parse-json "^4.0.0" parse-json "^4.0.0"
countdown@^2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/countdown/-/countdown-2.6.0.tgz#677fb8e3a9d4cc4e76415901ba253b518af34177"
integrity sha1-Z3+446nUzE52QVkBuiU7UYrzQXc=
create-ecdh@^4.0.0: create-ecdh@^4.0.0:
version "4.0.4" version "4.0.4"
resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e"