/[suikacvs]/www/test/uri/data/test.cgi
Suika

Diff of /www/test/uri/data/test.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Sun Jun 1 08:55:24 2008 UTC revision 1.3 by wakaba, Sun Jun 1 11:52:18 2008 UTC
# Line 24  sub get_id ($) { Line 24  sub get_id ($) {
24    return $s;    return $s;
25  } # get_id  } # get_id
26    
27  print qq[Content-Type: text/html; charset=utf-8  print q[Content-Type: text/html; charset=utf-8
28    
29  <!DOCTYPE HTML>  <!DOCTYPE HTML>
30  <html lang=en>  <html lang=en>
# Line 39  print qq[Content-Type: text/html; charse Line 39  print qq[Content-Type: text/html; charse
39    background-color: #F0F8FC;    background-color: #F0F8FC;
40    color: black;    color: black;
41  }  }
42  </style>];  [irrelevant] {
43      display: none;
44    }
45    </style>
46    <script>
47      window.onload = function () {
48        var tags = {};
49        var anchors = document.getElementsByTagName ('a');
50        var anchorsL = anchors.length;
51        for (var i = 0; i < anchorsL; i++) {
52          var anchor = anchors[i];
53          if (!anchor.hasAttribute ('href')) {
54            var tagName = anchor.textContent;
55            anchor.setAttribute ('href', '#tag=' + encodeURIComponent (tagName));
56            anchor.onclick = function () {
57              showTag (this.textContent);
58            };
59            tags[tagName] = true;
60          }
61        }
62    
63        var uri = location.href;
64        if (uri.match (/#/)) {
65          var hash = uri.substring (uri.indexOf ('#'));
66          if (hash.match (/^#tag=/)) {
67            showTag (decodeURIComponent (hash.substring (5)));
68          }
69        }
70    
71        var tagsEl = document.getElementById ('tags');
72        var tagList = [];
73        for (var v in tags) {
74          tagList.push (v);
75        }
76        tagList = tagList.sort ();
77        for (var i = 0; i < tagList.length; i++) {
78          tagsEl.appendChild (document.createTextNode (', '));
79          var a = tagsEl.appendChild (document.createElement ('a'));
80          a.href = '#tag=' + encodeURIComponent (tagList[i]);
81          a.textContent = tagList[i];
82          a.onclick = function () {
83            showTag (this.textContent);
84          };
85        }
86      }; // window.onload
87    
88      function showTag (tag) {
89        var items = document.getElementsByTagName ('div');
90        var itemsL = items.length;
91        I: for (var i = 0; i < itemsL; i++) {
92          var item = items[i];
93          if (tag == '') {
94            item.removeAttribute ('irrelevant');
95          } else {
96            var itemAs = item.getElementsByTagName ('a');
97            var itemAsL = itemAs.length;
98            for (var j = 0; j < itemAsL; j++) {
99              if (itemAs[j].textContent == tag) {
100                item.removeAttribute ('irrelevant');
101                continue I;
102              }
103            }
104            item.setAttribute ('irrelevant', '');
105          }
106        }
107      }
108    </script><p id=tags>Tags: <a href="#" onclick="showTag ('')">All</a></p>];
109    
110  for (@item) {  for (@item) {
111    s/^#//;    s/^#//;
112    my %prop;    my %prop;
113    for (split /\n#/, $_) {    for (split /\n#/, $_) {
114      if (s/^(data|note|conforming|non-conforming)(?>\n|\z)//s) {      if (s/^([0-9A-Za-z-]+)(?>\n|\z)//s) {
115        $prop{$1} = $_;        $prop{$1} = $_;
116        } elsif (s/^([0-9A-Za-z-]+)\s+escaped(?>\n|\z)//s) {
117          my $t = $1;
118          s/&#x([0-9A-Fa-f]+);/chr hex $1/ge;
119          $prop{$t} = $_;
120      }      }
121    }    }
122    
123    my $id = htescape (get_id ($prop{data}));    my $id = htescape (get_id ($prop{data}));
124    my $euri = htescape ($prop{data});    my $euri = htescape ($prop{data});
125    print qq[<div class=item id=$id><p>URI: &lt;<a href="$euri">$euri</a>&gt;];    print qq[<div class=item id=$id><p>URI: &lt;<a href="$euri">$euri</a>&gt;];
126    for (qw/note conforming non-conforming/) {    for (qw/note conforming non-conforming source/) {
127      next unless defined $prop{$_};      next unless defined $prop{$_};
128      print qq[<p>];      print qq[<p>];
129      print qq[<strong>Conforming</strong>: ] if $_ eq 'conforming';      print qq[<strong>Conforming <code>data:</code> URI</strong>: ] if $_ eq 'conforming';
130      print qq[<strong>Non-conforming</strong>: ] if $_ eq 'non-conforming';      print qq[<strong>Non-conforming <code>data:</code> URI</strong>: ] if $_ eq 'non-conforming';
131        print qq[Source: ] if $_ eq 'source';
132      my $v = htescape ($prop{$_});      my $v = htescape ($prop{$_});
133      $v =~ s[&lt;([^>]+)>][&lt;<a href="$1">$1</a>&gt;]g;      $v =~ s[&lt;([^>]+)>][&lt;<a href="$1">$1</a>&gt;]g;
134      print qq[<span class=note>] . $v . qq[</span>];      print qq[<span class=note>] . $v . qq[</span>];
135    }    }
136    
137      if (defined $prop{tag}) {
138        my @tag = sort {$a cmp $b} split /\n/, $prop{tag};
139        print q[<p class=tags>Tags: ];
140        print join ', ', map {'<a>' . htescape ($_) . '</a>'} @tag;
141      }
142    print qq[</div>];    print qq[</div>];
143  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24