[Debtags-commits] [svn] r2054 - in web/trunk: . js
Enrico Zini
enrico at alioth.debian.org
Wed Nov 8 20:30:40 CET 2006
Author: enrico
Date: Wed Nov 8 20:30:40 2006
New Revision: 2054
Modified:
web/trunk/edit.html
web/trunk/js/debtags.js
web/trunk/js/test.html
Log:
Implemented submit of patches
Modified: web/trunk/edit.html
==============================================================================
--- web/trunk/edit.html (original)
+++ web/trunk/edit.html Wed Nov 8 20:30:40 2006
@@ -27,7 +27,7 @@
if (sdesc == null) return;
pkg = p;
- document.patch.pkg.value = pkg;
+ //document.patch.pkg.value = pkg;
render("pkgname", "<a href='http://packages.qa.debian.org/"+pkg+"'>"+pkg+"</a>");
origtags = ts.copy();
@@ -84,7 +84,7 @@
var count = 0;
b = "<ul>\n";
var patch = origtags.mkpatch(tags);
- document.patch.patch.value = patch.toString();
+ //document.patch.patch.value = patch.toString();
patch.each(function(p){
if (p[0] == '+')
b += "<li><span class='tag' onClick='delTag(\""+p.substring(1)+"\")'>"+p+"</span></li>\n";
@@ -215,6 +215,16 @@
}, true);
}
+function submitPatch()
+{
+ var patch = origtags.mkpatch(tags);
+ var toSend = pkg + ": " + patch.toString();
+ fireSubmitPatch(toSend, function(){}, function(res) {
+ // If successful, refresh package info
+ if (res[0] == "200 OK")
+ setPackage(pkg);
+ }, false);
+}
//-->
</script>
</head>
@@ -236,6 +246,10 @@
Changes:
<div id="curpatch">
</div>
+
+ <form name="patch" onSubmit="return false;">
+ <input type="button" name="submit" value="Submit" onClick="submitPatch()"/>
+ </form>
</div>
<div id="curpackage">
<p><span id="pkgname"> </span> - <span id="pkgsdesc"> </span></p>
@@ -247,11 +261,6 @@
to remove the "not-yet-tagged" tags.</p>
</div>
- <form name="patch" id="patchForm" method="get">
- <input type="hidden" name="pkg" value="">
- <input type="hidden" name="patch" value="">
- </form>
-
<div style="clear: both"></div>
<p>Current tag view:
Modified: web/trunk/js/debtags.js
==============================================================================
--- web/trunk/js/debtags.js (original)
+++ web/trunk/js/debtags.js Wed Nov 8 20:30:40 2006
@@ -67,6 +67,40 @@
}
}
+function runPostRequest(url, content, progressfunc, finalfunc, async)
+{
+ try {
+ var req = getXMLHttpRequest();
+ req.open("POST", url, async);
+ req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ if (async)
+ {
+ req.onreadystatechange = function() {
+ switch (req.readyState)
+ {
+ case 4:
+ if (req.status != 200) {
+ alert("Posting to " + 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(content);
+ if (!async)
+ finalfunc(req.responseText.split("\n"));
+ } catch (e) {
+ alert("Cannot post data to " + url + ": " + e);
+ finalfunc(new Array());
+ }
+}
+
function fireFTSQuery(str, progressFunc, finalFunc, async)
{
// Build the new search base
@@ -210,6 +244,12 @@
);
}
+function fireSubmitPatch(patch, progressFunc, finalFunc, async)
+{
+ var content = "patch="+encodeURIComponent(patch);
+ runPostRequest(QUERY_BASE + "/patch", content, progressFunc, finalFunc, async);
+}
+
//
// Debtags infrastructure
//
Modified: web/trunk/js/test.html
==============================================================================
--- web/trunk/js/test.html (original)
+++ web/trunk/js/test.html Wed Nov 8 20:30:40 2006
@@ -191,6 +191,12 @@
ensure("should have sdesc in the result", sdesc != null);
ensure("should have ldesc in the result", ldesc != null);
+var count = 0;
+var result = null;
+fireSubmitPatch("debtags: +implemented-in::c++", function(){++count;}, function(res){++count;result=res;},false);
+ ensure_equals("sync query has no partial events", count, 1);
+ ensure_equals("submit of patch should succeed", result[0], "200 OK");
+
/*
var a = {};
a["antani"] = "blinda";
More information about the Debtags-commits
mailing list