From: Mike Taylor Date: Fri, 24 Jan 2014 12:31:50 +0000 (+0000) Subject: Single global mkws.paz changed to per-team m_paz. X-Git-Tag: 1.0.0~1616 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=cf5a5a8b95f1e56bb4eb603f91c978aea6e1f04f;p=mkws-moved-to-github.git Single global mkws.paz changed to per-team m_paz. run_auto_searches() moved to be member of global mkws. --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index a6c3893..1a0782d 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -159,6 +159,7 @@ function _make_mkws_team($, teamName) { "start": $.now(), "last": $.now() }; + var m_paz; // will be initialised below // if (console && console.log) // disabled, will fail in IE8 @@ -265,20 +266,18 @@ function _make_mkws_team($, teamName) { // create a parameters array and pass it to the pz2's constructor // then register the form submit event with the pz2.search function // autoInit is set to true on default - if (!mkws.paz) { - mkws.paz = new pz2({ "onshow": my_onshow, - "windowid": teamName, - "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way - "pazpar2path": mkws_config.pazpar2_url, - "oninit": my_oninit, - "onstat": my_onstat, - "onterm": my_onterm, - "termlist": "xtargets,subject,author", - "onbytarget": my_onbytarget, - "usesessions" : mkws_config.use_service_proxy ? false : true, - "showResponseType": '', // or "json" (for debugging?) - "onrecord": my_onrecord }); - } + m_paz = new pz2({ "onshow": my_onshow, + "windowid": teamName, + "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way + "pazpar2path": mkws_config.pazpar2_url, + "oninit": my_oninit, + "onstat": my_onstat, + "onterm": my_onterm, + "termlist": "xtargets,subject,author", + "onbytarget": my_onbytarget, + "usesessions" : mkws_config.use_service_proxy ? false : true, + "showResponseType": '', // or "json" (for debugging?) + "onrecord": my_onrecord }); if (!isNaN(parseInt(mkws_config.perpage_default))) { m_recPerPage = parseInt(mkws_config.perpage_default); @@ -290,8 +289,8 @@ function _make_mkws_team($, teamName) { // function my_oninit(teamName) { debug("init for " + teamName); - mkws.paz.stat(); - mkws.paz.bytarget(); + m_paz.stat(); + m_paz.bytarget(); } @@ -407,7 +406,7 @@ function _make_mkws_team($, teamName) { function my_onrecord(data, teamName) { debug("record for " + teamName); // FIXME: record is async!! - clearTimeout(mkws.paz.recordTimer); + clearTimeout(m_paz.recordTimer); // in case on_show was faster to redraw element var detRecordDiv = document.getElementById('mkwsDet_'+data.recid); if (detRecordDiv) return; @@ -496,7 +495,7 @@ function _make_mkws_team($, teamName) { if (!m_submitted) return false; resetPage(); loadSelect(); - mkws.paz.show(0, m_recPerPage, m_sort); + m_paz.show(0, m_recPerPage, m_sort); return false; } @@ -552,7 +551,7 @@ function _make_mkws_team($, teamName) { } debug("triggerSearch(" + m_query + "): filters = " + $.toJSON(m_filters) + ", pp2filter = " + pp2filter + ", params = " + $.toJSON(params)); - mkws.paz.search(m_query, m_recPerPage, m_sort, pp2filter, undefined, params); + m_paz.search(m_query, m_recPerPage, m_sort, pp2filter, undefined, params); } @@ -716,21 +715,21 @@ function _make_mkws_team($, teamName) { mkws.showPage = function (pageNum) { m_curPage = pageNum; - mkws.paz.showPage(m_curPage - 1); + m_paz.showPage(m_curPage - 1); } // simple paging functions mkws.pagerNext = function () { if (m_totalRec - m_recPerPage*m_curPage > 0) { - mkws.paz.showNext(); + m_paz.showNext(); m_curPage++; } } mkws.pagerPrev = function () { - if (mkws.paz.showPrev() != false) + if (m_paz.showPrev() != false) m_curPage--; } @@ -789,7 +788,7 @@ function _make_mkws_team($, teamName) { return; } // request the record - mkws.paz.record(recId); + m_paz.record(recId); } @@ -1002,7 +1001,7 @@ function _make_mkws_team($, teamName) { } - function run_auto_searches() { + mkws.run_auto_searches = function() { debug("running auto searches"); $('[id^="mkwsRecords"]').each(function () { @@ -1418,7 +1417,7 @@ function _mkws_jquery_plugin ($) { mkws_config.pazpar2_url); } else { // raw pp2 - run_auto_searches(); + mkws.run_auto_searches(); } }); @@ -1454,7 +1453,7 @@ function _mkws_jquery_plugin ($) { debug("Service proxy auth successfully done"); mkws.authenticated = true; - run_auto_searches(); + mkws.run_auto_searches(); }); } })(jQuery);