X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=56d3522df6519d332ea495dfe7fe0fb18cce646e;hb=59042a289588b636ea5c80a1ec4c871415a4fe72;hp=b5dc51d1b35efc3befb7da2ea8759630f0cbb414;hpb=e1910c1453642bea8ffad32e3e1a4e52f1ecf8eb;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index b5dc51d..56d3522 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; @@ -270,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('')); @@ -281,7 +283,7 @@ function _make_mkws_team($, teamName) { { var template = loadTemplate("Summary"); hit._id = "mkwsRec_" + hit.recid; - hit._onclick = "mkws.showDetails(this.id);return false;" + hit._onclick = "mkws.showDetails(this.id, '" + m_teamName + "');return false;" return template(hit); } @@ -355,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); @@ -404,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); }); }); @@ -425,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; } @@ -697,30 +704,31 @@ function _make_mkws_team($, teamName) { mkws.switchView = function(view) { debug("switchView: " + view); - var targets = document.getElementById('mkwsTargets'); - var results = document.getElementById('mkwsResults') || - document.getElementById('mkwsRecords'); - var blanket = document.getElementById('mkwsBlanket'); - var motd = document.getElementById('mkwsMOTD'); + //var targets = document.getElementById('mkwsTargets'); + var targets = $('#mkwsTargets'); + var results = $('#mkwsResults,#mkwsRecords'); + var blanket = $('#mkwsBlanket'); + var motd = $('#mkwsMOTD'); switch(view) { case 'targets': - if (targets) targets.style.display = "block"; - if (results) results.style.display = "none"; - if (blanket) blanket.style.display = "none"; - if (motd) motd.style.display = "none"; + if (targets) targets.css('display', 'block'); + if (results) results.css('display', 'none'); + if (blanket) blanket.css('display', 'none'); + if (motd) motd.css('display', 'none'); break; case 'records': - if (targets) targets.style.display = "none"; - if (results) results.style.display = "block"; - if (blanket) blanket.style.display = "block"; - if (motd) motd.style.display = "none"; + if (targets) targets.css('display', 'none'); + if (results) results.css('display', 'block'); + if (blanket) blanket.css('display', 'block'); + if (motd) motd.css('display', 'none'); break; case 'none': - if (targets) targets.style.display = "none"; - if (results) results.style.display = "none"; - if (blanket) blanket.style.display = "none"; - if (motd) motd.style.display = "none"; + alert("mkws.switchView('none') shouldn't happen"); + if (targets) targets.css('display', 'none'); + if (results) results.css('display', 'none'); + if (blanket) blanket.css('display', 'none'); + if (motd) motd.css('display', 'none'); break; default: alert("Unknown view '" + view + "'"); @@ -729,7 +737,7 @@ function _make_mkws_team($, teamName) { // detailed record drawing - mkws.showDetails = function (prefixRecId) { + that.showDetails = function (prefixRecId) { var recId = prefixRecId.replace('mkwsRec_', ''); var oldRecId = m_curDetRecId; m_curDetRecId = recId; @@ -1276,7 +1284,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 */ @@ -1315,7 +1323,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 + "'"); } }); @@ -1348,6 +1356,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 = {