X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmkws-widget-categories.js;h=61abb4e3d36c870096b6a893838463a8b8daded4;hb=8dca06c07b94d4c6891d4a892280eb70f14d0b57;hp=4d2f7e77e38bfc3f28921406e45b627a4da259ab;hpb=2827e0f2dc405c6085f2092d8d2debc395941570;p=mkws-moved-to-github.git
diff --git a/src/mkws-widget-categories.js b/src/mkws-widget-categories.js
index 4d2f7e7..61abb4e 100644
--- a/src/mkws-widget-categories.js
+++ b/src/mkws-widget-categories.js
@@ -1,33 +1,35 @@
-mkws.registerWidgetType('Categories', function() {
- var that = this;
+mkws.registerWidgetType('categories', function() {
+ var that = this;
- if (!this.config.use_service_proxy) {
- alert("can't use categories widget without Service Proxy");
- return;
- }
+ if (!mkws.authenticated) {
+ alert("can't use categories widget when not authenticated");
+ return;
+ }
- this.team.queue("authenticated").subscribe(function(authName, realm) {
- var req = new pzHttpRequest(that.config.pazpar2_url + "?command=categories", function(err) {
- alert("HTTP call for categories failed: " + err)
- });
+ this.team.queue("authenticated").subscribe(function(authName, realm) {
+ var req = new pzHttpRequest(mkws.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);
+ req.get(null, function(data) {
+ if (!$.isXMLDoc(data)) {
+ alert("categories response document is not XML");
+ return;
+ }
+ that.info("got categories: " + data);
- var text = [];
- text.push("Select category: ");
- text.push("");
- $(that.node).html(text.join(''));
- });
+ var text = [];
+ text.push("Select category: ");
+ text.push("");
+ that.node.html(text.join(''));
});
+ });
});