Not quite a trivial Categories widget any more.
[mkws-moved-to-github.git] / src / mkws-widget-categories.js
1 mkws.registerWidgetType('Categories', function() {
2     var that = this;
3
4     if (!this.config.use_service_proxy) {
5         alert("can't use categories widget without Service Proxy");
6         return;
7     }
8
9     this.team.queue("authenticated").subscribe(function(authName, realm) {
10         $(that.node).append("<p><b>Categories for " + realm + "</b></p>");      
11         var req = new pzHttpRequest(that.config.pazpar2_url + "?command=categories", function(err) {
12             alert("HTTP call for categories failed: " + err)
13         });
14
15         req.get(null, function(data) {
16             if (!$.isXMLDoc(data)) {
17                 alert("categories response document is not XML");
18                 return;
19             }
20             that.log("got categories: " + data);
21             // Parse once we've figured out the format
22         });
23     });
24 });