12 Commits

Author SHA1 Message Date
20xd6 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
20xd6 cb83a330ef Update 'clock.css'
CSS portion of fix for issue #8
2021-11-19 17:17:01 -05:00
20xd6 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
20xd6 fb2e531f0d Merge pull request 'display_fix' (#7) from display_fix into master
Reviewed-on: #7
2021-05-09 15:45:29 -04:00
20xd6 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
20xd6 3e7189690a Remove testing code. 2021-05-09 15:23:27 -04:00
20xd6 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
20xd6 dbad2b51a4 Merge pull request 'Merge change in prod into master branch.' (#6) from prod into master
Reviewed-on: #6
2021-05-09 15:05:13 -04:00
20xd6 e06839d684 Merge branch 'master' into prod 2021-05-09 15:04:06 -04:00
20xd6 163b2fdb3a Add readme to prod 2021-05-09 12:32:14 -04:00
20xd6 732a063229 Add Copy Timestamp
A button that will copy the current timestamp has been added.
2021-05-09 12:28:02 -04:00
20xd6 004fe37680 Merge pull request 'Resolution for #1' (#2) from timefix into master
Reviewed-on: #2
2020-09-27 17:17:30 -04:00
4 changed files with 52 additions and 4 deletions
+31
View File
@@ -0,0 +1,31 @@
# WebClock
It's a clock. It runs in your browser.
#### Description
A simple clock for your web based timekeeping needs.
Includes the abality to set the timezone you want if the one your browser chooes isn't what you need.
The time will appear not only on the main page but also in the page's title so you can leave the page and still keep an eye on the time.
#### Requierments
```
php - I'm running it on a minimum of 5.6 so that or anything newer should work
a webserver - I use apache. It's nice.
A javascript interpriter - Basicaly a modernish webbrowser.
```
### Install
1. git clone into a directory accessable by your webserver.
`git clone https://efrick.ddns.net/git/20xd6/WebClock.git`
2. Optional steps
1. Edit `clock.php` to point to your root CSS files. _It points to a css file called `styles.css` in the root directory. If this is not your root css file please edit it._
2. Add a symlink from `clock.php` to a file called `index.php`.
`ln -s clock.php index.php` _Most webservers will look for an index file (`index.html` or `index.php` for example) in any folder you open. Adding this symlink will inable you to link to the direcoty rather than `clock.php` without messing with the configuration of the webserver._
#### Note:
There is a small privacy concern. Because this clock is using PHP to creat the inishal time entry and because this is using the `date()` function in PHP to do this it will reveal what timezone the server running it is set to.
### ToDo
- [x] Add a differentiator from the selected timezone and the original timezone.
- [x] Display original timezone's time.
- [x] Display the offset of the two selected timezones.
- [ ] Add a timer.
- [ ] Multiple clocks for tracking regions. _this is sort of implemented with the display original timezone feature but not compleatly and not how I want it._
#### Licening
##### GPLv2
A copy of the GPLv2 can be fond [here](https://efrick.ddns.net/GPLv2.txt).
+3
View File
@@ -7,3 +7,6 @@ select {
.chkbox {
display: inline-block;
}
.time_copy_btn {
margin-left: 5px;
}
+12 -1
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',
@@ -46,3 +46,14 @@ function startTime(){
}
//document.getElementById('JStz').innerHTML = current_tz;
}
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;
temp_element.select();
temp_element.setSelectionRange(0,999);
document.execCommand("copy");
document.body.removeChild(temp_element);
}
+6 -3
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>\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']){