diff --git a/public/handlebars/statement.hbs b/public/handlebars/statement.hbs index 5f63838..60cc2b7 100644 --- a/public/handlebars/statement.hbs +++ b/public/handlebars/statement.hbs @@ -29,13 +29,6 @@

{{ data.prefLabel.[@value] }}

{{ data.definition.[@value] }}

-

{{i18n "notices" locale=language}}

- -

{{{i18n "Disclaimer" locale=language}}}

{{#parameters.date}}

{{i18n data.identifier . locale=language}}

{{/parameters.date}} @@ -43,6 +36,13 @@ {{#parameters.relatedURL}}

{{{i18n data.identifier . locale=language}}}

{{/parameters.relatedURL}} +

{{i18n "notices" locale=language}}

+ +

{{{i18n "Disclaimer" locale=language}}}

diff --git a/public/js/helpers.js b/public/js/helpers.js index e6d3998..99ea4ab 100644 --- a/public/js/helpers.js +++ b/public/js/helpers.js @@ -6,12 +6,78 @@ Handlebars.registerHelper('a', function (href, options) { return new Handlebars.SafeString("" + href + ""); }); -Handlebars.registerHelper('id', function(id, graph, options) { +Handlebars.registerHelper('resource', function(id, graph, options) { for (var i = 0; i < graph.length; i++) { - if (graph[i]['@id'].trim() == id.trim()) { + if (graph[i]['@id'] == id) { return options.fn(graph[i]); } } }); + +Handlebars.registerHelper('property', function(property, graph, options) { + + var sort = options.hash['sort'].split(" "); + var on_property = sort[0]; + var order = sort[1]; + + var graphs = []; + + for (var i = 0; i < property.length; i++) { + for (var j = 0; j < graph.length; j++) { + if (graph[j]['@id'] == property[i]) { + graphs.push(graph[j]); + } + } + } + + var ret = ""; + + graphs.sort(order == "asc" ? sort_property_asc(on_property) : sort_property_desc(on_property)); + + for (var k = 0; k < graphs.length; k++) { + ret = ret + options.fn(graphs[k]); + } + + return ret; + +}); + +Handlebars.registerHelper('sort', function(values, options) { + // weird Rhino behavior, explicitly create array + var vals = []; + for (var i = 0; i < values.length; i++) { + vals.push(values[i]); + } + vals.sort(options.hash['direction'] == "asc" ? sort_asc : sort_desc); + var ret = ""; + for (var i = 0; i < vals.length; i++) { + ret = ret + options.fn(vals[i]); + } + return ret; +}); + +function sort_property_asc(on_property) { + return function(a, b) { + return a[on_property]['@value'] == b[on_property]['@value'] + ? 0 : +(a[on_property]['@value'] > b[on_property]['@value']) || -1; + } +} + +function sort_property_desc(on_property) { + return function(a, b) { + return a[on_property]['@value'] == b[on_property]['@value'] + ? 0 : +(a[on_property]['@value'] < b[on_property]['@value']) || -1; + } +} + +function sort_asc(a, b) { + return a['@value'] == b['@value'] + ? 0 : +(a['@value'] > b['@value']) || -1; +} + +function sort_desc(a, b) { + return a['@value'] == b['@value'] + ? 0 : +(a['@value'] < b['@value']) || -1; +} diff --git a/public/rightsstatements.github.io b/public/rightsstatements.github.io index 23dd954..a13b11c 160000 --- a/public/rightsstatements.github.io +++ b/public/rightsstatements.github.io @@ -1 +1 @@ -Subproject commit 23dd954bc176bda3db42bcd70d605099b78c5cc0 +Subproject commit a13b11c1851a6cff23c758940a78084b298b882a