Switch widget now generates it own HTML.
[mkws-moved-to-github.git] / src / mkws-widgets.js
index 517850b..d360730 100644 (file)
@@ -83,6 +83,13 @@ widget.autosearch = function(widget) {
                if (!query) {
                    alert("This page has a MasterKey widget that needs a query specified by the path-component " + index);
                }
+            } else if (query.match(/^!var!/)) {
+               var name = query.replace(/^!var!/, '');
+               query = window[name]; // It's ridiculous that this works
+               widget.log("obtained query '" + query + "' from variable '" + name + "'");
+               if (!query) {
+                   alert("This page has a MasterKey widget that needs a query specified by the '" + name + "' variable");
+               }
            }
 
            var sortOrder = widget.config.sort;
@@ -325,3 +332,22 @@ mkws.registerWidgetType('Done', function() {
        $(that.node).html("Search complete: found " + n + " records");
     });
 });
+
+
+mkws.registerWidgetType('Switch', function() {
+    var tname = this.team.name();
+    $(this.node).html('\
+<a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
+| \
+</span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a> \
+<div class="mkwsUpperCase">foo</div>\
+');
+});
+
+
+mkws.registerWidgetType('UpperCase', function() {
+    var text = $(this.node).html();
+    $(this.node).html(text.toUpperCase());
+});
+
+