1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // Import Bootstrap
- import 'bootstrap'
- import 'bootstrap/dist/css/bootstrap.min.css'
- // Import own css
- import '../css/index.css'
- // Import SimpleMDE
- import SimpleMDE from 'simplemde'
- import 'simplemde/dist/simplemde.min.css'
- if (document.querySelector('textarea') != null) {
- new SimpleMDE()
- }
- // Javascript
- function countdown() {
- let element = document.querySelector(".countdown")
- let date = element.getAttribute('date');
- let days, hours, minutes, seconds;
-
- let endDate = new Date(date).getTime();
- if (isNaN(endDate)) {
- return;
- }
- let startDate = new Date().getTime();
- if (endDate > startDate) {
- calculate()
- setInterval(calculate, 1000);
- }
- function calculate() {
- let startDate = new Date().getTime();
- let timeRemaining = parseInt((endDate - startDate) / 1000);
-
- if (timeRemaining >= 0) {
- hours = parseInt(timeRemaining / 3600);
- timeRemaining = (timeRemaining % 3600);
-
- minutes = parseInt(timeRemaining / 60);
- timeRemaining = (timeRemaining % 60);
-
- seconds = parseInt(timeRemaining);
-
- document.querySelector(".countdown .hours").innerHTML = ("0" + hours).slice(-2);
- document.querySelector(".countdown .minutes").innerHTML = ("0" + minutes).slice(-2);
- document.querySelector(".countdown .seconds").innerHTML = ("0" + seconds).slice(-2);
- } else {
- window.location.reload(false);
- }
- }
- }
- window.onload = function () {
- if (document.querySelector('.countdown') != null) {
- countdown();
- }
- }
|