File: dropdown_calendar.rb

package info (click to toggle)
tdiary 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,088 kB
  • sloc: ruby: 23,031; javascript: 1,029; xml: 325; makefile: 26; sh: 4
file content (32 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# dropdown_calendar.rb
#
# calendar: カレンダーをドロップダウンリストに置き換えるプラグイン
#   パラメタ: なし
#
# 	Copyright (C) 2003 TADA Tadashi
#	You can redistribute it and/or modify it under GPL2 or any later version.
#

@dropdown_calendar_label = '過去の日記' unless @resource_loaded

def calendar
	result = %Q[<form method="get" action="#{h @index}">\n]
	result << %Q[<div class="calendar">\n]
	result << %Q[<select name="url" onChange="window.location=$(this).val()">\n]
	result << "<option value=''>#{@conf.options['dropdown_calendar.label'] || @dropdown_calendar_label}</option>\n"
	@years.keys.sort.reverse_each do |year|
		@years[year.to_s].sort.reverse_each do |month|
			date = "#{year}#{month}"
			result << %Q[<option value="#{h @index}#{anchor(date)}">#{year}-#{month}</option>\n]
		end
	end
	result << "</select>\n"
	result << "</div>\n</form>"
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End: