[LON-CAPA-cvs] cvs: modules /gerd/Wiki convert.pl

www www at source.lon-capa.org
Thu Dec 15 15:02:58 EST 2011


www		Thu Dec 15 20:02:58 2011 EDT

  Modified files:              
    /modules/gerd/Wiki	convert.pl 
  Log:
  Hide/Show functionality
  
  
Index: modules/gerd/Wiki/convert.pl
diff -u modules/gerd/Wiki/convert.pl:1.11 modules/gerd/Wiki/convert.pl:1.12
--- modules/gerd/Wiki/convert.pl:1.11	Thu Dec 15 17:46:56 2011
+++ modules/gerd/Wiki/convert.pl	Thu Dec 15 20:02:58 2011
@@ -134,6 +134,9 @@
     print "====== Processing $idx: $idxres{$idx}\n";
     my $outflag=0;
     my $output='';
+    my $id=0;
+    my $thflag=0;
+    my $trflag=0;
     while (my $line=<IN>) {
        chomp($line);
        if ($line=~/^\<\!--\s*$/) { last; }
@@ -147,6 +150,23 @@
        $line=~s/\<EMBED\s+src\=\"([^\"]+)\"(.*)\s+NAME\=\"[^\"]+/&embedfragment($targetdir,$1,$2)/gse;
        $line=~s/\<PARAM NAME\=movie VALUE\=\"([^\"]+)\"/&paramfragment($targetdir,$1)/gse;
        $line=~s/\<OBJECT(.*)\s+id\=\"([^\"]+)\"/&objectfragment($1,$targetdir,$2)/gse;
+       if ($line=~/collapsible\s*collapsed/) {
+          $thflag=1;
+          $id++;
+       }
+       if ($thflag) {
+          if ($line=~/\<\/th\>/) {
+             $line=~s/\<\/th\>/&showhide($id)/se;
+             $thflag=0;
+             $trflag=1;
+          }
+       }
+       if ($trflag) {
+          if ($line=~/\<tr\>/) {
+             $line=~s/\<tr\>/&hiddenrow($id)/se;
+             $trflag=0;
+          }
+       }
 # ------------------------------------------------- End Substitutions
        $output.=$line."\n";
     }
@@ -157,6 +177,16 @@
     close(OUT);
 }
 
+sub showhide {
+   my ($id)=@_;
+   return ' [<a id="ht'.$id.'l" href="javascript:toggleDisplay(\'ht'.$id.'\',\'hide\',\'show\')">show</a>]</th>';
+}
+
+sub hiddenrow {
+   my ($id)=@_;
+   return '<tr id="ht'.$id.'" style="display:none">';
+}
+
 sub header {
    my ($title)=@_;
    return(<<ENDHEADER);
@@ -183,6 +213,67 @@
     }
 }
 </script>
+<style type="text/css">
+.collapseButton {
+float:right;
+font-weight:400;
+text-align:right;
+width:auto;
+}
+
+.wikitable th,.prettytable th {
+background:#f2f2f2;
+text-align:left;
+font-weight:400;
+}
+
+table.subtable {
+background:#fff;
+border:1px #aaa solid;
+border-collapse:collapse;
+margin:1em 1em 1em 0;
+}
+
+.subtable th {
+color:#555;
+background:#fff;
+text-align:left;
+font-weight:700;
+}
+
+.subsubtable th {
+background:#f2f2f2;
+color:#000;
+text-align:left;
+font-weight:700;
+}
+
+img.tex.inlinemath {
+height:1.1em;
+vertical-align:0;
+}
+
+img.tex.inlinesub {
+height:1.4em;
+vertical-align:-3px;
+}
+
+table.wikitable,table.prettytable,.subsubtable {
+background:#f9f9f9;
+border:1px #aaa solid;
+border-collapse:collapse;
+margin:1em 1em 1em 0;
+}
+
+.wikitable th,.wikitable td,.prettytable th,.prettytable td,.subtable th,.subtable td,.subsubtable th,.subsubtable td {
+border:1px #aaa solid;
+padding:.2em;
+}
+
+.wikitable caption,.prettytable caption,.subtable caption,.subsubtable caption {
+font-weight:700;
+}
+</style>
 </head>
 <body>
 ENDHEADER




More information about the LON-CAPA-cvs mailing list