From 4a1ea6a97841cd64a5f9efd6c6bf3557689eac2b Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Sun, 30 Jun 2013 09:01:31 +0100 Subject: [PATCH] Factor out duplicate author/subject facet-generation code into new add_single_facet() function. Target facet is still (for now) done separately. --- experiments/spclient/mkws.js | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/experiments/spclient/mkws.js b/experiments/spclient/mkws.js index e7217ad..3bf3069 100644 --- a/experiments/spclient/mkws.js +++ b/experiments/spclient/mkws.js @@ -175,30 +175,24 @@ function my_onterm(data) { } termlists.push(''); - termlists.push('
'); - termlists.push('
' + M('Subjects') + '
'); - for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) { - termlists.push('' - + data.subject[i].name - + ' (' - + data.subject[i].freq - + ')
'); - } - termlists.push('
'); + add_single_facet(termlists, "Subjects", data.subject, SubjectMax, "su"); + add_single_facet(termlists, "Authors", data.author, AuthorMax, "au"); + + var termlist = document.getElementById("termlist"); + replaceHtml(termlist, termlists.join('')); +} +function add_single_facet(termlists, caption, data, max, cclIndex) { termlists.push('
'); - termlists.push('
' + M('Authors') + '
'); - for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) { - termlists.push('' - + data.author[i].name + termlists.push('
' + M(caption) + '
'); + for (var i = 0; i < data.length && i < max; i++ ) { + termlists.push('
' + + data[i].name + ' (' - + data.author[i].freq + + data[i].freq + ')
'); } termlists.push('
'); - - var termlist = document.getElementById("termlist"); - replaceHtml(termlist, termlists.join('')); } function my_onrecord(data) { -- 1.7.10.4