aboutsummaryrefslogtreecommitdiff
path: root/pollhead.rb
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-11-24 20:39:56 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-11-24 20:39:56 +0100
commitefd838d9ac1112d3d4cd8bb64951b417a977f4b2 (patch)
treed49990669ef3ec20ac6bb89710518021e6f32901 /pollhead.rb
parent4279e3023c4f437cd4fb996e0535fe09241823cf (diff)
give sort feedback
Diffstat (limited to 'pollhead.rb')
-rw-r--r--pollhead.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/pollhead.rb b/pollhead.rb
index a4a6b8a..87d2cb3 100644
--- a/pollhead.rb
+++ b/pollhead.rb
@@ -78,12 +78,19 @@ class PollHead
end
end
- def to_html(showeditbuttons = false,activecolumn = nil)
- ret = "<tr><th><a href='?sort=name'>Name #{NOSORT}</a></th>\n"
+ def to_html(scols, showeditbuttons = false,activecolumn = nil)
+ def sortsymb(scols,col)
+ scols.include?(col) ? SORT : NOSORT
+ end
+ ret = "<tr>"
+ ret += "<th><a href='?sort=name'>Name #{sortsymb(scols,"name")}</a></th>\n" unless showeditbuttons
@data.each{|columntitle,columndescription|
ret += "<th"
ret += " id='active' " if activecolumn == columntitle
- ret += "><a title=\"#{columndescription}\" href=\"?sort=#{CGI.escapeHTML(CGI.escape(columntitle))}\">#{CGI.escapeHTML(columntitle)} #{NOSORT}</a>"
+ ret += ">"
+ ret += "<a title=\"#{columndescription}\" href=\"?sort=#{CGI.escapeHTML(CGI.escape(columntitle))}\">" unless showeditbuttons
+ ret += "#{CGI.escapeHTML(columntitle)}"
+ ret += " #{sortsymb(scols,columntitle)}</a>" unless showeditbuttons
if showeditbuttons
ret += <<EDITDELETE
<div>
@@ -100,7 +107,7 @@ EDITDELETE
end
ret += "</th>"
}
- ret += "<th><a href='.'>Last Edit #{NOSORT}</a></th>\n"
+ ret += "<th><a href='?'>Last Edit #{sortsymb(scols,"timestamp")}</a></th>\n" unless showeditbuttons
ret += "</tr>\n"
ret
end
@@ -126,7 +133,7 @@ EDITDELETE
</form>
<fieldset><legend>Preview</legend>
<table summary='Preview poll head'>
-#{to_html(true,activecolumn)}
+#{to_html([],true,activecolumn)}
</table>
</fieldset>
END