From: Mike Taylor Date: Thu, 17 Apr 2014 16:13:38 +0000 (+0100) Subject: Not quite a trivial Categories widget any more. X-Git-Tag: 1.0.0~907^2~4 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=6d77d26b06a5a066405c63ca02369cd9f30ed46e;p=mkws-moved-to-github.git Not quite a trivial Categories widget any more. --- diff --git a/src/mkws-widget-categories.js b/src/mkws-widget-categories.js index 3b21da1..0b1f114 100644 --- a/src/mkws-widget-categories.js +++ b/src/mkws-widget-categories.js @@ -1 +1,24 @@ -var req = new pzHttpRequest(auth.servicePath + "?command=categories"); +mkws.registerWidgetType('Categories', function() { + var that = this; + + if (!this.config.use_service_proxy) { + alert("can't use categories widget without Service Proxy"); + return; + } + + this.team.queue("authenticated").subscribe(function(authName, realm) { + $(that.node).append("

Categories for " + realm + "

"); + var req = new pzHttpRequest(that.config.pazpar2_url + "?command=categories", function(err) { + alert("HTTP call for categories failed: " + err) + }); + + req.get(null, function(data) { + if (!$.isXMLDoc(data)) { + alert("categories response document is not XML"); + return; + } + that.log("got categories: " + data); + // Parse once we've figured out the format + }); + }); +});