X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-team.js;h=cf4794bb93f298cfb3dcec7bb45745dde2fd6324;hb=df823384f61228cdcedc53999e44dc4704c858f9;hp=8d33d9e87cb9a1fb661f169e6902aeea0f28429d;hpb=6a8b6776618229ff0cae8b19288124daf9239463;p=mkws-moved-to-github.git
diff --git a/src/mkws-team.js b/src/mkws-team.js
index 8d33d9e..cf4794b 100644
--- a/src/mkws-team.js
+++ b/src/mkws-team.js
@@ -26,7 +26,8 @@ function team($, teamName) {
"last": $.now()
};
var m_paz; // will be initialised below
- var m_template = {};
+ var m_tempateText = {}; // widgets can register tempates to be compiled
+ var m_template = {}; // compiled templates, from any source
var m_config = mkws.objectInheritingFrom(mkws.config);
var m_widgets = {}; // Maps widget-type to object
@@ -185,7 +186,9 @@ function team($, teamName) {
that.limitCategory = function(id) {
log("limitCategory(id=" + id + ")");
- m_filterSet.add(categoryFilter(id));
+ // Only one category filter at a time
+ m_filterSet.removeMatching(function(f) { return f.type === 'category' });
+ if (id !== '') m_filterSet.add(categoryFilter(id));
if (m_query) triggerSearch();
return false;
};
@@ -265,15 +268,17 @@ function team($, teamName) {
if (query) m_query = query;
if (sortOrder) m_sortOrder = sortOrder;
if (perpage) m_perpage = perpage;
- if (targets) m_filterSet.add(targetFilter(id, id));
+ if (targets) m_filterSet.add(targetFilter(targets, targets));
var pp2filter = m_filterSet.pp2filter();
var pp2limit = m_filterSet.pp2limit(limit);
var pp2catLimit = m_filterSet.pp2catLimit();
+ if (pp2catLimit) {
+ pp2filter = pp2filter ? pp2filter + "," + pp2catLimit : pp2catLimit;
+ }
var params = {};
if (pp2limit) params.limit = pp2limit;
- if (pp2catLimit) params.categoryfilter = pp2catLimit;
if (maxrecs) params.maxrecs = maxrecs;
if (torusquery) {
if (!mkws.config.use_service_proxy)
@@ -416,7 +421,10 @@ function team($, teamName) {
});
// on first page, hide the termlist
- $(document).ready(function() { widgetNode("Termlists").hide(); });
+ $(document).ready(function() {
+ var t = widgetNode("Termlists");
+ if (t) t.hide();
+ });
var container = findnode(".mkwsMOTDContainer");
if (container.length) {
// Move the MOTD from the provided element down into the container
@@ -437,7 +445,27 @@ function team($, teamName) {
return m_config.lang;
}
+ // set or re-set "lang" URL parameter
+ function lang_url(lang) {
+ var query = location.search;
+ // no query parameters? done
+ if (!query) {
+ return "?lang=" + lang;
+ }
+
+ // parameter does not exists
+ if (!query.match(/[\?&]lang=/)) {
+ return query + "&lang=" + lang;
+ }
+
+ // replace existing parameter
+ query = query.replace(/\?lang=([^]*)/, "?lang=" + lang);
+ query = query.replace(/\&lang=([^]*)/, "&lang=" + lang);
+ return query;
+ }
+
+ // dynamic URL or static page? /path/foo?query=test
/* create locale language menu */
function mkwsHtmlLang() {
var lang_default = "en";
@@ -473,7 +501,7 @@ function team($, teamName) {
if (lang == l) {
data += ' ' + l + ' ';
} else {
- data += ' ' + l + ' '
+ data += ' ' + l + ' '
}
}
@@ -589,6 +617,11 @@ function team($, teamName) {
that.renderDetails = renderDetails;
+ that.registerTemplate = function(name, text) {
+ m_tempateText[name] = text;
+ };
+
+
function loadTemplate(name) {
var template = m_template[name];
@@ -604,6 +637,9 @@ function team($, teamName) {
}
if (!source) {
+ source = m_tempateText[name];
+ }
+ if (!source) {
source = defaultTemplate(name);
}