User:Peteforsyth/vector.js

$(function { var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],      months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],      $oldPopover;  $('head').append('');  $.getScript("https://en.wikieducator.org/skins/common/we/vendor/jQuery.popover/jquery.popover-1.1.2.js", function { $('.weLTime').click(function {     if ($oldPopover) {        $oldPopover.popover('hide');      }      var t = $(this).attr('title');

event.preventDefault; event.stopPropagation;

$oldPopover = $(this); $(this).popover({       trigger: 'none',        title: 'Local time',        content: t      }).popover('show'); return false; }); });  $('.weLTime').each(function {    function hour(d) {      var a = 'AM',          h = d.getHours;      if (h >= 12) {          h = h - 12;          a = 'PM';      }      if (h === 0) {          h = 12;      }      h = h.toString;      return {h: h, a: a};    }    function minute(d) {      var r = d.getMinutes.toString;      if (r.length === 1) {        r = '0' + r;      }      return r;    }

var t = $(this).attr('title'), d = new Date(t), h = hour(d), m = minute(d), ds = days[d.getDay] + ', ' + months[d.getMonth] + ' ' + d.getDate + ' ' + h.h + ':' + m + h.a + ' ' + d.toString.replace(/.*\(([^)]+)\)$/, '$1');   console.log(t, '->', ds);    $(this).attr('title', ds);  }); })