diff options
author | Hiroto Takahashi | 2014-05-07 12:46:34 +0900 |
---|---|---|
committer | Hiroto Takahashi | 2014-05-07 12:46:34 +0900 |
commit | eb20651ddfea323e9138a80b9cdf536022791bdf (patch) | |
tree | c139543230d4431b52c37ad955d9f66bed45c84e | |
parent | c2048181730e1dd258de8311485589fbce50ca59 (diff) | |
download | vimperator-plugins-eb20651ddfea323e9138a80b9cdf536022791bdf.tar.bz2 |
update alert.js add module absolute time setting
-rw-r--r-- | alert.js | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -349,6 +349,14 @@ let PLUGIN_INFO = xml` }; } + function torelativetime(h, m) { + if (h < 0 || h > 24 || m < 0 || m > 59) + return false; + var now = new Date(); + var d = (h * 60 + parseInt(m)) - (now.getHours() * 60 + now.getMinutes() + now.getSeconds() / 60); + return d >= 0 ? d : d + 60 * 24; + } + let alertMethods = { alert: function (next, msg) { window.alert(msg); @@ -436,11 +444,13 @@ let PLUGIN_INFO = xml` function (args) { let methods = [], time = null, message = ''; args.forEach(function (v) { - let m, f; + let m, f, t; if ((m = v.match(/^-(\w+)(?:=(.*))?$/)) && (f = alertMethods[m[1]])) methods.push([f, m[2]]); else if (!time && v.match(/^\d+(\.\d+)?$/)) time = parseFloat(v); + else if (!time && (m = v.match(/^(\d{1,2}):(\d{1,2})$/)) && (t = torelativetime(m[1], m[2]))) + time = parseFloat(t); else message += ' ' + v; }); |