104 |
sub start_section ($%) { |
sub start_section ($%) { |
105 |
my ($self, %opt) = @_; |
my ($self, %opt) = @_; |
106 |
|
|
107 |
|
my $class = 'section'; |
108 |
if (defined $opt{role}) { |
if (defined $opt{role}) { |
109 |
if ($opt{role} eq 'parse-errors') { |
if ($opt{role} eq 'parse-errors') { |
110 |
$opt{id} ||= 'parse-errors'; |
$opt{id} ||= 'parse-errors'; |
111 |
$opt{title} ||= 'Parse Errors Section'; |
$opt{title} ||= 'Parse Errors Section'; |
112 |
$opt{short_title} ||= 'Parse Errors'; |
$opt{short_title} ||= 'Parse Errors'; |
113 |
|
$class .= ' errors'; |
114 |
delete $opt{role}; |
delete $opt{role}; |
115 |
} elsif ($opt{role} eq 'structure-errors') { |
} elsif ($opt{role} eq 'structure-errors') { |
116 |
$opt{id} ||= 'document-errors'; |
$opt{id} ||= 'document-errors'; |
117 |
$opt{title} ||= 'Structural Errors'; |
$opt{title} ||= 'Structural Errors'; |
118 |
$opt{short_title} ||= 'Struct. Errors'; |
$opt{short_title} ||= 'Struct. Errors'; |
119 |
|
$class .= ' errors'; |
120 |
delete $opt{role}; |
delete $opt{role}; |
121 |
} elsif ($opt{role} eq 'reformatted') { |
} elsif ($opt{role} eq 'reformatted') { |
122 |
$opt{id} ||= 'document-tree'; |
$opt{id} ||= 'document-tree'; |
123 |
$opt{title} ||= 'Reformatted Document Source'; |
$opt{title} ||= 'Reformatted Document Source'; |
124 |
$opt{short_title} ||= 'Reformatted'; |
$opt{short_title} ||= 'Reformatted'; |
125 |
|
$class .= ' dump'; |
126 |
delete $opt{role} |
delete $opt{role} |
127 |
} elsif ($opt{role} eq 'tree') { |
} elsif ($opt{role} eq 'tree') { |
128 |
$opt{id} ||= 'document-tree'; |
$opt{id} ||= 'document-tree'; |
129 |
$opt{title} ||= 'Document Tree'; |
$opt{title} ||= 'Document Tree'; |
130 |
$opt{short_title} ||= 'Tree'; |
$opt{short_title} ||= 'Tree'; |
131 |
|
$class .= ' dump'; |
132 |
delete $opt{role}; |
delete $opt{role}; |
133 |
} elsif ($opt{role} eq 'structure') { |
} elsif ($opt{role} eq 'structure') { |
134 |
$opt{id} ||= 'document-structure'; |
$opt{id} ||= 'document-structure'; |
135 |
$opt{title} ||= 'Document Structure'; |
$opt{title} ||= 'Document Structure'; |
136 |
$opt{short_title} ||= 'Structure'; |
$opt{short_title} ||= 'Structure'; |
137 |
|
$class .= ' dump'; |
138 |
|
delete $opt{role}; |
139 |
|
} elsif ($opt{role} eq 'subdoc') { |
140 |
|
$class .= ' subdoc'; |
141 |
|
delete $opt{role}; |
142 |
|
} elsif ($opt{role} eq 'source') { |
143 |
|
$opt{id} ||= 'source-string'; |
144 |
|
$opt{title} ||= 'Document Source'; |
145 |
|
$opt{short_title} ||= 'Source'; |
146 |
|
$class .= ' source'; |
147 |
delete $opt{role}; |
delete $opt{role}; |
148 |
} |
} |
149 |
} |
} |
150 |
|
|
151 |
$self->{section_rank}++; |
$self->{section_rank}++; |
152 |
$self->html ('<div class=section'); |
$self->html (qq[<div class="$class"]); |
153 |
if (defined $opt{id}) { |
if (defined $opt{id}) { |
154 |
my $id = $self->input->id_prefix . $opt{id}; |
my $prefix = $self->input->id_prefix; |
155 |
$self->html (' id="' . $htescape->($id) . '"'); |
$opt{parent_id} ||= $prefix; |
156 |
push @{$self->{nav}}, |
my $id = $prefix . $opt{id}; |
157 |
[$id => $opt{short_title} || $opt{title} => $opt{text}] |
$self->html (' id="' . $htescape->($id) . '">'); |
158 |
if $self->{section_rank} == 2; |
if ($self->{section_rank} == 2 or length $opt{parent_id}) { |
159 |
|
my $st = $opt{short_title} || $opt{title}; |
160 |
|
push @{$self->{nav}}, |
161 |
|
[$id => $st => $opt{text}]; |
162 |
|
|
163 |
|
$self->start_tag ('script'); |
164 |
|
$self->html (qq[ addSectionLink ('$id', ']); |
165 |
|
$self->nl_text ($st, text => $opt{text}); |
166 |
|
if (defined $opt{parent_id}) { |
167 |
|
$self->html (q[', '] . $opt{parent_id}); |
168 |
|
} |
169 |
|
$self->html (q[') ]); |
170 |
|
$self->end_tag ('script'); |
171 |
|
} |
172 |
|
} else { |
173 |
|
$self->html ('>'); |
174 |
} |
} |
175 |
my $section_rank = $self->{section_rank}; |
my $section_rank = $self->{section_rank}; |
176 |
$section_rank = 6 if $section_rank > 6; |
$section_rank = 6 if $section_rank > 6; |
177 |
$self->html ('><h' . $section_rank . '>'); |
$self->html ('<h' . $section_rank . '>'); |
178 |
$self->nl_text ($opt{title}, text => $opt{text}); |
$self->nl_text ($opt{title}, text => $opt{text}); |
179 |
$self->html ('</h' . $section_rank . '>'); |
$self->html ('</h' . $section_rank . '>'); |
180 |
} # start_section |
} # start_section |
461 |
<link rel="stylesheet" href="../cc-style.css" type="text/css"> |
<link rel="stylesheet" href="../cc-style.css" type="text/css"> |
462 |
<script src="../cc-script.js"></script> |
<script src="../cc-script.js"></script> |
463 |
</head> |
</head> |
464 |
<body> |
<body onclick=" return onbodyclick (event) " onload=" onbodyload () "> |
465 |
<h1>]); |
<h1>]); |
466 |
$self->nl_text (q[WebHACC:Heading]); |
$self->nl_text (q[WebHACC:Heading]); |
467 |
$self->html ('</h1>'); |
$self->html (q[</h1><script> insertNavSections () </script>]); |
468 |
} # html_header |
} # html_header |
469 |
|
|
470 |
sub generate_input_section ($$) { |
sub generate_input_section ($$) { |
473 |
my $options = sub ($) { |
my $options = sub ($) { |
474 |
my $context = shift; |
my $context = shift; |
475 |
|
|
476 |
$out->html (q[<div class=details><p class=legend onclick="nextSibling.style.display = nextSibling.style.display == 'none' ? 'block' : 'none'">]); |
$out->html (q[<div class="details default"><p class=legend onclick="nextSibling.style.display = nextSibling.style.display == 'block' ? 'none' : 'block'; parentNode.className = nextSibling.style.display == 'none' ? 'details' : 'details open'">]); |
477 |
$out->nl_text (q[Options]); |
$out->nl_text (q[Options]); |
478 |
$out->start_tag ('div'); |
$out->start_tag ('div'); |
479 |
|
|
551 |
}; # $options |
}; # $options |
552 |
|
|
553 |
$out->start_section (id => 'input', title => 'Input'); |
$out->start_section (id => 'input', title => 'Input'); |
554 |
|
$out->html (q[<script> insertNavSections ('input') </script>]); |
555 |
|
|
556 |
$out->start_section (id => 'input-url', title => 'By URL'); |
$out->start_section (id => 'input-url', title => 'By URL', |
557 |
|
parent_id => 'input'); |
558 |
$out->start_tag ('form', action => './#result-summary', |
$out->start_tag ('form', action => './#result-summary', |
559 |
'accept-charset' => 'utf-8', |
'accept-charset' => 'utf-8', |
560 |
method => 'get'); |
method => 'get'); |
570 |
value => $cgi->get_parameter ('uri')); |
value => $cgi->get_parameter ('uri')); |
571 |
$out->end_tag ('label'); |
$out->end_tag ('label'); |
572 |
|
|
|
$options->('url'); |
|
|
|
|
573 |
$out->start_tag ('p'); |
$out->start_tag ('p'); |
574 |
$out->start_tag ('button', type => 'submit'); |
$out->start_tag ('button', type => 'submit'); |
575 |
$out->nl_text ('Check'); |
$out->nl_text ('Check'); |
576 |
|
$out->end_tag ('button'); |
577 |
|
|
578 |
|
$options->('url'); |
579 |
|
|
580 |
$out->end_tag ('form'); |
$out->end_tag ('form'); |
581 |
$out->end_section; |
$out->end_section; |
584 |
|
|
585 |
## TODO: File upload |
## TODO: File upload |
586 |
|
|
587 |
$out->start_section (id => 'input-text', title => 'By direct input'); |
$out->start_section (id => 'input-text', title => 'By direct input', |
588 |
|
parent_id => 'input'); |
589 |
$out->start_tag ('form', action => './#result-summary', |
$out->start_tag ('form', action => './#result-summary', |
590 |
'accept-charset' => 'utf-8', |
'accept-charset' => 'utf-8', |
591 |
method => 'post'); |
method => 'post'); |
603 |
$out->end_tag ('textarea'); |
$out->end_tag ('textarea'); |
604 |
$out->end_tag ('label'); |
$out->end_tag ('label'); |
605 |
|
|
|
$options->('text'); |
|
|
|
|
606 |
$out->start_tag ('p'); |
$out->start_tag ('p'); |
607 |
$out->start_tag ('button', type => 'submit', |
$out->start_tag ('button', type => 'submit', |
608 |
onclick => 'form.method = form.s.value.length > 512 ? "post" : "get"'); |
onclick => 'form.method = form.s.value.length > 512 ? "post" : "get"'); |
609 |
$out->nl_text ('Check'); |
$out->nl_text ('Check'); |
610 |
$out->end_tag ('button'); |
$out->end_tag ('button'); |
611 |
|
|
612 |
|
$options->('text'); |
613 |
|
|
614 |
$out->end_tag ('form'); |
$out->end_tag ('form'); |
615 |
$out->end_section; |
$out->end_section; |
616 |
|
|
617 |
|
$out->script (q[ |
618 |
|
if (!document.webhaccNavigated && |
619 |
|
document.getElementsByTagName ('textarea')[0].value.length > 0) { |
620 |
|
showTab ('input-text'); |
621 |
|
document.webhaccNavigated = false; |
622 |
|
} |
623 |
|
]); |
624 |
|
|
625 |
$out->end_section; |
$out->end_section; |
626 |
} # generate_input_section |
} # generate_input_section |
627 |
|
|