7 Commits

Author SHA1 Message Date
e9425d87d2 Fix error adding class to copy buttons
The quotes arround the class assignment had not been properly escaped.
This was causing PHP to fail and return a blank page.
2021-11-23 08:54:28 -05:00
cb83a330ef Update 'clock.css'
CSS portion of fix for issue #8
2021-11-19 17:17:01 -05:00
7df5bbd271 Fix a display issue #8
Update index.php with class tags for the timestamp copy buttons.
2021-11-19 17:12:43 -05:00
fb2e531f0d Merge pull request 'display_fix' (#7) from display_fix into master
Reviewed-on: #7
2021-05-09 15:45:29 -04:00
95ad27846a Add second timestamp copy button.
When two timezones are displayed there is now a button to copy each of
the timestamps.
2021-05-09 15:28:56 -04:00
3e7189690a Remove testing code. 2021-05-09 15:23:27 -04:00
3cc49403c9 Fix an error attempting to update missing value.
The original timezone display was attempting to be updated even when it
was not displayed.
2021-05-09 15:19:44 -04:00
3 changed files with 12 additions and 6 deletions

View File

@@ -7,3 +7,6 @@ select {
.chkbox {
display: inline-block;
}
.time_copy_btn {
margin-left: 5px;
}

View File

@@ -32,7 +32,7 @@ function startTime(){
hour:'2-digit',
minute:'2-digit',
second:'2-digit',});
if(original_tz){//Test if there is a non-null value for original_tz. If True then the part of the page this pertains to is being displayed.
if(display_origTZ){//Test if there is a non-null value for original_tz. If True then the part of the page this pertains to is being displayed.
document.getElementById('time_original').innerHTML = current_time.toLocaleString('en-EN' ,{
timeZone: original_tz,
hourCycle:'h24',
@@ -47,8 +47,8 @@ function startTime(){
//document.getElementById('JStz').innerHTML = current_tz;
}
function copy_timestamp() {
var copyText = document.getElementById("time_body").innerText;
function copy_timestamp(to_copy) {
var copyText = document.getElementById(to_copy).innerText;
var temp_element = document.createElement("textarea");
document.body.appendChild(temp_element)
temp_element.value = copyText;

View File

@@ -15,6 +15,9 @@
$scriptHour = date('O');
$scriptTZ = date_default_timezone_get();
}
if($_POST['originalTZ']){
$orig_TZ_display = True;
}
} else{
$selectedTimezone = date_default_timezone_get();
$scriptTZ = date_default_timezone_get();
@@ -32,7 +35,7 @@
<meta name="author" content="efrick"/>
<link href="/styles.css" type="text/css" rel="stylesheet"/>
<link href="clock.css" type="text/css" rel="stylesheet"/>
<script>var current_tz=<?php echo json_encode($scriptTZ) . ',original_tz = ' . json_encode($originalTZ);?></script>
<script>var current_tz=<?php echo json_encode($scriptTZ) . ',original_tz = ' . json_encode($originalTZ) . ',display_origTZ = ' . json_encode($orig_TZ_display);?></script>
<script type="text/javascript" src="clock.js"></script>
</head>
<body>
@@ -45,13 +48,13 @@
"<br><span>".
"<p id='time_body'>".
date("D, M d, Y, H:i:s") .
"</p><p> GMT". date("O T") ."</p><button onclick='copy_timestamp()'>Copy Timestamp</button>\n\t\t</span>";
"</p><p> GMT". date("O T") ."</p><button class=\"time_copy_btn\" onclick='copy_timestamp(\"time_body\")'>Copy Timestamp</button>\n\t\t</span>";
if($_POST['originalTZ']){// if the user want display the browser detected timezone as well as the selected one.
date_default_timezone_set($originalTZ);
echo'<h3>Time in original Timezone</h3>'.
'<span><p id="time_original">'.
date("D, M d, Y, H:i:s") .
"</p><p> GMT". date("O T") .'</p></span>';
"</p><p> GMT". date("O T") ."</p><button class=\"time_copy_btn\" onclick='copy_timestamp(\"time_original\")'>Copy Timestamp</button></span>";
date_default_timezone_set($scriptTZ);
}
if($_POST['displayOffset']){