- /*
- * All the HTML stuff to render the search forms and
- * result pages.
- */
- function mkwsHtmlAll() {
- mkwsSetLang();
- if (m_config.show_lang)
- mkwsHtmlLang();
-
- log("HTML search form");
- findnode('.mkwsSearch').html('\
-<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + m_teamName + '" action="" >\
- <input class="mkwsQuery mkwsTeam_' + m_teamName + '" type="text" size="' + m_config.query_width + '" />\
- <input class="mkwsButton mkwsTeam_' + m_teamName + '" type="submit" value="' + M('Search') + '" />\
-</form>');
-
- log("HTML records");
- // If the team has a .mkwsResults, populate it in the usual
- // way. If not, assume that it's a smarter application that
- // defines its own subcomponents, some or all of the
- // following:
- // .mkwsTermlists
- // .mkwsRanking
- // .mkwsPager
- // .mkwsNavi
- // .mkwsRecords
- findnode(".mkwsResults").html('\
-<table width="100%" border="0" cellpadding="6" cellspacing="0">\
- <tr>\
- <td class="mkwsTermlistContainer1 mkwsTeam_' + m_teamName + '" width="250" valign="top">\
- <div class="mkwsTermlists mkwsTeam_' + m_teamName + '"></div>\
- </td>\
- <td class="mkwsMOTDContainer mkwsTeam_' + m_teamName + '" valign="top">\
- <div class="mkwsRanking mkwsTeam_' + m_teamName + '"></div>\
- <div class="mkwsPager mkwsTeam_' + m_teamName + '"></div>\
- <div class="mkwsNavi mkwsTeam_' + m_teamName + '"></div>\
- <div class="mkwsRecords mkwsTeam_' + m_teamName + '"></div>\
- </td>\
- </tr>\
- <tr>\
- <td colspan="2">\
- <div class="mkwsTermlistContainer2 mkwsTeam_' + m_teamName + '"></div>\
- </td>\
- </tr>\
-</table>');
-
- var acc = [];
- var facets = m_config.facets;
- acc.push('<div class="title">' + M('Termlists') + '</div>');
- for (var i = 0; i < facets.length; i++) {
- acc.push('<div class="mkwsFacet mkwsTeam_' + m_teamName + '" data-mkws-facet="' + facets[i] + '">');
- acc.push('</div>');
- }
- findnode(".mkwsTermlists").html(acc.join(''));
-
- var ranking_data = '<form name="mkwsSelect" class="mkwsSelect mkwsTeam_' + m_teamName + '" action="" >';
- if (m_config.show_sort) {
- ranking_data += M('Sort by') + ' ' + mkwsHtmlSort() + ' ';
- }
- if (m_config.show_perpage) {
- ranking_data += M('and show') + ' ' + mkwsHtmlPerpage() + ' ' + M('per page') + '.';
- }
- ranking_data += '</form>';
- findnode(".mkwsRanking").html(ranking_data);
-
- mkwsHtmlSwitch();
-
- findnode('.mkwsSearchForm').submit(function() {
- var val = findnode('.mkwsQuery').val();
- newSearch(val);
- return false;
- });
-
- // on first page, hide the termlist
- $(document).ready(function() { findnode(".mkwsTermlists").hide(); });
- var container = findnode(".mkwsMOTDContainer");
- if (container.length) {
- // Move the MOTD from the provided element down into the container
- findnode(".mkwsMOTD").appendTo(container);
- }
- }
-
-
- function mkwsSetLang() {
- var lang = mkws.getParameterByName("lang") || m_config.lang;
- if (!lang || !mkws.locale_lang[lang]) {
- m_config.lang = ""
- } else {
- m_config.lang = lang;
- }
-
- log("Locale language: " + (m_config.lang ? m_config.lang : "none"));
- return m_config.lang;
- }
-
-
- /* create locale language menu */
- function mkwsHtmlLang() {
- var lang_default = "en";
- var lang = m_config.lang || lang_default;
- var list = [];
-
- /* display a list of configured languages, or all */
- var lang_options = m_config.lang_options || [];
- var toBeIncluded = {};
- for (var i = 0; i < lang_options.length; i++) {
- toBeIncluded[lang_options[i]] = true;
- }
-
- for (var k in mkws.locale_lang) {
- if (toBeIncluded[k] || lang_options.length == 0)
- list.push(k);
- }
-
- // add english link
- if (lang_options.length == 0 || toBeIncluded[lang_default])
- list.push(lang_default);
-
- log("Language menu for: " + list.join(", "));
-
- /* the HTML part */
- var data = "";
- for(var i = 0; i < list.length; i++) {
- var l = list[i];
-
- if (data)
- data += ' | ';
-
- if (lang == l) {
- data += ' <span>' + l + '</span> ';
- } else {
- data += ' <a href="?lang=' + l + '">' + l + '</a> '
- }
- }
-
- findnode(".mkwsLang").html(data);
- }
-
-
- function mkwsHtmlSort() {
- log("HTML sort, m_sortOrder = '" + m_sortOrder + "'");
- var sort_html = '<select class="mkwsSort mkwsTeam_' + m_teamName + '">';
-
- for(var i = 0; i < m_config.sort_options.length; i++) {
- var opt = m_config.sort_options[i];
- var key = opt[0];
- var val = opt.length == 1 ? opt[0] : opt[1];
-
- sort_html += '<option value="' + key + '"';
- if (m_sortOrder == key || m_sortOrder == val) {
- sort_html += ' selected="selected"';
- }
- sort_html += '>' + M(val) + '</option>';
- }
- sort_html += '</select>';
-
- return sort_html;
- }
-
-
- function mkwsHtmlPerpage() {
- log("HTML perpage, m_perpage = " + m_perpage);
- var perpage_html = '<select class="mkwsPerpage mkwsTeam_' + m_teamName + '">';
-
- for(var i = 0; i < m_config.perpage_options.length; i++) {
- var key = m_config.perpage_options[i];
-
- perpage_html += '<option value="' + key + '"';
- if (key == m_perpage) {
- perpage_html += ' selected="selected"';
- }
- perpage_html += '>' + key + '</option>';
- }
- perpage_html += '</select>';
-
- return perpage_html;
- }
-
-
- function mkwsHtmlSwitch() {
- log("HTML switch for team " + m_teamName);
-
- var node = findnode(".mkwsSwitch");
- node.append($('<a href="#" onclick="mkws.switchView(\'' + m_teamName + '\', \'records\')">' + M('Records') + '</a>'));
- node.append($("<span/>", { text: " | " }));
- node.append($('<a href="#" onclick="mkws.switchView(\'' + m_teamName + '\', \'targets\')">' + M('Targets') + '</a>'));
-
- log("HTML targets");
- var node = findnode(".mkwsTargets");
- node.html('\
-<div class="mkwsBytarget mkwsTeam_' + m_teamName + '">\
- No information available yet.\
-</div>');
- node.css("display", "none");
- }
-
-