From b38396a8f8aa88915b38ab747b265b089ab96133 Mon Sep 17 00:00:00 2001 From: anekos Date: Fri, 28 Nov 2008 15:38:56 +0000 Subject: added "%a" git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@25288 d0d07461-0603-4401-acd4-de1884942a52 --- clock.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'clock.js') diff --git a/clock.js b/clock.js index c25b504..759513a 100644 --- a/clock.js +++ b/clock.js @@ -4,7 +4,7 @@ * @description clock. * @description-ja とけい。 * @author janus_wel - * @version 0.11 + * @version 0.12 * @minversion 2.0pre * @maxversion 2.0pre * ==/VimperatorPlugin== @@ -20,6 +20,7 @@ * %t: time hh:mm * %d: day MM/DD * %y: year YYYY + * %a: A abbreviation for the day of the week. * clock_position: id of element that is marker of insert position. * default is 'liberator-commandline-command' ( after commandline ) * clock_after: boolean that show insert after of the element @@ -90,6 +91,9 @@ Clock.prototype = { t: function (label) { return setInterval(function () label.setAttribute('value', time()), 100); }, + a: function (label) { + return setInterval(function () label.setAttribute('value', wday()), 60 * 1000); + }, d: function (label) { return setInterval(function () label.setAttribute('value', day()), 60 * 1000); }, @@ -109,6 +113,16 @@ Clock.prototype = { intervalId: id, }; }, + a: function (self) { + let l = self._master.cloneNode(false); + l.setAttribute('id', self._constants.prefix + 'wday'); + l.setAttribute('value', weekDay()); + let id = self._constants.driver.a(l); + return { + node: l, + intervalId: id, + }; + }, d: function (self) { let l = self._master.cloneNode(false); l.setAttribute('id', self._constants.prefix + 'day'); @@ -236,6 +250,12 @@ function time() { if (min.length < 2) min = '0' + min; return hour + (now.getMilliseconds() < 400 ? ' ' : ':') + min; } +function weekDay() { + const wdays = 'sun mon tue wed thu fri sat'.split(/%s/); + let now = new Date(); + return now.toLocaleFormat ? now.toLocaleFormat('%a') + : wdays[now.getDay()]; +} function day() { let now = new Date(); let date = now.getDate().toString(10); -- cgit v1.2.3