From a1a99d008c1bf102129b8cfd7ad15bf5168fc41d Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Sat, 26 Apr 2014 01:26:23 +0100 Subject: [PATCH] The widget.autosearch function now understands queries of the form !var!name (as well as !param!name and !path!number) Allows the application to set the query into a named variable in whatever way it wishes, and have MKWS obtain it from that variable. Fixes bug MKWS-170. --- src/mkws-widgets.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mkws-widgets.js b/src/mkws-widgets.js index 517850b..c677853 100644 --- a/src/mkws-widgets.js +++ b/src/mkws-widgets.js @@ -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; -- 1.7.10.4