[Debtags-commits] [svn] r1934 - in web/trunk: . js
Enrico Zini
enrico at costa.debian.org
Fri Sep 22 13:03:58 UTC 2006
Author: enrico
Date: Fri Sep 22 13:03:58 2006
New Revision: 1934
Added:
web/trunk/js/
web/trunk/js/debtags.js
web/trunk/js/test.html
Modified:
web/trunk/fts.html
Log:
Started a proper javascript library, and use it
Modified: web/trunk/fts.html
==============================================================================
--- web/trunk/fts.html (original)
+++ web/trunk/fts.html Fri Sep 22 13:03:58 2006
@@ -8,101 +8,34 @@
<meta name="Author" content="Enrico Zini, enrico at debian.org">
<link rev="made" href="mailto:enrico at debian.org">
<link href="main.css" rel="stylesheet" type="text/css">
- <script src="http://debtags.alioth.debian.org/packagebrowser/vocabulary.js"></script>
+ <script src="js/vocabulary.js"></script>
+ <script src="js/debtags.js"></script>
<script type="text/javascript">
<!--
-
-// From http://jibbering.com/2002/4/httprequest.html
-var req = false;
-/*@cc_on @*/
-/*@if (@_jscript_version >= 5)
-// JScript gives us Conditional compilation, we can cope with old IE versions.
-// and security blocked creation of the objects.
-try {
- req = new ActiveXObject("Msxml2.XMLHTTP");
-} catch (e) {
- try {
- req = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (E) {
- req = false;
- }
-}
- at end @*/
-if (!req && typeof XMLHttpRequest != 'undefined') {
- req = new XMLHttpRequest();
-}
-
-function performSearch(keys)
-{
- var node = document.getElementById("results");
-
- // Build the new search base
- var base = new Array();
- var keys = keys.value.split(" ");
- for (var t in keys)
- base.push(escape(keys[t]));
-
- req.open("GET", "http://debtags.alioth.debian.org/cgi-bin/fts/"+base.join('/'),true);
- req.onreadystatechange = function() {
- switch (req.readyState)
- {
- case 4:
- if (req.status != 200)
- {
- alert("Downloading new package informations failed:\n" + req.statusText);
- break
- }
- // Decode new package informations
- updateResults(req.responseText.split('\n'));
- break;
- default:
- updateResults(req.responseText.split('\n'));
- break;
- }
- }
- req.send(null)
-}
-
-var packageDataRegexp = new RegExp("^(\\S+) (\\S*) (.+)$");
-function packageData(line)
-{
- return packageDataRegexp.exec(line);
-}
-
-function updateResults(lines)
+function updateResults(coll, pkgs)
{
var node = document.getElementById("results");
b = "";
- b += "<p>" + (lines.length - 1) + " results:</p>\n";
-
- //b += lines.join('/');
+ b += "<p>" + coll.packageCount() + " results:</p>\n";
b += "<ul>";
- for (var line in lines)
- {
- var fields = packageData(lines[line]);
- if (!fields || fields.length < 4)
- {
- //b += "<li>--" + lines[line] + "</li>";
- continue;
- }
+ coll.iterPackages(function(p){
b += "<li>";
- b += "<a href='http://packages.debian.org/'"+fields[1]+"'>"+fields[1]+"<a>";
+ b += "<a href='http://packages.debian.org/'"+p+"'>"+p+"<a>";
b += " -- ";
- b += fields[3];
+ b += pkgs.get(p);
b += "</li>\n";
- /*
- var tags = fields[2].split(',');
- for (var tag in tags)
- p.addTag(tags[tag]);
- */
- }
+ });
b += "</ul>";
node.innerHTML = b;
}
+function performSearch(keys)
+{
+ fireFTSQuery(keys.value, updateResults, updateResults, true);
+}
//-->
</script>
</head>
More information about the Debtags-commits
mailing list