Time read script
Quick win. Add an optional time read script to Playit Cartwall to a presenter can read the time off screen. Top 3/4 of the screen is tiles. 1/4 full width at the bottom is the time read script. Enable or disable in settings. Also include an offset value.
Currently we have PlayIt Cartwall window sized to the 3/4 and a web browser window sized to the bottom 1/4 of screen. It runs on a touchscreen.
The code for the time read is:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<style>
body {
background-color: #20292F;
}
#time {
color: #ffffff;
text-align: center;
font-size: 20pt;
font-family: Arial;
margin-top: 0px;
}
#label {
color: #ffffff;
text-align: center;
font-size: 42pt;
font-family: Arial;
margin-top: 0px;
}
</style>
<script>
function startTime() {
var today = new Date();
var delay = new Date();
delay.setSeconds(delay.getSeconds() + 30)
var h = delay.getHours();
var m = delay.getMinutes();
var s = delay.getSeconds();
document.getElementById('time').innerHTML = formatAMPM(today);
document.getElementById('label').innerHTML = convertNumberToName(h,m);
setTimeout(startTime,100);
}
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
hours = hours < 10 ? '0'+hours : hours;
minutes = minutes < 10 ? '0'+minutes : minutes;
seconds = seconds < 10 ? '0'+seconds : seconds;
var strTime = hours + ':' + minutes + ':' + seconds + ' ' + ampm;
return strTime;
}
function convertHourToName(num) {
if (num > 12) {
num -= 12;
}
return convertNumberToName(num);
}
function convertNumberToName(hh,mm) {
var h, result;
var labels = ["Zero", "One", "Two", "Three",
"Four", "Five", "Six", "Seven", "Eight", "Nine",
"Ten", "Eleven", "Twelve", "Thirteen","Fourteen","Fifteen","Sixteen",
"Seventeen","Eighteen","Nineteen","Twenty",
"Twenty-One", "Twenty-Two","Twenty-Three",
"Twenty-Four","Twenty-Five","Twenty-Six","Twenty-Seven","Twenty-Eight","Twenty-Nine"];
h = hh;
n = hh + 1;
result = "";
if (h > 12) {
h = h - 12;
}
if (n > 12) {
n = n - 12;
}
if (hh==0 && mm==0){
return "Midnight";
}
if (hh==12 && mm==0){
return "Midday";
}
if (mm == 15){
return "Quarter past " + labels[h];
}
if (mm == 45){
return "Quarter to " + labels[h];
}
if (mm == 0) {
return labels[h] + " O'Clock";
}
if (mm == 30){
return "Half past " + labels[h];
}
if (mm == 1){
return labels[mm] + " past " + labels[h];
}
if (mm > 1 && mm < 30){
return labels[mm] + " past " + labels[h];
}
if (mm == 59){
return labels[60 - mm] + " to " + labels[n];
}
if (mm > 30){
return labels[60 - mm] + " to " + labels[n];
}
return result;
}
</script>
</head>
<body onload="startTime()">
<div id="time"></div>
<div id="label"></div>
</body>
</html>