move the default config values for "mkws" into the function()
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index 7a767f4..9b09508 100644 (file)
@@ -2,12 +2,8 @@
 
 "use strict"; // HTML5: disable for debug_level >= 2
 
-// Set up namespace and some state.
-var mkws = {
-    sort: 'relevance',
-    authenticated: false,
-    filters: []
-};
+// Set up global mkws object
+var mkws = {};
 
 // Define empty mkws_config for simple applications that don't define it.
 if (mkws_config == null || typeof mkws_config != 'object') {
@@ -21,6 +17,10 @@ function _mkws($) {
     // call this function only once
     if (mkws.init) return;
 
+mkws.sort = 'relevance';
+mkws.authenticated = false;
+mkws.filters = [];
+
 mkws.locale_lang = {
     "de": {
        "Authors": "Autoren",
@@ -207,6 +207,7 @@ Handlebars.registerHelper('commaList', function(items, options) {
     }
 }
 
+
 mkws.sort = mkws_config.sort_default;
 debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to mkws.sort");
 
@@ -257,6 +258,10 @@ var SourceMax = 16;
 var SubjectMax = 10;
 var AuthorMax = 10;
 
+if (!isNaN(parseInt(mkws_config.perpage_default))) {
+    recPerPage = parseInt(mkws_config.perpage_default);
+}
+
 //
 // pz2.js event handlers:
 //
@@ -788,7 +793,7 @@ function defaultTemplate(name)
        return '\
       <table>\
        <tr>\
-         <th>Title</th>\
+         <th>{{translate "Title"}}</th>\
          <td>\
            {{md-title}}\
            {{#if md-title-remainder}}\
@@ -801,19 +806,19 @@ function defaultTemplate(name)
        </tr>\
        {{#if md-date}}\
        <tr>\
-         <th>Date</th>\
+         <th>{{translate "Date"}}</th>\
          <td>{{md-date}}</td>\
        </tr>\
        {{/if}}\
        {{#if md-author}}\
        <tr>\
-         <th>Author</th>\
+         <th>{{translate "Author"}}</th>\
          <td>{{md-author}}</td>\
        </tr>\
        {{/if}}\
        {{#if md-electronic-url}}\
        <tr>\
-         <th>URL</th>\
+         <th>{{translate "URL"}}</th>\
          <td>\
            {{#each md-electronic-url}}\
              <a href="{{this}}">{{this}}</a><br/>\
@@ -823,7 +828,7 @@ function defaultTemplate(name)
        {{/if}}\
        {{#if-any location having="md-subject"}}\
        <tr>\
-         <th>Subject</th>\
+         <th>{{translate "Subject"}}</th>\
          <td>\
            {{#first location having="md-subject"}}\
              {{#if md-subject}}\
@@ -834,7 +839,7 @@ function defaultTemplate(name)
        </tr>\
        {{/if-any}}\
        <tr>\
-         <th>Locations</th>\
+         <th>{{translate "Locations"}}</th>\
          <td>\
            {{#commaList location}}\
              {{attr "@name"}}{{/commaList}}\