From: Mike Taylor Date: Mon, 3 Mar 2014 17:10:26 +0000 (+0000) Subject: Reorder functions: all onXXX handlers together, in order. X-Git-Tag: 1.0.0~1354 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=27b7bc85372b54c732469f43950d3d6e15d13344;p=mkws-moved-to-github.git Reorder functions: all onXXX handlers together, in order. --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 2a4449f..5c40cb3 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -281,40 +281,31 @@ function team($, teamName) { } - function onShow(data, teamName) { - debug("show"); - m_totalRec = data.merged; - - var pager = findnode(".mkwsPager"); - if (pager.length) { - pager.html(drawPager(data)) + function onBytarget(data, teamName) { + debug("target"); + var targetDiv = findnode('.mkwsBytarget'); + if (!targetDiv) { + return; } - var results = findnode(".mkwsRecords"); - if (!results.length) - return; + var table ='' + + '' + + '' + + '' + + '' + + '' + + ''; - var html = []; - for (var i = 0; i < data.hits.length; i++) { - var hit = data.hits[i]; - html.push('
', - renderSummary(hit), - '
'); - if (hit.recid == m_curDetRecId) { - if (m_curDetRecData) - html.push(renderDetails(m_curDetRecData)); - } + for (var i = 0; i < data.length; i++) { + table += ""; } - results.html(html.join('')); - } - - 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); + table += '
' + M('Target ID') + '' + M('Hits') + '' + M('Diags') + '' + M('Records') + '' + M('State') + '
" + data[i].id + + "" + data[i].hits + + "" + data[i].diagnostic + + "" + data[i].records + + "" + data[i].state + "
'; + targetDiv.html(table); } @@ -367,6 +358,57 @@ function team($, teamName) { } + function onShow(data, teamName) { + debug("show"); + m_totalRec = data.merged; + + var pager = findnode(".mkwsPager"); + if (pager.length) { + pager.html(drawPager(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_curDetRecId) { + if (m_curDetRecData) + html.push(renderDetails(m_curDetRecData)); + } + } + results.html(html.join('')); + } + + + function onRecord(data, args, teamName) { + debug("record: teamName=" + teamName + ", m_teamName=" + m_teamName); + // FIXME: record is async!! + clearTimeout(m_paz.recordTimer); + // in case on_show was faster to redraw element + var detRecordDiv = document.getElementById('mkwsDet_' + teamName + '_' + data.recid); + if (detRecordDiv) return; + m_curDetRecData = data; + var recordDiv = document.getElementById('mkwsRecdiv_' + teamName + '_' + m_curDetRecData.recid); + var html = renderDetails(m_curDetRecData); + recordDiv.innerHTML += html; + } + + + 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 addSingleFacet(acc, caption, data, max, pzIndex) { acc.push('
'); acc.push('
' + M(caption) + '
'); @@ -402,47 +444,6 @@ function team($, teamName) { } - function onRecord(data, args, teamName) { - debug("record: teamName=" + teamName + ", m_teamName=" + m_teamName); - // FIXME: record is async!! - clearTimeout(m_paz.recordTimer); - // in case on_show was faster to redraw element - var detRecordDiv = document.getElementById('mkwsDet_' + teamName + '_' + data.recid); - if (detRecordDiv) return; - m_curDetRecData = data; - var recordDiv = document.getElementById('mkwsRecdiv_' + teamName + '_' + m_curDetRecData.recid); - var html = renderDetails(m_curDetRecData); - recordDiv.innerHTML += html; - } - - - function onBytarget(data, teamName) { - debug("target"); - var targetDiv = findnode('.mkwsBytarget'); - if (!targetDiv) { - return; - } - - var table ='' + - '' + - '' + - '' + - '' + - '' + - ''; - - for (var i = 0; i < data.length; i++) { - table += ""; - } - - table += '
' + M('Target ID') + '' + M('Hits') + '' + M('Diags') + '' + M('Records') + '' + M('State') + '
" + data[i].id + - "" + data[i].hits + - "" + data[i].diagnostic + - "" + data[i].records + - "" + data[i].state + "
'; - targetDiv.html(table); - } - //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////