Not quite a trivial Categories widget any more.
authorMike Taylor <mike@indexdata.com>
Thu, 17 Apr 2014 16:13:38 +0000 (17:13 +0100)
committerMike Taylor <mike@indexdata.com>
Thu, 17 Apr 2014 16:13:55 +0000 (17:13 +0100)
src/mkws-widget-categories.js

index 3b21da1..0b1f114 100644 (file)
@@ -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("<p><b>Categories for " + realm + "</b></p>");      
+       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
+       });
+    });
+});