]> git.deb.at Git - deb/packages.git/commitdiff
experiment a little with the use of JavaScript. Right now I use
authorFrank Lichtenheld <frank@lichtenheld.de>
Thu, 23 Nov 2006 21:32:40 +0000 (21:32 +0000)
committerFrank Lichtenheld <frank@lichtenheld.de>
Thu, 23 Nov 2006 21:32:40 +0000 (21:32 +0000)
it to make the display of some potentially very long lists
(binary packages in source package search results and providers
of virtual packages in dependency listings) optional for the user

lib/Packages/DoSearch.pm
static/packages.js [new file with mode: 0644]
templates/html/head.tmpl
templates/html/search.tmpl
templates/html/show.tmpl

index df9a91d0b266e891d02094401505b2fc72fa7adf..2a59937b84423ad9ec04573417fc2150053f6865 100644 (file)
@@ -14,7 +14,7 @@ our @EXPORT = qw( do_search );
 use Deb::Versions;
 use Packages::I18N::Locale;
 use Packages::Search qw( :all );
 use Deb::Versions;
 use Packages::I18N::Locale;
 use Packages::Search qw( :all );
-use Packages::CGI qw( :DEFAULT msg );
+use Packages::CGI qw( :DEFAULT msg error );
 use Packages::DB;
 use Packages::Config qw( $DBDIR @SUITES @ARCHIVES $ROOT );
 
 use Packages::DB;
 use Packages::Config qw( $DBDIR @SUITES @ARCHIVES $ROOT );
 
@@ -156,8 +156,7 @@ sub do_search {
                if ($arch ne 'virtual') {
                    $pkgs{$pkg}{$suite}{$version}{$arch} = 1;
                    $subsect{$pkg}{$suite}{$version} = $subsection;
                if ($arch ne 'virtual') {
                    $pkgs{$pkg}{$suite}{$version}{$arch} = 1;
                    $subsect{$pkg}{$suite}{$version} = $subsection;
-                   $sect{$pkg}{$suite}{$version} = $section
-                       unless $section eq 'main';
+                   $sect{$pkg}{$suite}{$version} = $section;
                    $archives{$pkg}{$suite}{$version} ||= $archive;
                    
                    $desc{$pkg}{$suite}{$version} = $desc;
                    $archives{$pkg}{$suite}{$version} ||= $archive;
                    
                    $desc{$pkg}{$suite}{$version} = $desc;
diff --git a/static/packages.js b/static/packages.js
new file mode 100644 (file)
index 0000000..c33e06d
--- /dev/null
@@ -0,0 +1,25 @@
+
+function init_toggle_elem(id_str,user_str) {
+       toggle_toggle_elem(id_str,user_str,'hide');
+}
+
+function toggle_toggle_elem(id_str,user_str,mode) {
+       var other_mode = ( mode == "hide" ) ? "show" : "hide";
+       var link = document.createElement("a");
+       link.setAttribute("href","javascript:toggle_toggle_elem(\""+id_str+"\",\""+user_str+"\",\""+other_mode+"\")");
+       var txt = document.createTextNode("["+other_mode+" "+user_str+"]");
+       link.appendChild(txt);
+       if (document.getElementById("js_"+id_str).childNodes.length > 0) { 
+               document.getElementById("js_"+id_str).replaceChild(link,document.getElementById("js_"+id_str).firstChild);
+       } else {
+               document.getElementById("js_"+id_str).appendChild(link);
+       }
+       toggleDisplay(document.getElementById("html_"+id_str));
+}
+
+function toggleDisplay(obj) {
+       if (obj.style.display == "none")
+               obj.style.display = "";
+       else
+               obj.style.display = "none";
+}
index 31cc40b026520abe4a6da58470d6b495d94a9980..734d92a57f06eaa5b1801608f8730a76327771e8 100644 (file)
@@ -11,6 +11,7 @@
 
 <link href="/debian.css" rel="stylesheet" type="text/css" media="all">
 <link href="/packages.css" rel="stylesheet" type="text/css" media="all">
 
 <link href="/debian.css" rel="stylesheet" type="text/css" media="all">
 <link href="/packages.css" rel="stylesheet" type="text/css" media="all">
+<script src="/packages.js" type="text/javascript"></script>
 </head>
 <body>
 <div id="header">
 </head>
 <body>
 <div id="header">
index 69c9db0e9ba75326ded53266f07048b19b6fe325..e5105bf7ef56638b786651850e70fdc407d1c4f3 100644 (file)
@@ -16,7 +16,7 @@
   <h3>Package [% pkg %]</h3>
   <ul>
   [% FOREACH s IN suites %]
   <h3>Package [% pkg %]</h3>
   <ul>
   [% FOREACH s IN suites %]
-    <li><a class="resultlink" href="[% make_url(pkg,'','suite',s.suite) %]">[% s.suite %]</a>[% ' (' _ s.subsect _ ')' IF s.subsect %]: [% s.desc %]  [%- IF s.section %] [<strong class="pmarker">[% s.section %]</strong>][% END %]
+    <li><a class="resultlink" href="[% make_url(pkg,'','suite',s.suite) %]">[% s.suite %]</a>[% ' (' _ s.subsect _ ')' IF s.subsect %]: [% s.desc %]  [%- IF s.section != main_section %] [<strong class="pmarker">[% s.section %]</strong>][% END %]
     [% FOREACH s.versions %]
       <br>[% version %] [%- IF archive != main_archive %] [<strong class="pmarker">[% archive %]</strong>][% END %]: [% architectures.join(' ') %]
     [% END %]
     [% FOREACH s.versions %]
       <br>[% version %] [%- IF archive != main_archive %] [<strong class="pmarker">[% archive %]</strong>][% END %]: [% architectures.join(' ') %]
     [% END %]
   <h3>Source Package [% pkg %]</h3>
   <ul>
   [% FOREACH origins %]
   <h3>Source Package [% pkg %]</h3>
   <ul>
   [% FOREACH origins %]
-     [% origin = (archive == 'us') ? suite : "$suite/$archive" %]
-    <li><a class="resultlink" href="[% make_url(pkg,'','source',source,'suite',origin) %]">[% origin %]</a> ([% subsection %]): [% version %]
+     [% origin = (archive == main_archive) ? suite : "$suite/$archive";
+       js_id = string2id("$pkg$suite$archive")  %]
+    <li><a class="resultlink" href="[% make_url(pkg,'','source','source','suite',origin) %]">[% origin %]</a> ([% subsection %]): [% version %]
       [%- IF section %] [<strong class="pmarker">[% section %]</strong>][% END %]
       [%- IF real_archive %] [<strong class="pmarker">[% real_archive %]</strong>][% END %]
       [%- IF section %] [<strong class="pmarker">[% section %]</strong>][% END %]
       [%- IF real_archive %] [<strong class="pmarker">[% real_archive %]</strong>][% END %]
-    <br>Binary packages: <span class="binaries">[% FOREACH binary IN binaries %]<a href="[% make_url(binary,'','source',source,'suite',suite,'archive',archive) %]">[% binary %]</a>[% ', ' UNLESS loop.last %][% END %]</span>
+    <br>Binary packages: <span id="js_[% js_id %]" class="p_js_elem"></span> <span id="html_[% js_id %]" class="binaries">[% FOREACH binary IN binaries %]<a href="[% make_url(binary,'','source','','suite',suite,'archive',archive) %]">[% binary %]</a>[% ', ' UNLESS loop.last %][% END %]</span>
+       [% IF binaries.size > 10 %]
+       <script type="text/javascript">init_toggle_elem("[% js_id %]","[% binaries.size %] binary packages")</script>
+       [% END %]
     </li>
   [% END %]
   </ul>
     </li>
   [% END %]
   </ul>
index 4a51464f68fefb8496fe3eb7a181de7f33c22c54..b0929244cc33fa09c5dd4c6e5dda82a89ab020b6 100644 (file)
@@ -6,12 +6,7 @@
    keywords = "$suite, $archive, $section, $subsection, $version"
    print_search_field = 'packages'
    search_field_values = { 
    keywords = "$suite, $archive, $section, $subsection, $version"
    print_search_field = 'packages'
    search_field_values = { 
-                         keywords => '',
                          searchon => is_source ? 'sourcenames' : 'names',
                          searchon => is_source ? 'sourcenames' : 'names',
-                         arch => 'any',
-                         suite => 'all',
-                         section => 'all',
-                         exact => 0
                          }
   navigation = [ { prefix=>'Distribution:', title=>'Overview over this suite', url=>make_url('/'), name=>suite },
                 { prefix=>'Section:', title=>'All packages in this section', url=>make_url("$subsection/"), name=>subsection },
                          }
   navigation = [ { prefix=>'Distribution:', title=>'Overview over this suite', url=>make_url('/'), name=>suite },
                 { prefix=>'Section:', title=>'All packages in this section', url=>make_url("$subsection/"), name=>subsection },
@@ -128,13 +123,13 @@ Do not install it on a normal Debian system.</p>
         [% ' [' _ arch_str _ ']' IF arch_str %]</dt>
       [%- IF !is_old_pkgs -%]
         <dd>[% desc -%]
         [% ' [' _ arch_str _ ']' IF arch_str %]</dt>
       [%- IF !is_old_pkgs -%]
         <dd>[% desc -%]
-        [%- IF providers.size > 0 -%]
+        [%- IF providers.pkgs.size > 0 -%]
           [% '<br>also a ' IF providers.also %]virtual package provided by
           [% '<br>also a ' IF providers.also %]virtual package provided by
-          [%- IF providers.pkgs.size < 11 -%]
-           [% FOREACH provider IN providers.pkgs %]<a href="[% make_url(provider,'','suite',suite,'source','') %]">[% provider %]</a>[% ', ' UNLESS loop.last %][% END %]
-          [%- ELSE -%]
-            <a href="[% make_url(name,'','suite',suite,'source','') %]">[% providers.pkgs.size %] packages</a>
-          [% END %]
+         [% js_id = name %]
+           <span id="js_[% js_id %]" class="p_js_elem"></span> <span id="html_[% js_id %]">[% FOREACH provider IN providers.pkgs %]<a href="[% make_url(provider,'','suite',suite,'source','') %]">[% provider %]</a>[% ', ' UNLESS loop.last %][% END %]</span>
+       [% IF providers.pkgs.size > 10 %]
+       <script type="text/javascript">init_toggle_elem("[% js_id %]","[% providers.pkgs.size %] providing packages")</script>
+       [% END %]
         [% END %]
         </dd>
       [% END %]
         [% END %]
         </dd>
       [% END %]