/* Array extra support (ver 1.0 / 2005-09-13) by ma.la http://ma.la/ Licence: GPL http://www.gnu.org/copyleft/gpl.html */ Array.prototype.forEach = function(callback,thisObject){ for(var i=0,len=this.length;i max) ? max : max-(fromIndex||0) || max; for(;i>=0;i--) if(searchElement === this[i]) return i; return -1 } Array.prototype.every = function(callback,thisObject){ for(var i=0,len=this.length;i [[1,2,3],[4,5]] Array.prototype.splitTo = function(num){ var per = Math.ceil(this.length / num); return this.splitter(function(v,i){return i%per==per-1}); } /* date_extra.js */ if(typeof Locale == "undefined") Locale = {}; Locale.jp = { abday : ["日", "月", "火", "水", "木", "金", "土"], day : ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"], abmon : [" 1月", " 2月", " 3月", " 4月", " 5月", " 6月", " 7月", " 8月", " 9月", "10月", "11月", "12月"], mon : ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"], d_t_fmt : "%Y年%m月%d日 %H時%M分%S秒", d_fmt : "%Y年%m月%d日", t_fmt : "%H時%M分%S秒", am_pm : ["午前", "午後"], t_fmt_ampm : "%p%H時%M分%S秒" } Locale.en = { abday : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], day : ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], abmon : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], mon : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], d_t_fmt : "%a %b %d %Y", d_fmt : "%d/%m/%Y", t_fmt : "%H:%M:%S", am_pm : ["AM", "PM"] } // locale指定、グローバル Date.setLocale = function(lc){ Date.prototype.locale = lc } // locale指定、そのオブジェクトに対してのみ Date.prototype.setLocale = function(lc){ this.locale = lc; return this; } // うるう年を判別する Date.isleap = function(year){ return ((year % 400) == 0) ? 1 : ((year % 100) == 0) ? 0 : ((year % 4) == 0) ? 1 : 0; } Date.prototype.isleap = function(){ return Date.isleap(this.getFullYear()) } Date.month_yday = [ [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365], [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366] ]; /* tm object like ruby mon : 1-12 yday: 1-366 */ Date.prototype.tm = function(){ with(this){return { year : getFullYear(), mon : getMonth() + 1, mday : getDate(), yday : Date.month_yday[isleap()][getMonth()] + getDate(), wday : getDay(), hour : getHours(), min : getMinutes(), sec : getSeconds() }} } /* http://www.microsoft.com/japan/msdn/library/default.asp?url=/japan/msdn/library/ja/cpref/html/frlrfSystemGlobalizationDateTimeFormatInfoClassTopic.asp */ Date.prototype.toObject = function(){ var zerofill = function(keta){ return function(){return ("0".x(keta) + this).slice(-keta)} } with(this.tm()){ var o = { yyyy : year, M : mon, d : mday, t : Locale[this.locale].am_pm[(hour < 12 ) ? 0 : 1], h : hour % 12 || 12, H : hour, m : min, s : sec }} o.yy = this.getYear().format(zerofill(2)); "M d H h m s".split(" ").forEach(function(v){ o[v+v] = o[v].format(zerofill(2)) }); return o; } Date.prototype.strfObject = function(){ var self = this; var tm = this.tm(); var o = this.toObject(); var lc = Locale[this.locale]; var lazy = function(f){ var tmp = {}; tmp.toString = function(){return self.strftime(f)} return tmp; } return { "a" : lc.abday[tm.wday], "A" : lc.day[tm.wday], "b" : lc.abmon[tm.mon-1], "B" : lc.mon[tm.mon-1], "c" : lazy(lc.d_t_fmt), "d" : o.dd, "H" : o.HH, "I" : o.hh, "j" : tm.yday, "M" : o.mm, "m" : o.MM, "p" : o.t, "S" : o.ss, "U" : "", "w" : tm.wday, "W" : "", "x" : lazy(lc.d_fmt), "X" : lazy(lc.t_fmt), "Y" : o.yyyy, "y" : o.yy, "z" : "", "Z" : "" } } Date.prototype.strftime = function(format){ var obj = this.strfObject(); return format.replace(/%(\w{1})/g,function(){ var arg = arguments; return obj[arg[1]] }) } Date.prototype.format = function(){ }; /* Function.prototype */ Function.prototype.isFunction = true; /* インスタンス生成 */ Function.prototype.New = Function.prototype.newInstance = function(){ for(var i=0,arg=[];i