svnno****@sourc*****
svnno****@sourc*****
2009年 6月 22日 (月) 20:21:31 JST
Revision: 1225 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1225 Author: dhrname Date: 2009-06-22 20:21:31 +0900 (Mon, 22 Jun 2009) Log Message: ----------- Dateオブジェクトに_synchParserメソッドを追加 Modified Paths: -------------- branches/05x/051/sie.js Modified: branches/05x/051/sie.js =================================================================== --- branches/05x/051/sie.js 2009-06-14 13:36:42 UTC (rev 1224) +++ branches/05x/051/sie.js 2009-06-22 11:21:31 UTC (rev 1225) @@ -1841,16 +1841,83 @@ partialClock = str.match(/(\d\d)\:([\.\d]+)/); min = RegExp.$1; s = RegExp.$2; } - d = parseInt(h)*3600000 + parseInt(min)*6000 + parseFloat(s)*1000; + d = parseInt(h,10)*3600000 + parseInt(min,10)*6000 + parseFloat(s,10)*1000; } this.clockValue = d; } Date.prototype._tani = {"h":3600000, "min":6000, "s":1000, "ms":1}; +//isFiredメソッド。イベントが発火されたかどうか。返す値はBoolean型。 +Date.prototype.isFired = function(s) { + if (s >= this.clockValue && !this.indefinite) { + return true; + } else { + return false; + } +} +//_synchParserメソッド。begin属性の値などの解析を行う。 +Date.prototype._synchParser(str) { + var mode = 0, pool = "", midValue = idValue = null; + for (var i=0,sti=str.length;i<stri;++i) { + var stri = str.charAt(i); + switch (mode) { + case 0: + if ("+-".indexOf(stri) !== -1 || stri.test(/[1-9]/)) { + mode = 1; + } else { + mode = 12; + } + break; + case 1: + break; + case 2: + if ("begin|end".indexOf(midValue) !== -1) { + mode = 3; + } else if (midValue.indexOf("accessKey(") === 0) { + mode = 4; + } else if (midValue.indexOf("repeat(") === 0) { + mode = 5; + } + case 3: + case 4: + case 5: + pool += stri; + break; + case 12: + if (stri === ".") { + idValue = pool; + pool = ""; + break; + } else if("+-".indexOf(stri) !== -1) { //符号ならば + midValue = pool; + pool = ""; + mode = 2; + } + pool += stri; + break; + } + } + if (mode === 1) { + this.setClockValue(str); + } else if (mode === 12) { + midValue = pool; + } else { + this.setClockValue(pool); + } + this.id = idValue; + this.event = midValue || pool; +} +var beginEvent = new Date(), endEvent = new Date(), _currentTime = 0; +beginEvent.setClockValue("00:02"); +endEvent.setClockValue("00:04"); +beginEvent.indefinite = false; +endEvent.indefinite = false; +setInterval((function() { + if (beginEvent.isFired(_currentTime) && !endEvent.isFired(_currentTime)) { + alert(""); + } + _currentTime += 100; +}),41) -var ddnd = new Date(); -ddnd.setClockValue("40min"); -alert(ddnd.clockValue); - function utf16( /*string*/ s) { return unescape(s); }