m_sort = mkws_config.sort_default;
debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to m_sort");
+ // ### should be in global code
if (mkws_config.query_width < 5 || mkws_config.query_width > 150) {
debug("Reset query width: " + mkws_config.query_width);
mkws_config.query_width = 50;
}
+ // ### should be in global code
for (var key in mkws_config) {
if (mkws_config.hasOwnProperty(key)) {
if (key.match(/^language_/)) {
debug("show");
m_totalRec = data.merged;
+ // ### Here and elsewhere we should use a findnode() utility function
var pager = $(".mkwsPager.mkwsTeam_" + m_teamName);
if (pager.length) {
pager.html(drawPager(data))
// when search button pressed
+ // ### This is closure, so can always just operate on its own team
function onFormSubmitEventHandler()
{
mkws.handle_node_with_team(this, function (tname) {
}
+ // ### won't need to be externally visible once onFormSubmitEventHandler() is fixed.
+ // ### doesn't need windowid
that.newSearch = function(query, sort, targets, windowid)
{
debug("newSearch: " + query);
}
+ // ### doesn't need windowid
function triggerSearch (query, sort, targets, windowid)
{
var pp2filter = "";
* All the HTML stuff to render the search forms and
* result pages.
*/
+ // ### This and other multi-word identifiers should be camelCase
function mkws_html_all() {
mkws_set_lang();
if (mkws_config.show_lang)
mkws_html_lang();
debug("HTML search form");
- var node = $('.mkwsSearch.mkwsTeam_' + m_teamName);
- mkws.handle_node_with_team(node, function(tname) {
- node.html('\
+ mkws.handle_node_with_team($('.mkwsSearch.mkwsTeam_' + m_teamName),
+ function(tname) {
+ this.html('\
<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + tname + '" action="" >\
<input class="mkwsQuery mkwsTeam_' + tname + '" type="text" size="' + mkws_config.query_width + '" />\
<input class="mkwsButton mkwsTeam_' + tname + '" type="submit" value="' + M('Search') + '" />\
$(document).ready(function() { mkws.resize_page() });
}
- $('.mkwsSearchForm.mkwsTeam_' + m_teamName).each(function (i, obj) {
- debug("adding search-forms for team '" + m_teamName + "'");
- var node = this;
- mkws.handle_node_with_team(this, function(tname) {
- debug("adding search-form '" + tname + "' for team '" + m_teamName + "'");
- $(node).submit(onFormSubmitEventHandler);
- });
- });
-
+ var node;
+ node = $('.mkwsSearchForm.mkwsTeam_' + m_teamName);
+ if (node.length)
+ node.submit(onFormSubmitEventHandler);
node = $('.mkwsSort.mkwsTeam_' + m_teamName);
if (node.length)
node.change(onSelectDdChange);
// on first page, hide the termlist
$(document).ready(function() { $(".mkwsTermlists.mkwsTeam_" + m_teamName).hide(); });
var motd = $(".mkwsMOTD.mkwsTeam_" + m_teamName);
- var container = $(".mkwsMOTDContainer.mkwsTeam_" + m_teamName);
+ var container = $(".mkwsMOTDContainer.mkwsTeam_" + m_teamName);
if (motd.length && container.length) {
// Move the MOTD from the provided element down into the container
motd.appendTo(container);
// This function is taken from a StackOverflow answer
// http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144
+ // ### should we unify this and parseQuerystring()?
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
// elements that have the old magic IDs.
var ids = [ "Switch", "Lang", "Search", "Pager", "Navi",
"Results", "Records", "Targets", "Ranking",
- "Termlists", "Stat" ];
+ "Termlists", "Stat", "MOTD" ];
for (var i = 0; i < ids.length; i++) {
var id = 'mkws' + ids[i];
var node = $('#' + id);