aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/widgets/clock
diff options
context:
space:
mode:
Diffstat (limited to 'Neutron-trunk/widgets/clock')
-rw-r--r--Neutron-trunk/widgets/clock/feature.json15
-rw-r--r--Neutron-trunk/widgets/clock/source.php96
2 files changed, 111 insertions, 0 deletions
diff --git a/Neutron-trunk/widgets/clock/feature.json b/Neutron-trunk/widgets/clock/feature.json
new file mode 100644
index 0000000..70db617
--- /dev/null
+++ b/Neutron-trunk/widgets/clock/feature.json
@@ -0,0 +1,15 @@
+{
+ "name": {
+ "en": "Clock",
+ "fr": "Horloge"
+ },
+ "description": {
+ "en": "Shows the current time in a widget",
+ "fr": "Affiche un widget contenant l'heure"
+ },
+
+ "config": null,
+ "class": null,
+
+ "cache": true
+} \ No newline at end of file
diff --git a/Neutron-trunk/widgets/clock/source.php b/Neutron-trunk/widgets/clock/source.php
new file mode 100644
index 0000000..04c3939
--- /dev/null
+++ b/Neutron-trunk/widgets/clock/source.php
@@ -0,0 +1,96 @@
+<div id="widget-space">
+ <div style="text-align: center;"><h3 id="widget-clock-time">00:00:00</h3><span id="widget-clock-date">????? ??? ??????? ????</span></div>
+</div>
+<script>
+
+setInterval(() => {
+ time = new Date()
+ hours = time.getHours()
+ minutes = time.getMinutes()
+ seconds = time.getSeconds()
+ day = time.getDate()
+ month = time.getMonth() + 1
+ year = time.getFullYear()
+ dow = time.getDay() + 1
+ if (hours < 10) {
+ hours_str = "0" + hours
+ } else {
+ hours_str = hours
+ }
+ if (minutes < 10) {
+ minutes_str = "0" + minutes
+ } else {
+ minutes_str = minutes
+ }
+ if (seconds < 10) {
+ seconds_str = "0" + seconds
+ } else {
+ seconds_str = seconds
+ }
+ if (day == 1) {
+ day_str = "<?= $lang["widgets"]["clock"]["ordinal"] ?>"
+ } else {
+ day_str = day
+ }
+ if (dow == 2) {
+ dow_str = "<?= $lang["widgets"]["clock"]["days"][0] ?>"
+ }
+ if (dow == 3) {
+ dow_str = "<?= $lang["widgets"]["clock"]["days"][1] ?>"
+ }
+ if (dow == 4) {
+ dow_str = "<?= $lang["widgets"]["clock"]["days"][2] ?>"
+ }
+ if (dow == 5) {
+ dow_str = "<?= $lang["widgets"]["clock"]["days"][3] ?>"
+ }
+ if (dow == 6) {
+ dow_str = "<?= $lang["widgets"]["clock"]["days"][4] ?>"
+ }
+ if (dow == 7) {
+ dow_str = "<?= $lang["widgets"]["clock"]["days"][5] ?>"
+ }
+ if (dow == 1) {
+ dow_str = "<?= $lang["widgets"]["clock"]["days"][6] ?>"
+ }
+ if (month == 1) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][0] ?>"
+ }
+ if (month == 2) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][1] ?>"
+ }
+ if (month == 3) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][2] ?>"
+ }
+ if (month == 4) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][3] ?>"
+ }
+ if (month == 5) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][4] ?>"
+ }
+ if (month == 6) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][5] ?>"
+ }
+ if (month == 7) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][6] ?>"
+ }
+ if (month == 8) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][7] ?>"
+ }
+ if (month == 9) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][8] ?>"
+ }
+ if (month == 10) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][9] ?>"
+ }
+ if (month == 11) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][10] ?>"
+ }
+ if (month == 12) {
+ month_str = "<?= $lang["widgets"]["clock"]["months"][11] ?>"
+ }
+ document.getElementById('widget-clock-time').innerHTML = hours_str + ":" + minutes_str + ":" + seconds_str
+ document.getElementById('widget-clock-date').innerHTML = dow_str + " " + day_str + " " + month_str + " " + year
+}, 100)
+
+</script> \ No newline at end of file