X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=tools%2Fhtdocs%2Fmkws.js;h=fe29a5eff399d0e1925208279e4c1a215f1b6968;hb=a69a66b88e3317022c375792df0b1c3689431496;hp=abee7d26a73bc9dc95002d1e8ec4ef363b8b8a04;hpb=3707ef8981a7bb11586f4f35b4166aa41a29bb71;p=mkws-moved-to-github.git
diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js
index abee7d2..fe29a5e 100644
--- a/tools/htdocs/mkws.js
+++ b/tools/htdocs/mkws.js
@@ -226,17 +226,7 @@ function team($, teamName) {
debug("start running MKWS");
m_sort = mkws_config.sort_default;
- debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to m_sort");
-
- if (!isNaN(parseInt(mkws_config.perpage_default))) {
- m_perpage = parseInt(mkws_config.perpage_default);
- }
-
- // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp"
- if (mkws_config.pazpar2_url.match(/^\/\//)) {
- mkws_config.pazpar2_url = document.location.protocol + mkws_config.pazpar2_url;
- debug("adjust protocol independent links: " + mkws_config.pazpar2_url);
- }
+ m_perpage = mkws_config.perpage_default;
debug("Create main pz2 object");
// create a parameters array and pass it to the pz2's constructor
@@ -268,10 +258,8 @@ function team($, teamName) {
function onBytarget(data, teamName) {
debug("target");
- var targetDiv = findnode('.mkwsBytarget');
- if (!targetDiv) {
- return;
- }
+ var node = findnode('.mkwsBytarget');
+ if (node.length === 0) return;
var table ='
');
acc.push('
' + M(caption) + '
');
@@ -775,120 +753,6 @@ function team($, teamName) {
}
- function renderDetails(data, marker)
- {
- var template = loadTemplate("Record");
- var details = template(data);
- return '
' + details + '
';
- }
-
-
- function loadTemplate(name)
- {
- var template = m_template[name];
-
- if (template === undefined) {
- // Fall back to generic template if there is no team-specific one
- var node = findnode(".mkwsTemplate_" + name);
- if (!node.length) {
- node = findnode(".mkwsTemplate_" + name, "ALL");
- }
-
- var source = node.html();
- if (!source) {
- source = defaultTemplate(name);
- }
-
- template = Handlebars.compile(source);
- debug("compiled template '" + name + "'");
- m_template[name] = template;
- }
-
- return template;
- }
-
-
- function defaultTemplate(name)
- {
- if (name === 'Record') {
- return '\
-
\
- \
- {{translate "Title"}} | \
- \
- {{md-title}}\
- {{#if md-title-remainder}}\
- ({{md-title-remainder}})\
- {{/if}}\
- {{#if md-title-responsibility}}\
- {{md-title-responsibility}}\
- {{/if}}\
- | \
-
\
- {{#if md-date}}\
- \
- {{translate "Date"}} | \
- {{md-date}} | \
-
\
- {{/if}}\
- {{#if md-author}}\
- \
- {{translate "Author"}} | \
- {{md-author}} | \
-
\
- {{/if}}\
- {{#if md-electronic-url}}\
- \
- {{translate "Links"}} | \
- \
- {{#each md-electronic-url}}\
- Link{{index1}}\
- {{/each}}\
- | \
-
\
- {{/if}}\
- {{#if-any location having="md-subject"}}\
- \
- {{translate "Subject"}} | \
- \
- {{#first location having="md-subject"}}\
- {{#if md-subject}}\
- {{#commaList md-subject}}\
- {{this}}{{/commaList}}\
- {{/if}}\
- {{/first}}\
- | \
-
\
- {{/if-any}}\
- \
- {{translate "Locations"}} | \
- \
- {{#commaList location}}\
- {{attr "@name"}}{{/commaList}}\
- | \
-
\
-
\
-';
- } else if (name === "Summary") {
- return '\
-
\
- {{md-title}}\
-\
-{{#if md-title-remainder}}\
-
{{md-title-remainder}}\
-{{/if}}\
-{{#if md-title-responsibility}}\
-
{{md-title-responsibility}}\
-{{/if}}\
-';
- }
-
- var s = "There is no default '" + name +"' template!";
- alert(s);
- return s;
- }
-
-
/*
* All the HTML stuff to render the search forms and
* result pages.
@@ -978,19 +842,6 @@ function team($, teamName) {
}
- // implement $.parseQuerystring() for parsing URL parameters
- function parseQuerystring() {
- var nvpair = {};
- var qs = window.location.search.replace('?', '');
- var pairs = qs.split('&');
- $.each(pairs, function(i, v){
- var pair = v.split('=');
- nvpair[pair[0]] = pair[1];
- });
- return nvpair;
- }
-
-
function mkwsSetLang() {
var lang = parseQuerystring().lang || mkws_config.lang;
if (!lang || !mkws.locale_lang[lang]) {
@@ -1142,6 +993,19 @@ function team($, teamName) {
}
+ // implement $.parseQuerystring() for parsing URL parameters
+ function parseQuerystring() {
+ var nvpair = {};
+ var qs = window.location.search.replace('?', '');
+ var pairs = qs.split('&');
+ $.each(pairs, function(i, v){
+ var pair = v.split('=');
+ nvpair[pair[0]] = pair[1];
+ });
+ return nvpair;
+ }
+
+
// 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()?
@@ -1180,6 +1044,129 @@ function team($, teamName) {
}
+ function renderSummary(hit)
+ {
+ var template = loadTemplate("Summary");
+ hit._id = "mkwsRec_" + hit.recid;
+ hit._onclick = "mkws.showDetails('" + m_teamName + "', this.id);return false;"
+ return template(hit);
+ }
+
+
+ function renderDetails(data, marker)
+ {
+ var template = loadTemplate("Record");
+ var details = template(data);
+ return '
' + details + '
';
+ }
+
+
+ function loadTemplate(name)
+ {
+ var template = m_template[name];
+
+ if (template === undefined) {
+ // Fall back to generic template if there is no team-specific one
+ var node = findnode(".mkwsTemplate_" + name);
+ if (!node.length) {
+ node = findnode(".mkwsTemplate_" + name, "ALL");
+ }
+
+ var source = node.html();
+ if (!source) {
+ source = defaultTemplate(name);
+ }
+
+ template = Handlebars.compile(source);
+ debug("compiled template '" + name + "'");
+ m_template[name] = template;
+ }
+
+ return template;
+ }
+
+
+ function defaultTemplate(name)
+ {
+ if (name === 'Record') {
+ return '\
+
\
+ \
+ {{translate "Title"}} | \
+ \
+ {{md-title}}\
+ {{#if md-title-remainder}}\
+ ({{md-title-remainder}})\
+ {{/if}}\
+ {{#if md-title-responsibility}}\
+ {{md-title-responsibility}}\
+ {{/if}}\
+ | \
+
\
+ {{#if md-date}}\
+ \
+ {{translate "Date"}} | \
+ {{md-date}} | \
+
\
+ {{/if}}\
+ {{#if md-author}}\
+ \
+ {{translate "Author"}} | \
+ {{md-author}} | \
+
\
+ {{/if}}\
+ {{#if md-electronic-url}}\
+ \
+ {{translate "Links"}} | \
+ \
+ {{#each md-electronic-url}}\
+ Link{{index1}}\
+ {{/each}}\
+ | \
+
\
+ {{/if}}\
+ {{#if-any location having="md-subject"}}\
+ \
+ {{translate "Subject"}} | \
+ \
+ {{#first location having="md-subject"}}\
+ {{#if md-subject}}\
+ {{#commaList md-subject}}\
+ {{this}}{{/commaList}}\
+ {{/if}}\
+ {{/first}}\
+ | \
+
\
+ {{/if-any}}\
+ \
+ {{translate "Locations"}} | \
+ \
+ {{#commaList location}}\
+ {{attr "@name"}}{{/commaList}}\
+ | \
+
\
+
\
+';
+ } else if (name === "Summary") {
+ return '\
+
\
+ {{md-title}}\
+\
+{{#if md-title-remainder}}\
+
{{md-title-remainder}}\
+{{/if}}\
+{{#if md-title-responsibility}}\
+
{{md-title-responsibility}}\
+{{/if}}\
+';
+ }
+
+ var s = "There is no default '" + name +"' template!";
+ alert(s);
+ return s;
+ }
+
+
// main
(function() {
try {
@@ -1432,6 +1419,12 @@ function team($, teamName) {
$(document).ready(function() { mkws.resizePage() });
}
+ // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp"
+ if (mkws_config.pazpar2_url.match(/^\/\//)) {
+ mkws_config.pazpar2_url = document.location.protocol + mkws_config.pazpar2_url;
+ debug("adjust protocol independent links: " + mkws_config.pazpar2_url);
+ }
+
// Backwards compatibility: set new magic class names on any
// elements that have the old magic IDs.
var ids = [ "Switch", "Lang", "Search", "Pager", "Navi",