summaryrefslogtreecommitdiff
path: root/httemplate/elements
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements')
-rw-r--r--httemplate/elements/select-time-from_to.html17
-rw-r--r--httemplate/elements/select-time.html49
-rw-r--r--httemplate/elements/tr-select-avail-time-from_to.html58
3 files changed, 124 insertions, 0 deletions
diff --git a/httemplate/elements/select-time-from_to.html b/httemplate/elements/select-time-from_to.html
new file mode 100644
index 000000000..9d49b7ab8
--- /dev/null
+++ b/httemplate/elements/select-time-from_to.html
@@ -0,0 +1,17 @@
+<& select-time.html,
+ %opt,
+ 'field' => $opt{'prefix'}. 'stime',
+ 'selected_default' => 480, #8am... configure?
+ 'curr_value' => $cgi->param($opt{'prefix'}.'stime'),
+&>
+ -
+<& select-time.html,
+ %opt,
+ 'field' => $opt{'prefix'}. 'etime',
+ 'selected_default' => 1080, #6pm.. configure?
+ 'curr_value' => $cgi->param($opt{'prefix'}.'etime'),
+&>
+<%init>
+ my %opt = @_;
+
+</%init>
diff --git a/httemplate/elements/select-time.html b/httemplate/elements/select-time.html
new file mode 100644
index 000000000..6e22e1e3d
--- /dev/null
+++ b/httemplate/elements/select-time.html
@@ -0,0 +1,49 @@
+% unless ( $opt{'js_only'} ) {
+ <SELECT NAME="<% $opt{'field'} %>" SIZE="1" <%$disabled%> <%$onchange%> >
+% for ( my $t = 0; $t <=1440; $t += $increment ) {
+ <OPTION VALUE="<% $t %>"
+ <% ( $curr_value eq '' && $t == $selected_default )
+ || $curr_value == $t
+ ? 'SELECTED' : ''
+ %>
+ ><% pretty_time($t) %>
+% }
+ </SELECT>
+% }
+<%init>
+
+my %opt = @_;
+my $increment = $opt{increment} || 30;
+my $selected_default = $opt{selected_default};
+my $disabled = $opt{'disabled'} || '';
+
+my $curr_value = $opt{curr_value};
+
+my $onchange = '';
+if ( $opt{'onchange'} ) {
+ $onchange = $opt{'onchange'};
+ $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
+ $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
+ #callbacks should act the same
+ $onchange = 'onChange="'. $onchange. '"' unless $onchange =~ /^onChange=/i;
+}
+
+sub pretty_time {
+ my $t = shift;
+
+ return 'Midnight' if $t == 0 || $t == 1440;
+ return 'Noon' if $t == 720;
+
+ my $h = int( $t / 60 );
+ my $m = $t % 60;
+
+ my $ap = 'AM';
+ if ( $h == 0 || $h == 24 ) { $h = 12; }
+ elsif ( $h == 12 ) { $ap = 'PM'; }
+ elsif ( $h > 12 ) { $ap = 'PM'; $h -= 12; }
+
+ sprintf('%02d:%02d'." $ap", $h, $m);
+
+}
+
+</%init>
diff --git a/httemplate/elements/tr-select-avail-time-from_to.html b/httemplate/elements/tr-select-avail-time-from_to.html
new file mode 100644
index 000000000..b867388f8
--- /dev/null
+++ b/httemplate/elements/tr-select-avail-time-from_to.html
@@ -0,0 +1,58 @@
+% unless ( $opt{'js_only'} ) {
+
+ <& tr-td-label.html, %opt &>
+
+ <TD <% $colspan %> <% $style %>>
+% }
+ <& checkbox.html,
+ %opt,
+ prefix => '',
+ value => 'Y',
+ curr_value => $curr_value,
+ onchange => $opt{field}. '_changed',
+ &>
+
+ <& select-time-from_to.html,
+ %opt,
+ disabled => ($curr_value eq 'Y' ? '' : 'DISABLED' )
+ &>
+
+% unless ( $opt{'js_only'} ) {
+ </TD>
+ </TR>
+% }
+% unless ( $opt{'html_only'} || $opt{'js_only'} ) {
+ <SCRIPT TYPE="text/javascript">
+% }
+% unless ( $opt{'html_only'} ) {
+ function <% $opt{field} %>_changed(what) {
+
+ <% $opt{'onchange'} %>
+
+ var stime_el = what.form.<% $opt{field} %>_stime;
+ var etime_el = what.form.<% $opt{field} %>_etime;
+
+ if ( what.checked ) {
+ stime_el.disabled = false;
+ etime_el.disabled = false;
+ } else {
+ stime_el.disabled = true;
+ etime_el.disabled = true;
+ }
+
+ }
+% }
+% unless ( $opt{'html_only'} || $opt{'js_only'} ) {
+ </SCRIPT>
+% }
+<%init>
+
+my %opt = @_;
+
+my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+my $colspan = $opt{'colspan'} ? 'COLSPAN="'.$opt{'colspan'}.'"' : '';
+
+my $curr_value = $cgi->param($opt{'field'}); #wtf?
+
+</%init>