(function(){ Widget={}; window.openWidget=null; monthName=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; dayName=["Su","Mo","Tu","We","Th","Fr","Sa"]; meridiem=["AM","PM"]; AM=0; PM=1; function getStyle(el,_2){ if(window.getComputedStyle){ return window.getComputedStyle(el,null).getPropertyValue(_2); }else{ if(el.currentStyle){ return el.currentStyle[_2]; } } } function getPos(el){ var _4=0; var _5=0; if(el.offsetParent){ for(;el;el=el.offsetParent){ var _6=getStyle(el,"position"); if(_6=="absolute"||_6=="relative"){ break; } _4+=el.offsetTop; _5+=el.offsetLeft; } } return [_4,_5]; } function clearTime(_7){ _7.setHours(0); _7.setMinutes(0); _7.setSeconds(0); _7.setMilliseconds(0); return _7; } Widget.Interval=function(_8){ if(typeof _8=="string"){ _8=document.getElementById(_8); } this.parent=_8; this.value=document.createElement("input"); this.value.type="text"; this.value.size=10; this.value.style.textAlign="right"; this.value.value="1"; this.value.onfocus=function(){ if(window.openWidget){ window.openWidget.hide(); } }; this.unit=document.createElement("select"); this.unit.options[0]=new Option("minute","60"); this.unit.options[1]=new Option("hour","3600"); this.unit.options[2]=new Option("day","86400"); this.unit.selectedIndex=2; this.unit.onfocus=function(){ if(window.openWidget){ window.openWidget.hide(); } }; var _9=document.createTextNode(" "); _8.appendChild(this.value); _8.appendChild(_9); _8.appendChild(this.unit); }; Widget.Interval.prototype.set=function(_a){ this.value.value=_a; }; Widget.Interval.prototype.get=function(){ var v=parseInt(this.value.value); var u=parseInt(this.unit.value); v*=u; if(v<60){ v=60; } return v; }; Widget.Calendar=function(_d){ this.datetime=_d; this.div=document.createElement("div"); this.div.className="calendar"; this.div.style.display="none"; this.datetime.parent.appendChild(this.div); }; Widget.Calendar.prototype.update=function(_e){ function relDate(_f,_10,_11){ var _11=(_11=="y"?"FullYear":"Month"); var _12=new Date(_f); _12["set"+_11](_f["get"+_11]()+_10); if(_12.getDate()!=_f.getDate()){ _12.setDate(0); } return (" class=\"link\" onclick=\"window.openWidget.update("+_12.valueOf()+")\""); } if(typeof _e=="number"){ _e=new Date(_e); }else{ if(typeof _e=="string"){ var dt=new Date(); parseDate(_e,dt); _e=dt; } } var _14=clearTime(new Date()); var _15=clearTime(new Date(1000*this.datetime.get())); var _16=new Date(_e); _16.setDate(1); _16.setDate(1-(6+_16.getDay())%7); var _17=""+""+""; _17+=""; for(var i=0;i<7;i++){ _17+=""; } _17+=""; var day,_1a,_1b=new Date(_16); while(_1b.getMonth()==_e.getMonth()||_1b.getMonth()==_16.getMonth()){ _17+=""; for(var _1c=0;_1c<7;_1c++){ cls=["day"]; day=_1b.getDate(); _1a=_1b.getMonth(); if(_1b.getMonth()!=_e.getMonth()){ cls[cls.length]="othermonth"; } if(_1b.getDay()==0||_1b.getDay()==6){ cls[cls.length]="weekend"; } if(_1b.valueOf()==_14.valueOf()){ cls[cls.length]="today"; } if(_1b.valueOf()==_15.valueOf()){ cls[cls.length]="selected"; } _17+=""; _1b.setDate(++day); while(_1b.getDate()!=day&&_1b.getMonth()==_1a){ alert(day+"\n"+_1b+"\n"+new Date()); _1b.setHours(_1b.getHours+1); _1b=clearTime(_1b); } } _17+=""; } _17+="
"+""+"\"Previous"+""+"\"Previous"+""+monthName[_e.getMonth()]+" "+_e.getFullYear()+""+"\"Next"+""+"\"Next"+"\"[X]\"
"+dayName[(1+i)%7]+"
"+day+"
"; this.div.innerHTML=_17; }; Widget.Calendar.prototype.hide=function(ts){ this.div.style.display="none"; window.openWidget=null; if(ts){ this.datetime.set(ts); } }; Widget.Calendar.prototype.show=function(_1e){ if(window.openWidget&&window.openWidget!=this){ window.openWidget.hide(); } if(_1e){ this.update(_1e); } var pos=getPos(this.datetime.date); var _20=this.datetime.date.offsetHeight; this.div.style.position="absolute"; this.div.style.top=(pos[0]+_20)+"px"; this.div.style.left=pos[1]+"px"; this.div.style.display="inline"; window.openWidget=this; }; Widget.TimePicker=function(_21){ this.datetime=_21; this.div=document.createElement("div"); this.div.className="timepicker"; this.div.style.display="none"; this.datetime.parent.appendChild(this.div); }; Widget.TimePicker.prototype.update=function(_22){ function entry(hr,mer,_25,_26){ var cls=""; if(hr==_25&&mer==_26){ cls="class=\"selected\" "; } var _28=""+hr+meridiem[mer]+""); return _28; } var _29=""; _29+=(""+""); var _2a=new Date(1000*this.datetime.get()); var _2b=_2a.getHours(); var _2c=AM; if(_2b>=12){ _2b-=12; _2c=PM; } if(_2b==0){ _2b=12; } for(var i=0;i<12;++i){ var hr=i; if(i==0){ hr=12; } _29+=(""+entry(hr,AM,_2b,_2c)+entry(hr,PM,_2b,_2c)+""); } _29+="
Hour"+"\"[X]\"
"; this.div.innerHTML=_29; }; Widget.TimePicker.prototype.hide=function(_2f){ this.div.style.display="none"; window.openWidget=null; if(_2f){ this.datetime.time.value=_2f; } }; Widget.TimePicker.prototype.show=function(_30){ if(window.openWidget&&window.openWidget!=this){ window.openWidget.hide(); } if(_30){ this.update(_30); } var pos=getPos(this.datetime.time); var _32=this.datetime.time.offsetHeight; this.div.style.position="absolute"; this.div.style.top=(pos[0]+_32)+"px"; this.div.style.left=pos[1]+"px"; this.div.style.display="inline"; window.openWidget=this; }; Widget.DateTime=function(_33){ var _34=this; if(typeof _33=="string"){ _33=document.getElementById(_33); } this.parent=_33; this.date=document.createElement("input"); this.date.type="text"; this.date.size=10; this.date.style.textAlign="right"; this.date.onfocus=function(){ _34.cal.show(_34.date.value); }; this.cal=new Widget.Calendar(this); var _35=document.createTextNode(" "); this.time=document.createElement("input"); this.time.type="text"; this.time.size=7; this.time.onfocus=function(){ _34.tpick.show(_34.time.value); }; this.tpick=new Widget.TimePicker(this); _33.appendChild(this.date); _33.appendChild(_35); _33.appendChild(this.time); }; Widget.DateTime.prototype.set=function(ts){ if(typeof ts=="number"){ var dt=new Date(1000*ts); }else{ dt=ts; } this.date.value=formatDate(dt,"M/d/y"); this.time.value=formatDate(dt,"h:mma"); }; Widget.DateTime.prototype.get=function(){ if(this.date.value==""){ return 0; } var dt=new Date(); parseDate(this.date.value+" "+this.time.value,dt); return dt.getTime()/1000; }; Widget.TimeRange=function(_39){ var _3a=this; if(typeof _39=="string"){ _39=document.getElementById(_39); } this.parent=_39; this.callback=null; this.start=null; this.end=null; this.outputFormat="E NNN d, h:mm a"; this.outputFormatYear="y, E NNN d, h:mm a"; this.output=document.createElement("span"); this.output.className="link"; this.output.setAttribute("title","Click here to enter time-range to display"); this.output.onclick=function(){ _3a.clicked(this); }; this.input=document.createElement("span"); this.input.className="input"; this.start=new Widget.DateTime(this.input); this.dash=document.createTextNode(" - "); this.input.appendChild(this.dash); this.end=new Widget.DateTime(this.input); var _3b=document.createTextNode(" "); this.button=document.createElement("input"); this.button.type="button"; this.button.value="Set"; this.button.onclick=function(){ _3a.submitted(this); }; this.button.onfocus=function(){ if(window.openWidget){ window.openWidget.hide(); } }; this.input.appendChild(_3b); this.input.appendChild(this.button); this.input.style.display="none"; _39.appendChild(this.output); _39.appendChild(this.input); }; Widget.TimeRange.prototype.setCallback=function(_3c){ this.callback=_3c; }; Widget.TimeRange.prototype.clicked=function(_3d){ if(this.startDate){ this.start.set(this.startDate); } if(this.endDate){ this.end.set(this.endDate); } this.output.style.display="none"; this.input.style.display="inline"; }; Widget.TimeRange.prototype.submitted=function(_3e){ this.startDate=new Date(1000*this.start.get()); this.endDate=new Date(1000*this.end.get()); this.show(this.startDate,this.endDate); this.output.style.display="inline"; this.input.style.display="none"; if(this.callback){ this.callback(this.startDate,this.endDate); } }; Widget.TimeRange.prototype.show=function(_3f,_40){ var _41=this.outputFormat; var now=new Date(); if(_3f.getFullYear()!=_40.getFullYear()||_3f.getFullYear()!=now.getFullYear()){ _41=this.outputFormatYear; } this.startDate=_3f; this.endDate=_40; var _43=formatDate(_3f,_41); var _44=formatDate(_40,_41); var txt=document.createTextNode(_43+" - "+_44); if(this.output.firstChild){ this.output.removeChild(this.output.firstChild); } this.output.appendChild(txt); }; })();