-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.cgi
More file actions
executable file
·55 lines (46 loc) · 1.38 KB
/
options.cgi
File metadata and controls
executable file
·55 lines (46 loc) · 1.38 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl
use v5.12;
use lib '.';
use Roots::Util;
use Roots::Template;
use CGI qw(-utf8);
# get the session id
my $q = CGI->new();
Roots::Util::get_existing_session();
# get our displayed keys from the params; otherwise from the previous cookie
my (@displayed, $cookie);
if ($q->param("btn")) {
@displayed = $q->multi_param('disp');
$cookie = $q->cookie(-name=>"disp", -value=>\@displayed,
-expires=>'+1y');
print $q->redirect(-uri=>Roots::Util::session_url(),
-cookie=>$cookie);
exit;
} else {
@displayed = $q->cookie('disp');
@displayed = qw( b5 rom ) unless @displayed;
}
my %checked;
foreach (@displayed) {
$checked{$_} = 'checked';
}
# print headers
print $q->header();
Roots::Template::print_head("Display Options",undef,1);
# display stuff
print $q->h1("Village DB: Display Options");
print_options();
# finish up
Roots::Template::print_tail();
# subroutines
sub print_options {
print <<EOF;
<p>Please select the encodings you want displayed:</p>
<form method="POST">
<input type="checkbox" name="disp" id="rom" $checked{rom} value="rom"><label for="rom">Romanization</label><br>
<input type="checkbox" name="disp" id="py" $checked{py} value="py"><label for="py">Pinyin (Mandarin)</label><br>
<input type="checkbox" name="disp" id="jp" $checked{jp} value="jp"><label for="jp">Jyutping (Cantonese)</label><br>
<input type="submit" name="btn" value="Submit">
</form>
EOF
}