From 3cc49403c9e033492f7d2e3a812eb56beaa709e7 Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Sun, 9 May 2021 15:19:44 -0400 Subject: [PATCH 1/3] Fix an error attempting to update missing value. The original timezone display was attempting to be updated even when it was not displayed. --- clock.js | 3 ++- clock.php | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clock.js b/clock.js index b58802c..199b124 100644 --- a/clock.js +++ b/clock.js @@ -32,7 +32,8 @@ 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. + //~ alert("display_origTZ == " + display_origTZ); document.getElementById('time_original').innerHTML = current_time.toLocaleString('en-EN' ,{ timeZone: original_tz, hourCycle:'h24', diff --git a/clock.php b/clock.php index 2420058..48af5f7 100644 --- a/clock.php +++ b/clock.php @@ -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 @@ - + From 3e7189690ac219aba4c883f917a05159b7ea2daa Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Sun, 9 May 2021 15:23:27 -0400 Subject: [PATCH 2/3] Remove testing code. --- clock.js | 1 - 1 file changed, 1 deletion(-) diff --git a/clock.js b/clock.js index 199b124..08e8c08 100644 --- a/clock.js +++ b/clock.js @@ -33,7 +33,6 @@ function startTime(){ minute:'2-digit', second:'2-digit',}); 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. - //~ alert("display_origTZ == " + display_origTZ); document.getElementById('time_original').innerHTML = current_time.toLocaleString('en-EN' ,{ timeZone: original_tz, hourCycle:'h24', From 95ad27846a159aee5e0924b6873a626656b10077 Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Sun, 9 May 2021 15:28:56 -0400 Subject: [PATCH 3/3] Add second timestamp copy button. When two timezones are displayed there is now a button to copy each of the timestamps. --- clock.js | 4 ++-- clock.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clock.js b/clock.js index 08e8c08..73f4949 100644 --- a/clock.js +++ b/clock.js @@ -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; diff --git a/clock.php b/clock.php index 48af5f7..687dd6f 100644 --- a/clock.php +++ b/clock.php @@ -48,13 +48,13 @@ "
". "

". date("D, M d, Y, H:i:s") . - "

GMT". date("O T") ."

\n\t\t
"; + "

GMT". date("O T") ."

\n\t\t"; if($_POST['originalTZ']){// if the user want display the browser detected timezone as well as the selected one. date_default_timezone_set($originalTZ); echo'

Time in original Timezone

'. '

'. date("D, M d, Y, H:i:s") . - "

GMT". date("O T") .'

'; + "

GMT". date("O T") ."

"; date_default_timezone_set($scriptTZ); } if($_POST['displayOffset']){