OBS widget that implements a countdown timer overlay for "Starting Soon..." style displays.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.6 KiB

extends ../layouts/main
block content-container
.interface
.container
.metadata
#show-title Just Joe Radio
#show-url justjoeradio.com
.prompt STARTING SOON
.time-line
#countdown-display.countdown-display
#time-display.time-display
script.
window.dtp = window.dtp || { };
dtp.showTitle = document.getElementById('show-title');
dtp.showUrl = document.getElementById('show-url');
dtp.timeDisplay = document.getElementById('time-display');
dtp.countdown = document.getElementById('countdown-display');
const params = new URLSearchParams(window.location.search);
dtp.showTitle.textContent = params.get('title');
dtp.showUrl.textContent = params.get('url');
const year = parseInt(params.get('year'), 10);
const month = parseInt(params.get('month'), 10) - 1;
const day = parseInt(params.get('date'), 10);
const hours = parseInt(params.get('hours'), 10);
const minutes = parseInt(params.get('minutes'), 10);
dtp.start = new Date(year, month, day, hours, minutes, 0, 0);
function update ( ) {
const NOW = new Date();
const remaining = Math.ceil((dtp.start.valueOf() - NOW.valueOf()) / 1000.0);
dtp.timeDisplay.textContent = moment(NOW).format('hh:mm A');
dtp.countdown.textContent = numeral(remaining).format('00:00:00');
requestAnimationFrame(update);
}
requestAnimationFrame(update);