aboutsummaryrefslogtreecommitdiffstats
path: root/include/widgets.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-03-05 04:28:48 -0800
committerfriendica <info@friendica.com>2014-03-05 04:28:48 -0800
commitd58abc0230e07663ce543088c186639d36f82f02 (patch)
tree474ebb0f31063805d8b95dcddc22d4345c989936 /include/widgets.php
parent61f47cd5ed6eee337d9ab30b65844b5118080b76 (diff)
downloadvolse-hubzilla-d58abc0230e07663ce543088c186639d36f82f02.tar.gz
volse-hubzilla-d58abc0230e07663ce543088c186639d36f82f02.tar.bz2
volse-hubzilla-d58abc0230e07663ce543088c186639d36f82f02.zip
add clock widget and correct some doco
Diffstat (limited to 'include/widgets.php')
-rw-r--r--include/widgets.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/include/widgets.php b/include/widgets.php
index 8d8eef160..90586397f 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -649,4 +649,60 @@ function widget_item($arr) {
$o .= prepare_page($r[0]);
return $o;
+}
+
+function widget_clock($arr) {
+
+ $miltime = 0;
+ if(isset($arr['military']) && $arr['military'])
+ $miltime = 1;
+
+$o = <<< EOT
+<div class="widget">
+<h3 class="clockface"></h3>
+<script>
+
+var timerID = null
+var timerRunning = false
+
+function stopclock(){
+ if(timerRunning)
+ clearTimeout(timerID)
+ timerRunning = false
+}
+
+function startclock(){
+ stopclock()
+ showtime()
+}
+
+function showtime(){
+ var now = new Date()
+ var hours = now.getHours()
+ var minutes = now.getMinutes()
+ var seconds = now.getSeconds()
+ var military = $miltime
+ var timeValue = ""
+ if(military)
+ timeValue = hours
+ else
+ timeValue = ((hours > 12) ? hours - 12 : hours)
+ timeValue += ((minutes < 10) ? ":0" : ":") + minutes
+// timeValue += ((seconds < 10) ? ":0" : ":") + seconds
+ if(! military)
+ timeValue += (hours >= 12) ? " P.M." : " A.M."
+ $('.clockface').html(timeValue)
+ timerID = setTimeout("showtime()",1000)
+ timerRunning = true
+}
+
+$(document).ready(function() {
+ startclock();
+});
+
+</script>
+</div>
+EOT;
+return $o;
+
} \ No newline at end of file