X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=a8c0470c0cd1e511819df356b3e189984d2e8923;hb=88d2ed49777fe955226df0b4cbe509aa042e07e6;hp=634108723896ec0253cc2b2d8271976a57fbfdd2;hpb=16708a6aebe10acd3b72bcb20b03c54d1195a1b9;p=mkws-moved-to-github.git
diff --git a/src/mkws-core.js b/src/mkws-core.js
index 6341087..a8c0470 100644
--- a/src/mkws-core.js
+++ b/src/mkws-core.js
@@ -111,10 +111,11 @@ mkws.M = function(word) {
// This function is taken from a StackOverflow answer
// http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144
-mkws.getParameterByName = function(name) {
+mkws.getParameterByName = function(name, url) {
+ if (!url) url = location.search;
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
- results = regex.exec(location.search);
+ results = regex.exec(url);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@@ -258,11 +259,18 @@ mkws.defaultTemplate = function(name) {
\
\
';
+ } else if (name === 'Facet') {
+ return '\
+{{term}}\
+{{count}}\
+';
}
- var s = "There is no default '" + name +"' template!";
- alert(s);
- return s;
+ return null;
};
@@ -430,7 +438,7 @@ mkws.pagerNext = function(tname) {
function selectorForAllWidgets() {
- if (mkws.config.scan_all_nodes) {
+ if (mkws.config && mkws.config.scan_all_nodes) {
// This is the old version, which works by telling jQuery to
// find every node that has a class beginning with "mkws". In
// theory it should be slower than the class-based selector; but
@@ -479,7 +487,8 @@ mkws.pagerNext = function(tname) {
}
- $(document).ready(function() {
+ function init(rootsel) {
+ if (!rootsel) var rootsel = ':root';
var saved_config;
if (typeof mkws_config === 'undefined') {
log("setting empty config");
@@ -544,7 +553,7 @@ mkws.pagerNext = function(tname) {
}
var then = $.now();
- makeWidgetsWithin(1, $(':root'));
+ makeWidgetsWithin(1, $(rootsel));
var now = $.now();
log("walking MKWS nodes took " + (now-then) + " ms");
@@ -567,5 +576,9 @@ mkws.pagerNext = function(tname) {
// raw pp2
runAutoSearches();
}
+ };
+ $(document).ready(function() {
+ var widgetSelector = selectorForAllWidgets();
+ if (widgetSelector && $(widgetSelector).length !== 0) init();
});
})(jQuery);