From: Mike Taylor Date: Wed, 3 Jul 2013 12:41:12 +0000 (+0100) Subject: Several different things happening, should have committed separately. X-Git-Tag: 0.9.1~354 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=51e5e9c94a99b6fa3527a05f57c100501341404a;p=mkws-moved-to-github.git Several different things happening, should have committed separately. -- Swap #mkwsResults and #mkwsRecords IDs. -- Allow correct functioning in absence of #kwsSelect. -- Fix typo in comment -- Towards allowing application with no #mkwsResults. -- Towards allowing clever applications to roll their own results area instead of using our premade one. --- diff --git a/experiments/spclient/mkws.js b/experiments/spclient/mkws.js index 3abf9da..7897f96 100644 --- a/experiments/spclient/mkws.js +++ b/experiments/spclient/mkws.js @@ -121,7 +121,7 @@ function my_onshow(data) { + data.total + ')'; drawPager(pager); // navi - var results = document.getElementById("mkwsResults"); + var results = document.getElementById("mkwsRecords"); var html = []; for (var i = 0; i < data.hits.length; i++) { @@ -246,8 +246,10 @@ function domReady () { document.mkwsSearchForm.onsubmit = onFormSubmitEventHandler; document.mkwsSearchForm.mkwsQuery.value = ''; - document.mkwsSelect.mkwsSort.onchange = onSelectDdChange; - document.mkwsSelect.mkwsPerpage.onchange = onSelectDdChange; + if (document.mkwsSelect) { + document.mkwsSelect.mkwsSort.onchange = onSelectDdChange; + document.mkwsSelect.mkwsPerpage.onchange = onSelectDdChange; + } } // when search button pressed @@ -283,8 +285,10 @@ function triggerSearch () function loadSelect () { - curSort = document.mkwsSelect.mkwsSort.value; - recPerPage = document.mkwsSelect.mkwsPerpage.value; + if (document.mkwsSelect) { + curSort = document.mkwsSelect.mkwsSort.value; + recPerPage = document.mkwsSelect.mkwsPerpage.value; + } } // limit the query after clicking the facet @@ -386,28 +390,28 @@ function pagerPrev() { curPage--; } -// swithing view between targets and records +// switching view between targets and records function switchView(view) { var targets = document.getElementById('mkwsTargets'); - var records = document.getElementById('mkwsRecords'); + var records = document.getElementById('mkwsResults'); var blanket = document.getElementById('mkwsBlanket'); switch(view) { case 'targets': targets.style.display = "block"; - records.style.display = "none"; + if (records) records.style.display = "none"; if (blanket) { blanket.style.display = "none"; } break; case 'records': targets.style.display = "none"; - records.style.display = "block"; + if (records) records.style.display = "block"; if (blanket) { blanket.style.display = "block"; } break; case 'none': targets.style.display = "none"; - records.style.display = "none"; + if (records) records.style.display = "none"; if (blanket) { blanket.style.display = "none"; } break; default: @@ -546,26 +550,39 @@ function mkws_html_all(config) { '); debug("HTML records"); - $("#mkwsRecords").html('\ + // If the application has an #mkwsResults, populate it in the + // usual way. If not, assume that it's a smarter application that + // defines its own subcomponents: + // #mkwsTermlists + // #mkwsRanking + // #mkwsPager + // #mkwsNavi + // #mkwsRecords + if ($("#mkwsResults").length) { + $("#mkwsResults").html('\ \ \ \ \ \
\
\
\ -
\ -
\ - ' + M('Sort by') + ' ' + mkws_html_sort(config) + '\ - ' + M('and show') + ' ' + mkws_html_perpage(config) + '\ - ' + M('per page') + '.\ -
\ -
\ +
\
\
\ -
\ +
\
'); + } + + if ($("#mkwsRanking").length == 2) { + $("#mkwsRanking").html('\ +
\ + ' + M('Sort by') + ' ' + mkws_html_sort(config) + '\ + ' + M('and show') + ' ' + mkws_html_perpage(config) + '\ + ' + M('per page') + '.\ +
'); + } mkws_html_switch(config); @@ -792,7 +809,7 @@ jQuery.extend({ document.write('
\
\
\ -
\ +
\
\
\
\