From d2b83a91581809fa14754b891a074f102f9f3400 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Wed, 7 May 2014 13:21:40 +0100 Subject: [PATCH] Re-indent. --- src/mkws-widget-main.js | 588 +++++++++++++++++++++++------------------------ 1 file changed, 294 insertions(+), 294 deletions(-) diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index 9bb08eb..41201dd 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -4,176 +4,176 @@ mkws.registerWidgetType('Targets', function() { - var that = this; - var M = mkws.M; + var that = this; + var M = mkws.M; - $(this.node).html('\ + $(this.node).html('\
\ No information available yet.\
'); - $(this.node).css("display", "none"); - - this.team.queue("targets").subscribe(function(data) { - 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 + "
'; - var subnode = $(that.node).children('.mkwsBytarget'); - subnode.html(table); - }); + $(this.node).css("display", "none"); + + this.team.queue("targets").subscribe(function(data) { + 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 + "
'; + var subnode = $(that.node).children('.mkwsBytarget'); + subnode.html(table); + }); }); mkws.registerWidgetType('Stat', function() { - var that = this; - var M = mkws.M; - - this.team.queue("stat").subscribe(function(data) { - if (that.node.length === 0) alert("huh?!"); - - $(that.node).html('' + M('Status info') + '' + - ' -- ' + - '' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '' + - ' -- ' + - '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + ''); - }); + var that = this; + var M = mkws.M; + + this.team.queue("stat").subscribe(function(data) { + if (that.node.length === 0) alert("huh?!"); + + $(that.node).html('' + M('Status info') + '' + + ' -- ' + + '' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '' + + ' -- ' + + '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + ''); + }); }); mkws.registerWidgetType('Pager', function() { - var that = this; - var M = mkws.M; - - this.team.queue("pager").subscribe(function(data) { - $(that.node).html(drawPager(data)) - - function drawPager(data) { - var teamName = that.team.name(); - var s = '
' + M('Displaying') + ': ' - + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) + - ' ' + M('of') + ' ' + data.merged + ' (' + M('found') + ': ' - + data.total + ')
'; - - //client indexes pages from 1 but pz2 from 0 - var onsides = 6; - var pages = Math.ceil(that.team.totalRecordCount() / that.team.perpage()); - var currentPage = that.team.currentPage(); - - var firstClkbl = (currentPage - onsides > 0) - ? currentPage - onsides - : 1; - - var lastClkbl = firstClkbl + 2*onsides < pages - ? firstClkbl + 2*onsides - : pages; - - var prev = '<< ' + M('Prev') + ' | '; - if (currentPage > 1) - prev = '' - +'<< ' + M('Prev') + ' | '; - - var middle = ''; - for(var i = firstClkbl; i <= lastClkbl; i++) { - var numLabel = i; - if(i == currentPage) - numLabel = '' + i + ''; - - middle += ' ' - + numLabel + ' '; - } - - var next = ' | ' + M('Next') + ' >>'; - if (pages - currentPage > 0) - next = ' | ' - + M('Next') + ' >>'; - - var predots = ''; - if (firstClkbl > 1) - predots = '...'; - - var postdots = ''; - if (lastClkbl < pages) - postdots = '...'; - - s += '
' - + prev + predots + middle + postdots + next + '
'; - - return s; - } - }); + var that = this; + var M = mkws.M; + + this.team.queue("pager").subscribe(function(data) { + $(that.node).html(drawPager(data)) + + function drawPager(data) { + var teamName = that.team.name(); + var s = '
' + M('Displaying') + ': ' + + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) + + ' ' + M('of') + ' ' + data.merged + ' (' + M('found') + ': ' + + data.total + ')
'; + + //client indexes pages from 1 but pz2 from 0 + var onsides = 6; + var pages = Math.ceil(that.team.totalRecordCount() / that.team.perpage()); + var currentPage = that.team.currentPage(); + + var firstClkbl = (currentPage - onsides > 0) + ? currentPage - onsides + : 1; + + var lastClkbl = firstClkbl + 2*onsides < pages + ? firstClkbl + 2*onsides + : pages; + + var prev = '<< ' + M('Prev') + ' | '; + if (currentPage > 1) + prev = '' + +'<< ' + M('Prev') + ' | '; + + var middle = ''; + for(var i = firstClkbl; i <= lastClkbl; i++) { + var numLabel = i; + if(i == currentPage) + numLabel = '' + i + ''; + + middle += ' ' + + numLabel + ' '; + } + + var next = ' | ' + M('Next') + ' >>'; + if (pages - currentPage > 0) + next = ' | ' + + M('Next') + ' >>'; + + var predots = ''; + if (firstClkbl > 1) + predots = '...'; + + var postdots = ''; + if (lastClkbl < pages) + postdots = '...'; + + s += '
' + + prev + predots + middle + postdots + next + '
'; + + return s; + } + }); }); mkws.registerWidgetType('Records', function() { - var that = this; - var team = this.team; - - this.team.queue("records").subscribe(function(data) { - var html = []; - for (var i = 0; i < data.hits.length; i++) { - var hit = data.hits[i]; - that.team.queue("record").publish(hit); - var divId = team.recordElementId(hit.recid[0]); - 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())); - } - } - $(that.node).html(html.join('')); - - function renderSummary(hit) { - var template = team.loadTemplate(that.config.template || "Summary"); - hit._id = team.recordElementId(hit.recid[0]); - hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;" - return template(hit); - } - }); + var that = this; + var team = this.team; + + this.team.queue("records").subscribe(function(data) { + var html = []; + for (var i = 0; i < data.hits.length; i++) { + var hit = data.hits[i]; + that.team.queue("record").publish(hit); + var divId = team.recordElementId(hit.recid[0]); + 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())); + } + } + $(that.node).html(html.join('')); - widget.autosearch(that); + function renderSummary(hit) { + var template = team.loadTemplate(that.config.template || "Summary"); + hit._id = team.recordElementId(hit.recid[0]); + hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;" + return template(hit); + } + }); + + widget.autosearch(that); }); mkws.registerWidgetType('Navi', function() { - var that = this; - var teamName = this.team.name(); - var M = mkws.M; - - this.team.queue("navi").subscribe(function() { - var filters = that.team.filters(); - var text = ""; - - filters.visitTargets(function(id, name) { - if (text) text += " | "; - text += M('source') + ': ' + name + ''; - }); - - filters.visitFields(function(field, value) { - if (text) text += " | "; - text += M(field) + ': ' + value + ''; - }); - - $(that.node).html(text); + var that = this; + var teamName = this.team.name(); + var M = mkws.M; + + this.team.queue("navi").subscribe(function() { + var filters = that.team.filters(); + var text = ""; + + filters.visitTargets(function(id, name) { + if (text) text += " | "; + text += M('source') + ': ' + name + ''; + }); + + filters.visitFields(function(field, value) { + if (text) text += " | "; + text += M(field) + ': ' + value + ''; }); + + $(that.node).html(text); + }); }); @@ -181,55 +181,55 @@ mkws.registerWidgetType('Navi', function() { // anything, since they produce events rather than consuming them. // mkws.registerWidgetType('Sort', function() { - var that = this; - - $(this.node).change(function() { - that.team.set_sortOrder($(that.node).val()); - if (that.team.submitted()) { - that.team.reShow(); - } - return false; - }); + var that = this; + + $(this.node).change(function() { + that.team.set_sortOrder($(that.node).val()); + if (that.team.submitted()) { + that.team.reShow(); + } + return false; + }); }); mkws.registerWidgetType('Perpage', function() { - var that = this; - - $(this.node).change(function() { - that.team.set_perpage($(that.node).val()); - if (that.team.submitted()) { - that.team.reShow(); - } - return false; - }); + var that = this; + + $(this.node).change(function() { + that.team.set_perpage($(that.node).val()); + if (that.team.submitted()) { + that.team.reShow(); + } + return false; + }); }); mkws.registerWidgetType('Done', function() { - var that = this; + var that = this; - this.team.queue("complete").subscribe(function(n) { - $(that.node).html("Search complete: found " + n + " records"); - }); + this.team.queue("complete").subscribe(function(n) { + $(that.node).html("Search complete: found " + n + " records"); + }); }); mkws.registerWidgetType('Switch', function() { - var tname = this.team.name(); - $(this.node).html('\ + var tname = this.team.name(); + $(this.node).html('\ Records \ | \ Targets'); - widget.hideWhenNarrow(this); + widget.hideWhenNarrow(this); }); mkws.registerWidgetType('Search', function() { - var tname = this.team.name(); - var M = mkws.M; + var tname = this.team.name(); + var M = mkws.M; - $(this.node).html('\ + $(this.node).html('\
\ \ \ @@ -238,19 +238,19 @@ mkws.registerWidgetType('Search', function() { mkws.registerWidgetType('SearchForm', function() { - var team = this.team; - $(this.node).submit(function() { - var val = team.widget('Query').value(); - team.newSearch(val); - return false; - }); + var team = this.team; + $(this.node).submit(function() { + var val = team.widget('Query').value(); + team.newSearch(val); + return false; + }); }); mkws.registerWidgetType('Results', function() { - var tname = this.team.name(); + var tname = this.team.name(); - $(this.node).html('\ + $(this.node).html('\ \ \ \
\ @@ -270,143 +270,143 @@ mkws.registerWidgetType('Results', function() {
'); - widget.autosearch(this); + widget.autosearch(this); }); mkws.registerWidgetType('Ranking', function() { - var tname = this.team.name(); - var that = this; - var M = mkws.M; - - var s = ''; - if (this.config.show_sort) { - s += M('Sort by') + ' ' + mkwsHtmlSort() + ' '; + var tname = this.team.name(); + var that = this; + var M = mkws.M; + + var s = ''; + if (this.config.show_sort) { + s += M('Sort by') + ' ' + mkwsHtmlSort() + ' '; + } + if (this.config.show_perpage) { + s += M('and show') + ' ' + mkwsHtmlPerpage() + ' ' + M('per page') + '.'; + } + s += '
'; + + $(this.node).html(s); + + + function mkwsHtmlSort() { + var order = that.team.sortOrder(); + + that.log("HTML sort, sortOrder = '" + order + "'"); + var sort_html = ''; + return sort_html; + } - function mkwsHtmlSort() { - var order = that.team.sortOrder(); + function mkwsHtmlPerpage() { + var perpage = that.team.perpage(); - that.log("HTML sort, sortOrder = '" + order + "'"); - var sort_html = ''; - for(var i = 0; i < that.config.sort_options.length; i++) { - var opt = that.config.sort_options[i]; - var key = opt[0]; - var val = opt.length == 1 ? opt[0] : opt[1]; + for(var i = 0; i < that.config.perpage_options.length; i++) { + var key = that.config.perpage_options[i]; - sort_html += '