diff options
author | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2009-11-24 20:39:56 +0100 |
---|---|---|
committer | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2009-11-24 20:39:56 +0100 |
commit | efd838d9ac1112d3d4cd8bb64951b417a977f4b2 (patch) | |
tree | d49990669ef3ec20ac6bb89710518021e6f32901 /pollhead.rb | |
parent | 4279e3023c4f437cd4fb996e0535fe09241823cf (diff) |
give sort feedback
Diffstat (limited to 'pollhead.rb')
-rw-r--r-- | pollhead.rb | 17 |
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 |