aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2009-03-06 21:46:25 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2009-03-06 22:33:44 +0100
commit63edb54f04e19d98625366807e3c482bef44f836 (patch)
tree5d16d5f393ab0eff4a2f0f2b80993ab58039b0c4 /public
parent2a57624dd5c54110cf328a8bac079d36dbcae0ec (diff)
Show feed entries using JavaScript if possible.
Diffstat (limited to 'public')
-rw-r--r--public/feed-list.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/public/feed-list.js b/public/feed-list.js
new file mode 100644
index 0000000..cce8911
--- /dev/null
+++ b/public/feed-list.js
@@ -0,0 +1,45 @@
+YUI({base: "/yui3/build/", timeout: 10000}).use("io-base", function(Y) {
+ function successHandler(entry_id) {
+ function updateEntry(id, response) {
+ var elem = Y.Node.get("#entry-" + entry_id + "-container");
+ var xml = response.responseXML.documentElement;
+ var uri = xml.getElementsByTagName('uri')[0].firstChild.nodeValue;
+ var title = xml.getElementsByTagName('title')[0].firstChild.nodeValue;
+ var content = xml.getElementsByTagName('content')[0].firstChild.nodeValue;
+ elem.set("innerHTML", '<a href="' + uri + '"><h3>' + title + '</h3></a>' +
+ '<div class="entry-content">' + content + '</div>');
+ }
+
+ return updateEntry;
+ }
+
+ function failureHandler(entry_id) {
+ function updateEntry(id, response) {
+ var elem = Y.Node.get("#entry-" + entry_id + "-container");
+ // FIXME
+ alert ("No content.");
+ }
+
+ return updateEntry;
+ }
+
+ function getEntry(event) {
+ event.preventDefault();
+ var id_string = this.get('id');
+ var id = id_string.slice(6);
+ var queryURI = '/entry-xml?id=' + id;
+ Y.log("Querying server for entry: " + id, "info", "cljssss^g");
+ var request = Y.io(queryURI, {
+ method: "GET",
+ on: {
+ success: successHandler(id),
+ failure: failureHandler(id)
+ }});
+ }
+
+// Y.on("click", getEntry, ".entry-link");
+ Y.Node.all(".entry-link").each(function(elem, key) {
+ Y.on("click", getEntry, elem, elem);
+ });
+
+});