all repos — gears @ main

lightweight world clock webapp with jquery, moment-timezone, and fuse.js

worldClock.js (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
setupClock = function()
{

  $("h3").html("<time>" + formatTime(moment())+ "</time>");
  setInterval(function() {
    $("h3").html("<time>" + formatTime(moment()) + "</time>");
    table.updateNowLine();
  }, 250);
}

setTableRedraw = function()
{
  setInterval(table.draw(), 1000*60*30)
}

setupLocalZone = function()
{
  $("h4").text(moment().format("Z"));
  $("h5").text(moment.tz.guess());
  table.rows.push(moment.tz.guess());
  table.rows.push("UTC");
}

initSimpleInputs = function()
{
  $("#displayWindow").val(24);
  $("#displayWindow").on("change", table.updateWidth);
  $("#earlyLateToggle").prop("checked", true);
  $("#earlyLateToggle").on("change", table.toggleColorCode);
  $("#intervalA").on("change", table.setInterval);
  $("#intervalB").on("change", table.setInterval);
  $("#shareRawText").on("click", interval.copyText)
}

window.zones = moment.tz.names();
window.options =
{
  formatSelector: "24H",
  windowSelector: "aroundNow",
  colorCoding: true
}

window.updateFuncs = [table.draw]

$(document).ready(function()
{
  setupLocalZone();
  setupClock();
  setTableRedraw();
  searchbar.init();
  table.resetSliders();
  initOption("#formatSelector");
  initOption("#windowSelector");
  initSimpleInputs();
  table.draw();
})