Move function mkwsSetLang() to the end of the team object, where it's used.
[mkws-moved-to-github.git] / src / mkws-team.js
index 81877bc..01d79b8 100644 (file)
@@ -314,13 +314,6 @@ function team($, teamName) {
             if (blanket) blanket.css('display', 'block');
             if (motd) motd.css('display', 'none');
             break;
-       case 'none':
-           alert("mkws.switchView(" + m_teamName + ", '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 + "'");
        }
@@ -348,32 +341,6 @@ function team($, teamName) {
     };
 
 
-    /*
-     * All the HTML stuff to render the search forms and
-     * result pages.
-     */
-    function mkwsHtmlAll() {
-        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;
-    }
-
-
     // Translation function. At present, this is properly a
     // global-level function (hence the assignment to mkws.M) but we
     // want to make it per-team so different teams can operate in
@@ -447,7 +414,7 @@ function team($, teamName) {
                 source = m_tempateText[name];
             }
            if (!source) {
-               source = defaultTemplate(name);
+               source = mkws.defaultTemplate(name);
            }
 
            template = Handlebars.compile(source);
@@ -460,94 +427,6 @@ function team($, teamName) {
     that.loadTemplate = loadTemplate;
 
 
-    function defaultTemplate(name) {
-       if (name === 'Record') {
-           return '\
-<table>\
-  <tr>\
-    <th>{{translate "Title"}}</th>\
-    <td>\
-      {{md-title}}\
-      {{#if md-title-remainder}}\
-       ({{md-title-remainder}})\
-      {{/if}}\
-      {{#if md-title-responsibility}}\
-       <i>{{md-title-responsibility}}</i>\
-      {{/if}}\
-    </td>\
-  </tr>\
-  {{#if md-date}}\
-  <tr>\
-    <th>{{translate "Date"}}</th>\
-    <td>{{md-date}}</td>\
-  </tr>\
-  {{/if}}\
-  {{#if md-author}}\
-  <tr>\
-    <th>{{translate "Author"}}</th>\
-    <td>{{md-author}}</td>\
-  </tr>\
-  {{/if}}\
-  {{#if md-electronic-url}}\
-  <tr>\
-    <th>{{translate "Links"}}</th>\
-    <td>\
-      {{#each md-electronic-url}}\
-       <a href="{{this}}">Link{{index1}}</a>\
-      {{/each}}\
-    </td>\
-  </tr>\
-  {{/if}}\
-  {{#if-any location having="md-subject"}}\
-  <tr>\
-    <th>{{translate "Subject"}}</th>\
-    <td>\
-      {{#first location having="md-subject"}}\
-       {{#if md-subject}}\
-         {{#commaList md-subject}}\
-           {{this}}{{/commaList}}\
-       {{/if}}\
-      {{/first}}\
-    </td>\
-  </tr>\
-  {{/if-any}}\
-  <tr>\
-    <th>{{translate "Locations"}}</th>\
-    <td>\
-      {{#commaList location}}\
-       {{attr "@name"}}{{/commaList}}\
-    </td>\
-  </tr>\
-</table>\
-';
-       } else if (name === "Summary") {
-           return '\
-<a href="#" id="{{_id}}" onclick="{{_onclick}}">\
-  <b>{{md-title}}</b>\
-</a>\
-{{#if md-title-remainder}}\
-  <span>{{md-title-remainder}}</span>\
-{{/if}}\
-{{#if md-title-responsibility}}\
-  <span><i>{{md-title-responsibility}}</i></span>\
-{{/if}}\
-';
-       } else if (name === "Image") {
-           return '\
-      <a href="#" id="{{_id}}" onclick="{{_onclick}}">\
-        {{#first md-thumburl}}\
-         <img src="{{this}}" alt="{{../md-title}}"/>\
-        {{/first}}\
-       <br/>\
-      </a>\
-';
-       }
-
-       var s = "There is no default '" + name +"' template!";
-       alert(s);
-       return s;
-    }
-
     that.addWidget = function(w) {
         if (!m_widgets[w.type]) {
             m_widgets[w.type] = w;
@@ -571,7 +450,20 @@ function team($, teamName) {
         return m_widgets[type];
     }
 
-    mkwsHtmlAll()
+
+    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;
+    }
+
+
     mkwsSetLang();
 
     return that;