add options for stexaminer re-analysis
Tara L Andrews [Wed, 11 Jul 2012 17:34:03 +0000 (19:34 +0200)]
lib/stemmaweb/Controller/Stexaminer.pm
root/css/stexaminer.css
root/src/stexaminer.tt

index e556e32..e7eee1b 100644 (file)
@@ -39,8 +39,25 @@ sub index :Path :Args(1) {
                $c->stash->{graphdot} = $stemma->editable({ linesep => ' ' });
                $c->stash->{text_title} = $tradition->name;
                $c->stash->{template} = 'stexaminer.tt'; 
+               
+               # Get the analysis options
+               my( $use_type1, $ignore_sort ) = ( 0, 'none' );
+               if( $c->req->method eq 'POST' ) {
+                       $use_type1 = $c->req->param( 'show_type1' ) eq 'on' ? 1 : 0;
+                       $ignore_sort = $c->req->param( 'ignore_variant' );
+               }
+               $c->stash->{'show_type1'} = $use_type1;
+               $c->stash->{'ignore_variant'} = $ignore_sort;
                # TODO Run the analysis as AJAX from the loaded page.
-               my $t = run_analysis( $tradition, 'exclude_type1' => 1 );
+               my %analysis_options;
+               $analysis_options{'exclude_type1'} = !$use_type1;
+               if( $ignore_sort eq 'spelling' ) {
+                       $analysis_options{'collapse'} = [ qw/ spelling orthographic / ];
+               } elsif( $ignore_sort eq 'orthographic' ) {
+                       $analysis_options{'collapse'} = 'orthographic';
+               }
+                       
+               my $t = run_analysis( $tradition, %analysis_options );
                # Stringify the reading groups
                foreach my $loc ( @{$t->{'variants'}} ) {
                        my $mst = wit_stringify( $loc->{'missing'} );
index 760fbb2..5bf6401 100644 (file)
@@ -1,5 +1,22 @@
+#options {
+       position: relative;
+       border: 1px #c6dcf1 solid;
+       margin-left: 20px;
+       margin-bottom: 20px;
+       padding: 10px;
+       width: 500px;
+}
+.optionformelement {
+       float: left;
+       padding-left: 15px;
+}
+#options_button {
+       position: absolute;
+       bottom: 20px;
+       right: 20px;
+}
 #variants_table {
-    float: left;
+    clear: both;
     width: 90%;
     height: 190px;
     border: 1px #c6dcf1 solid;
 .cellb7 {
     border-right: 20px solid #ffd5e5;
 }
+
+/* Clearfix hack to make div container height work */
+.clearfix:after {
+       content: ".";
+       display: block;
+       clear: both;
+       visibility: hidden;
+       line-height: 0;
+       height: 0;
+}
+.clearfix {
+       display: inline-block;
+}
+html[xmlns] .clearfix {
+       display: block;
+}
+* html .clearfix {
+       height: 1%;
+}
\ No newline at end of file
index 25f1b32..de72766 100644 (file)
@@ -10,6 +10,22 @@ var graphdot = '[% graphdot %]';
 [% END -%]
     <h1>Stexaminer</h1>
     <h2>[% text_title %]</h2>
+    <div id="options">
+       <h3>Analysis options:</h3>
+       <form id="use_variants_form" name="use_variants_form" class="clearfix" method="POST">
+               <div class="optionformelement">
+                       <input type="radio" name="ignore_variant" value="none" [% 'checked="true"' IF ignore_variant == 'none' %]>Analyze all variation</input><br/>
+                       <input type="radio" name="ignore_variant" value="orthographic" [% 'checked="true"' IF ignore_variant == 'orthographic' %]>Ignore orthographic variation</input><br/>
+                       <input type="radio" name="ignore_variant" value="spelling" [% 'checked="true"' IF ignore_variant == 'spelling' %]>Ignore orthographic and spelling variation</input>
+               </div>
+               <div class="optionformelement">
+                       <input type="checkbox" name="show_type1" [% 'checked="true"' IF show_type1 %]>Include type-1 variation</input>
+               </div>
+               <div id="options_button" class="button optionformelement" onclick="$('#use_variants_form').submit()">
+                       <span>Re-analyze</span>
+               </div>
+       </form>
+    </div>
     <div id="variants_table">
       <table>
 [% FOREACH row IN variants -%]