X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=bcbb403f013b1356dbaac31436c27c12223fba09;hb=8d9bd3ea6f63478797e49f3dbbdd9d6ecd67ffd7;hp=0ff94ff94a132b8b683412901a22f64ad51e7164;hpb=05e195768393c50779514624d27fbf8942a9955e;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 0ff94ff..bcbb403 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -158,24 +158,21 @@ function widget($, team, type, node) { var M = mkws.M; - if (type === 'Targets') { - promoteTargets(); - team.debug("made targets widget(node=" + node + ")"); - } else if (type === 'Stat') { - promoteStat(); - team.debug("made stat widget(node=" + node + ")"); - } else if (type === 'Termlists') { - promoteTermlists(); - team.debug("made termlists widget(node=" + node + ")"); - } else if (type === 'Pager') { - promotePager(); - team.debug("made pager widget(node=" + node + ")"); - } else if (type === 'Records') { - promoteRecords(); - team.debug("made records widget(node=" + node + ")"); + var type2fn = { + Targets: promoteTargets, + Stat: promoteStat, + Termlists: promoteTermlists, + Pager: promotePager, + Records: promoteRecords, + Navi: promoteNavi + }; + + var promote = type2fn[type]; + if (promote) { + promote(); + team.debug("made " + type + " widget(node=" + node + ")"); } else { - // ### Handle other types here - team.debug("made unencapsulated widget(type=" + type + ", node=" + node + ")"); + team.debug("made UNENCAPSULATED widget(type=" + type + ", node=" + node + ")"); } return that; @@ -187,8 +184,6 @@ function widget($, team, type, node) { function promoteTargets() { team.queue("targets").subscribe(function(data) { - if (node.length === 0) alert("huh?!"); - var table ='' + '' + '' + @@ -374,6 +369,31 @@ function widget($, team, type, node) { } }); } + + + function promoteNavi() { + team.queue("navi").subscribe(function() { + var filters = team.filters(); + var text = ""; + + for (var i in filters) { + if (text) { + text += " | "; + } + var filter = filters[i]; + if (filter.id) { + text += M('source') + ': ' + filter.name + ''; + } else { + text += M(filter.field) + ': ' + filter.value + ''; + } + } + + $(node).html(text); + }); + } } @@ -411,6 +431,7 @@ function team($, teamName) { that.currentPage = function() { return m_currentPage; } that.currentRecordId = function() { return m_currentRecordId; } that.currentRecordData = function() { return m_currentRecordData; } + that.filters = function() { return m_filters; } var debug = function (s) { var now = $.now(); @@ -550,26 +571,7 @@ function team($, teamName) { function redrawNavi () { - var navi = findnode('.mkwsNavi'); - if (!navi) return; - - var text = ""; - for (var i in m_filters) { - if (text) { - text += " | "; - } - var filter = m_filters[i]; - if (filter.id) { - text += M('source') + ': ' + filter.name + ''; - } else { - text += M(filter.field) + ': ' + filter.value + ''; - } - } - - navi.html(text); + queue("navi").publish(); } @@ -850,8 +852,7 @@ function team($, teamName) { var node = findnode(".mkwsRanking"); if (node.length) { - var ranking_data = ''; - ranking_data += ''; + var ranking_data = ''; if (mkws_config.show_sort) { ranking_data += M('Sort by') + ' ' + mkwsHtmlSort() + ' '; } @@ -1512,7 +1513,7 @@ function team($, teamName) { // Second pass: make the individual widget objects. This has // to be done separately, and after the team-creation, since // that sometimes makes new widget nodes (e.g. creating - // mkwsTermlists instead mkwsResults. + // mkwsTermlists inside mkwsResults. $('[class^="mkws"],[class*=" mkws"]').each(function () { mkws.handleNodeWithTeam(this, function(tname, type) { var myTeam = mkws.teams[tname];
' + M('Target ID') + '' + M('Hits') + '