X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=b735cf6609951b6d58f3953cab3e57176bd6553d;hb=e1e6241171d921bdf2dddb603ef40422fe1b5519;hp=98fc11c585e30739df018c568bb635cf06bafa0b;hpb=5c8af699d6eb45391f7d2aa9b344f710e8dd4db5;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 98fc11c..b735cf6 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -141,7 +141,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { // wrapper for jQuery lib -function _make_mkws_team($, teamName) { +function team($, teamName) { var that = {}; var m_teamName = teamName; var m_submitted = false; @@ -162,10 +162,11 @@ function _make_mkws_team($, teamName) { // if (console && console.log) // disabled, will fail in IE8 - // console.log("run _make_mkws_team(" + (teamName ? teamName : "") + ")"); + // console.log("run team(" + (teamName ? teamName : "") + ")"); - // Needs to be defined inside _make_mkws_team() so it can see m_debug_time + // Needs to be defined inside team() so it can see m_debug_time + // ### member access won't work: there is only one instance of this function mkws.debug_function = function (string) { if (!mkws.debug_level) return; @@ -230,7 +231,6 @@ function _make_mkws_team($, teamName) { "usesessions" : mkws_config.use_service_proxy ? false : true, "showResponseType": '', // or "json" (for debugging?) "onrecord": my_onrecord }); - that.m_paz = m_paz; // For access from non-member functions like mkws.showDetails if (!isNaN(parseInt(mkws_config.perpage_default))) { m_recPerPage = parseInt(mkws_config.perpage_default); @@ -271,7 +271,8 @@ function _make_mkws_team($, teamName) { renderSummary(hit), ''); if (hit.recid == m_curDetRecId) { - html.push(renderDetails(m_curDetRecData)); + if (m_curDetRecData) + html.push(renderDetails(m_curDetRecData)); } } results.html(html.join('')); @@ -356,7 +357,7 @@ function _make_mkws_team($, teamName) { } - function my_onrecord(data, teamName) { + function my_onrecord(data, args, teamName) { debug("record for " + teamName); // FIXME: record is async!! clearTimeout(m_paz.recordTimer); @@ -405,10 +406,11 @@ function _make_mkws_team($, teamName) { // wait until the DOM is ready function domReady () { - $('.mkwsSearchForm').each(function (i, obj) { + $('.mkwsSearchForm.mkwsTeam_' + m_teamName).each(function (i, obj) { + debug("adding search-forms for team '" + m_teamName + "'"); var node = this; - debug("adding class 'foo' to node " + node); mkws.handle_node_with_team(node, function(tname) { + debug("adding search-form '" + tname + "' for team '" + m_teamName + "'"); $(node).submit(onFormSubmitEventHandler); }); }); @@ -426,7 +428,11 @@ function _make_mkws_team($, teamName) { // when search button pressed function onFormSubmitEventHandler() { - that.newSearch(document.mkwsSearchForm.mkwsQuery.value); + mkws.handle_node_with_team(this, function (tname) { + var val = $('.mkwsQuery.mkwsTeam_' + tname).val(); + mkws.teams[tname].newSearch(val); + }); + return false; } @@ -730,7 +736,7 @@ function _make_mkws_team($, teamName) { // detailed record drawing - mkws.showDetails = function (prefixRecId, tname) { + that.showDetails = function (prefixRecId) { var recId = prefixRecId.replace('mkwsRec_', ''); var oldRecId = m_curDetRecId; m_curDetRecId = recId; @@ -748,9 +754,7 @@ function _make_mkws_team($, teamName) { return; } // request the record - var team = mkws.teams[tname]; - if (!team) alert("no team '" + tname + "'"); - team.m_paz.record(recId); + m_paz.record(recId); } @@ -1279,7 +1283,7 @@ function _mkws_jquery_plugin ($) { }; -// wrapper to call _make_mkws_team() after page load +// wrapper to call team() after page load (function (j) { function log(s) { if (typeof console === "undefined" || typeof console.log === "undefined") { /* ARGH!!! old IE */ @@ -1318,7 +1322,7 @@ function _mkws_jquery_plugin ($) { if (mkws.teams[tname]) { log("MKWS team '" + tname + "' already exists, skipping"); } else { - mkws.teams[tname] = _make_mkws_team(j, tname); + mkws.teams[tname] = team(j, tname); log("Made MKWS team '" + tname + "'"); } }); @@ -1351,6 +1355,11 @@ function _mkws_jquery_plugin ($) { } + mkws.showDetails = function (prefixRecId, tname) { + mkws.teams[tname].showDetails(prefixRecId); + } + + function default_mkws_config() { /* default mkws config */ var config_default = {