X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=1de551488d57892072918db614b77ca87798798c;hb=e68bce23c27148f21675012108dc7a4ae16c8d26;hp=97c48678889c64273d70f1c24c83d18614d6e385;hpb=16c87b6939256145c562243680fbd855db904ac5;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 97c4867..1de5514 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -166,6 +166,7 @@ function team($, teamName) { // 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 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('')); @@ -371,7 +373,7 @@ function team($, teamName) { function my_onbytarget(data, teamName) { debug("target for " + teamName); - var targetDiv = document.getElementById("mkwsBytarget"); + var targetDiv = $('.mkwsBytarget.mkwsTeam_' + teamName); if (!targetDiv) { // No mkwsTargets div. return; @@ -394,7 +396,7 @@ function team($, teamName) { } table += ''; - targetDiv.innerHTML = table; + targetDiv.html(table); } //////////////////////////////////////////////////////////////////////////////// @@ -404,10 +406,11 @@ function 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 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 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 + "'"); @@ -977,18 +985,20 @@ function team($, teamName) { function mkws_html_switch() { - debug("HTML switch"); + debug("HTML switch for team " + m_teamName); - $("#mkwsSwitch").append($('' + M('Records') + '')); - $("#mkwsSwitch").append($("", { text: " | " })); - $("#mkwsSwitch").append($('' + M('Targets') + '')); + var node = $(".mkwsSwitch.mkwsTeam_" + m_teamName); + node.append($('' + M('Records') + '')); + node.append($("", { text: " | " })); + node.append($('' + M('Targets') + '')); debug("HTML targets"); - $("#mkwsTargets").html('\ -
\ + var node = $(".mkwsTargets.mkwsTeam_" + m_teamName); + node.html('\ +
\ No information available yet.\
'); - $("#mkwsTargets").css("display", "none"); + node.css("display", "none"); } @@ -1088,7 +1098,7 @@ function team($, teamName) { $("#mkwsTermlistContainer1").hide(); $("#mkwsTermlistContainer2").show(); for(var i = 0; i < list.length; i++) { - $("#" + list[i]).hide(); + $("#" + list[i]).hide(); // ### make team-aware } } else if ($(window).width() > width && parentId === "mkwsTermlistContainer2") { @@ -1097,7 +1107,7 @@ function team($, teamName) { $("#mkwsTermlistContainer1").show(); $("#mkwsTermlistContainer2").hide(); for(var i = 0; i < list.length; i++) { - $("#" + list[i]).show(); + $("#" + list[i]).show(); // ### make team-aware } } }; @@ -1301,11 +1311,20 @@ function _mkws_jquery_plugin ($) { var id = 'mkws' + ids[i]; var node = $('#' + id); if (node.attr('id')) { - node.addClass(id + " mkwsTeam_AUTO"); - log("added magic classes to '" + node.attr('id') + "'"); + node.addClass(id); + log("added magic class to '" + node.attr('id') + "'"); } } + // For all MKWS-classed nodes that don't have a team + // specified, set the team to AUTO. + $('div[class^="mkws"],div[class*=" mkws"]').each(function () { + if (!this.className.match(/mkwsTeam_/)) { + log("adding AUTO team to node with class '" + this.className + "'"); + $(this).addClass('mkwsTeam_AUTO'); + } + }); + // Find all nodes with class (NOT id) mkwsRecords, and // determine their team from the mkwsTeam_* class. So: //
@@ -1342,8 +1361,6 @@ function _mkws_jquery_plugin ($) { tname = cname.replace(/^mkwsTeam_/, ''); } } - if (!tname) - tname = "AUTO"; callback(tname); }