[Debtags-commits] [svn] r1956 - in web/trunk: . js
Enrico Zini
enrico at costa.debian.org
Mon Sep 25 12:50:29 UTC 2006
Author: enrico
Date: Mon Sep 25 12:50:28 2006
New Revision: 1956
Modified:
web/trunk/fts.html
web/trunk/js/debtags.js
Log:
Disable input form while the search is running
Catch and properly handle connection errors
Modified: web/trunk/fts.html
==============================================================================
--- web/trunk/fts.html (original)
+++ web/trunk/fts.html Mon Sep 25 12:50:28 2006
@@ -23,7 +23,7 @@
b += "<ul>";
coll.iterPackages(function(p){
b += "<li>";
- b += "<a href='http://packages.debian.org/'"+p+"'>"+p+"<a>";
+ b += "<a href='http://packages.debian.org/"+p+"'>"+p+"<a>";
b += " -- ";
b += pkgs.get(p);
b += "</li>\n";
@@ -32,9 +32,18 @@
node.innerHTML = b;
}
+function finalUpdateResults(coll, pkgs)
+{
+ updateResults(coll, pkgs);
+ document.search.keys.disabled = false;
+ document.search.submit.disabled = false;
+}
+
function performSearch(keys)
{
- fireFTSQuery(keys.value, updateResults, updateResults, true);
+ document.search.keys.disabled = true;
+ document.search.submit.disabled = true;
+ fireFTSQuery(keys.value, updateResults, finalUpdateResults, true);
}
//-->
</script>
@@ -59,7 +68,7 @@
<div id="search">
Search: <input type="text" name="keys" value='' onChange="performSearch(this)" />
- <input type="button" value="Search" onClick="performSearch(this.form.keys)" />
+ <input type="button" name="submit" value="Search" onClick="performSearch(this.form.keys)" />
</div>
<div id="results">
Modified: web/trunk/js/debtags.js
==============================================================================
--- web/trunk/js/debtags.js (original)
+++ web/trunk/js/debtags.js Mon Sep 25 12:50:28 2006
@@ -36,28 +36,35 @@
function runRequest(url, progressfunc, finalfunc, async)
{
- var req = getXMLHttpRequest();
- req.open("GET", url, async);
- if (async)
- {
- req.onreadystatechange = function() {
- switch (req.readyState)
- {
- case 4:
- if (req.status != 200)
- alert("Getting " + url + " failed with status " + req.statusText);
- else
- finalfunc(req.responseText.split("\n"));
- break;
- default:
- progressfunc(req.responseText.split("\n"));
- break;
- }
- };
+ try {
+ var req = getXMLHttpRequest();
+ req.open("GET", url, async);
+ if (async)
+ {
+ req.onreadystatechange = function() {
+ switch (req.readyState)
+ {
+ case 4:
+ if (req.status != 200) {
+ alert("Getting " + url + " failed with status " + req.statusText);
+ finalfunc(new Array());
+ }
+ else
+ finalfunc(req.responseText.split("\n"));
+ break;
+ default:
+ progressfunc(req.responseText.split("\n"));
+ break;
+ }
+ };
+ }
+ req.send(null);
+ if (!async)
+ finalfunc(req.responseText.split("\n"));
+ } catch (e) {
+ alert("Cannot get data from " + url + ": " + e);
+ finalfunc(new Array());
}
- req.send(null);
- if (!async)
- finalfunc(req.responseText.split("\n"));
}
function fireFTSQuery(str, progressFunc, finalFunc, async)
More information about the Debtags-commits
mailing list