From: Frank Lichtenheld Date: Thu, 23 Nov 2006 21:32:40 +0000 (+0000) Subject: experiment a little with the use of JavaScript. Right now I use X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=078ddbf7006d957bbef2daa9735ec9a8bf3d8fcd;p=deb%2Fpackages.git experiment a little with the use of JavaScript. Right now I use 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 --- diff --git a/lib/Packages/DoSearch.pm b/lib/Packages/DoSearch.pm index df9a91d..2a59937 100644 --- a/lib/Packages/DoSearch.pm +++ b/lib/Packages/DoSearch.pm @@ -14,7 +14,7 @@ our @EXPORT = qw( do_search ); 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 ); @@ -156,8 +156,7 @@ sub do_search { 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; diff --git a/static/packages.js b/static/packages.js new file mode 100644 index 0000000..c33e06d --- /dev/null +++ b/static/packages.js @@ -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"; +} diff --git a/templates/html/head.tmpl b/templates/html/head.tmpl index 31cc40b..734d92a 100644 --- a/templates/html/head.tmpl +++ b/templates/html/head.tmpl @@ -11,6 +11,7 @@ +