extract latest git commit ID from github, MKWS-420
[mkws-moved-to-github.git] / src / mkws-widget-categories.js
1 mkws.registerWidgetType('categories', function() {
2   var that = this;
3
4   this.team.queue("authenticated").subscribe(function(authName, realm) {
5     var req = new pzHttpRequest(mkws.pazpar2_url() + "?command=categories", function(err) {
6       alert("HTTP call for categories failed: " + err)
7     });
8
9     req.get(null, function(data) {
10       var $ = mkws.$;
11       if (!$.isXMLDoc(data)) {
12         alert("categories response document is not XML");
13         return;
14       }
15       that.info("got categories: " + data);
16
17       var text = [];
18       text.push("Select category: ");
19       text.push("<select name='mkws-category mkwsCategory' " +
20                 "onchange='mkws.limitCategory(\"" + that.team.name() + "\", this.value)'>");
21       text.push("<option value=''>[All]</option>");
22       $(data).find('category').each(function() {
23         var name = $(this).find('categoryName').text();
24         var id = $(this).find('categoryId').text();
25         text.push("<option value='", id, "'>", name, "</option>");
26       });
27       text.push("</select>");
28       that.node.html(text.join(''));
29     });
30   });
31 });