X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=0ff94ff94a132b8b683412901a22f64ad51e7164;hb=05e195768393c50779514624d27fbf8942a9955e;hp=0b0a5099537baaa245333e0cdb79213f2be07958;hpb=4a46b49eca2fe9a7b3bf01c3934215367b7e3050;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 0b0a509..0ff94ff 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -160,17 +160,24 @@ function widget($, team, type, node) { 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 + ")"); } 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; @@ -338,6 +345,35 @@ function widget($, team, type, node) { } }); } + + + function promoteRecords() { + team.queue("records").subscribe(function(data) { + var html = []; + for (var i = 0; i < data.hits.length; i++) { + var hit = data.hits[i]; + html.push('
', + renderSummary(hit), + '
'); + // ### At some point, we may be able to move the + // m_currentRecordId and m_currentRecordData members + // from the team object into this widget. + if (hit.recid == team.currentRecordId()) { + if (team.currentRecordData()) + html.push(team.renderDetails(team.currentRecordData())); + } + } + $(node).html(html.join('')); + + function renderSummary(hit) + { + var template = team.loadTemplate("Summary"); + hit._id = "mkwsRec_" + hit.recid; + hit._onclick = "mkws.showDetails('" + team.name() + "', this.id);return false;" + return template(hit); + } + }); + } } @@ -373,6 +409,8 @@ function team($, teamName) { that.perpage = function() { return m_perpage; } that.totalRecordCount = function() { return m_totalRecordCount; } that.currentPage = function() { return m_currentPage; } + that.currentRecordId = function() { return m_currentRecordId; } + that.currentRecordData = function() { return m_currentRecordData; } var debug = function (s) { var now = $.now(); @@ -381,6 +419,7 @@ function team($, teamName) { mkws.debug(m_teamName + ": " + timestamp + s); } + that.debug = debug; debug("start running MKWS"); @@ -436,25 +475,8 @@ function team($, teamName) { function onShow(data, teamName) { debug("show"); m_totalRecordCount = data.merged; - queue("pager").publish(data); - - var results = findnode(".mkwsRecords"); - if (!results.length) - return; - - var html = []; - for (var i = 0; i < data.hits.length; i++) { - var hit = data.hits[i]; - html.push('
', - renderSummary(hit), - '
'); - if (hit.recid == m_currentRecordId) { - if (m_currentRecordData) - html.push(renderDetails(m_currentRecordData)); - } - } - results.html(html.join('')); + queue("records").publish(data); } @@ -1046,21 +1068,13 @@ function team($, teamName) { } - function renderSummary(hit) - { - var template = loadTemplate("Summary"); - hit._id = "mkwsRec_" + hit.recid; - hit._onclick = "mkws.showDetails('" + m_teamName + "', this.id);return false;" - return template(hit); - } - - function renderDetails(data, marker) { var template = loadTemplate("Record"); var details = template(data); return '
' + details + '
'; } + that.renderDetails = renderDetails; function loadTemplate(name) @@ -1086,6 +1100,7 @@ function team($, teamName) { return template; } + that.loadTemplate = loadTemplate; // The following PubSub code is modified from the jQuery manual: