X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=bcbb403f013b1356dbaac31436c27c12223fba09;hb=8d9bd3ea6f63478797e49f3dbbdd9d6ecd67ffd7;hp=64e7351a3f9749c2c61fcf08ed952fead3a32772;hpb=cc3b4f99c2c25fbd7dfe117532efc92d3db34d86;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 64e7351..bcbb403 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -158,21 +158,23 @@ function widget($, team, type, node) { var M = mkws.M; - if (type === 'Targets') { - promoteTargets(); - } else if (type === 'Stat') { - promoteStat(); - } else if (type === 'Termlists') { - promoteTermlists(); - } else if (type === 'Pager') { - promotePager(); - } else if (type === 'Records') { - promoteRecords(); + 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 + ")"); } - mkws.debug("made widget(team=" + team + ", type=" + type + ", node=" + node); return that; @@ -182,8 +184,6 @@ function widget($, team, type, node) { function promoteTargets() { team.queue("targets").subscribe(function(data) { - if (node.length === 0) alert("huh?!"); - var table ='' + '' + '' + @@ -355,7 +355,7 @@ function widget($, team, type, node) { // from the team object into this widget. if (hit.recid == team.currentRecordId()) { if (team.currentRecordData()) - html.push(renderDetails(team.currentRecordData())); + html.push(team.renderDetails(team.currentRecordData())); } } $(node).html(html.join('')); @@ -369,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); + }); + } } @@ -406,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(); @@ -414,6 +440,7 @@ function team($, teamName) { mkws.debug(m_teamName + ": " + timestamp + s); } + that.debug = debug; debug("start running MKWS"); @@ -544,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(); } @@ -844,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() + ' '; } @@ -1068,6 +1075,7 @@ function team($, teamName) { var details = template(data); return '
' + details + '
'; } + that.renderDetails = renderDetails; function loadTemplate(name) @@ -1505,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') + '