From ae032a8c4c7da5ea77cdc6f99c3a85ae86cbb858 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Fri, 29 Jan 2010 00:12:46 +0100 Subject: new navigation with times --- timepollhead.rb | 127 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 88 insertions(+), 39 deletions(-) (limited to 'timepollhead.rb') diff --git a/timepollhead.rb b/timepollhead.rb index ab0454e..febcf37 100644 --- a/timepollhead.rb +++ b/timepollhead.rb @@ -35,7 +35,7 @@ class TimePollHead def col_size @data.size end - + # returns a sorted array of all columns # column should be the internal representation # column.to_s should deliver humanreadable form @@ -140,12 +140,79 @@ class TimePollHead ret end + def datenavi val,revision + case val + when MONTHBACK + navimonth = Date.parse("#{@startdate.strftime("%Y-%m")}-1")-1 + when MONTHFORWARD + navimonth = Date.parse("#{@startdate.strftime("%Y-%m")}-1")+31 + else + raise "Unknown navi value #{val}" + end + return < +
+
+ + + + + +
+
+ +END + end + def timenavi val,revision + return "" if @firsttime == 0 || @lasttime == 23 + case val + when _("Earlier") + firsttime = [@firsttime-2,0].max + lasttime = @lasttime + when _("Later") + firsttime = @firsttime + lasttime = [@lasttime+2,23].min + else + raise "Unknown navi value #{val}" + end + return < + +
+
+ + + + + +
+
+ + +END + end + + def edit_column_htmlform(activecolumn, revision) + # calculate start date, first and last time to show if $cgi.include?("add_remove_column_month") - startdate = Date.parse("#{$cgi["add_remove_column_month"]}-1") + @startdate = Date.parse("#{$cgi["add_remove_column_month"]}-1") else - startdate = Date.parse("#{Date.today.year}-#{Date.today.month}-1") + @startdate = Date.parse("#{Date.today.year}-#{Date.today.month}-1") end + + times = concrete_times + realtimes = times.collect{|t| Time.parse(t) if t =~ /\d\d:\d\d/}.compact + [9,16].each{|i| realtimes << Time.parse("#{i.to_s.rjust(2,"0")}:00")} + + ["firsttime","lasttime"].each{|t| + realtimes << Time.parse($cgi[t]) if $cgi.include?(t) + } + + @firsttime = realtimes.min.strftime("%H").to_i + @lasttime = realtimes.max.strftime("%H").to_i + + hintstr = _("Click on the dates to add or remove columns.") ret = < @@ -154,40 +221,19 @@ class TimePollHead END - def navi val,curmonth,revision - case val - when MONTHBACK - navimonth = Date.parse("#{curmonth}-1")-1 - when MONTHFORWARD - navimonth = Date.parse("#{curmonth}-1")+31 - else - raise "Unknown navi value #{val}" - end - return < -
-
- - - -
- - -END - end - ret += navi(MONTHBACK,startdate,revision) - ret += "
" - ret += navi(MONTHFORWARD,startdate,revision) + ret += datenavi(MONTHBACK,revision) + ret += "" + ret += datenavi(MONTHFORWARD,revision) ret += "\n" 7.times{|i| ret += "" } ret += "\n" - ((startdate.wday+7-1)%7).times{ + ((@startdate.wday+7-1)%7).times{ ret += "" } - d = startdate + d = @startdate while true do klasse = "notchosen" varname = "new_columnname" @@ -201,15 +247,17 @@ END
- - + + + +
TD d = d.next - break if d.month != startdate.month + break if d.month != @startdate.month ret += "\n" if d.wday == 1 end ret += < _("past") } - times = concrete_times - realtimes = times.collect{|t| Time.parse(t) if t =~ /\d\d:\d\d/}.compact - [9,16].each{|i| realtimes << Time.parse("#{i.to_s.rjust(2,"0")}:00")} - first = realtimes.min.strftime("%H").to_i - last = realtimes.max.strftime("%H").to_i + ret += timenavi(_("Earlier"),revision) - (first..last).each{|i| times << "#{i.to_s.rjust(2,"0")}:00" } + (@firsttime..@lasttime).each{|i| times << "#{i.to_s.rjust(2,"0")}:00" } times.flatten.compact.uniq.sort.each{|time| - ret +="\n" + ret +="\n" days.each{|day| timestamp = TimeString.new(day,time) klasse = "notchosen" @@ -290,6 +334,8 @@ END ret += < + + @@ -299,6 +345,7 @@ END } ret += "\n" } + ret += timenavi(_("Later"),revision) ret += "" days.each{|d| @@ -308,6 +355,8 @@ END
+ + END if @data.include?(TimeString.new(d,nil)) -- cgit v1.2.3
#{startdate.strftime('%b %Y')}#{@startdate.strftime('%b %Y')}
#{Date::ABBR_DAYNAMES[(i+1)%7]}
#{time}