pandora/static/js/entity.js

26 lines
914 B
JavaScript
Raw Normal View History

2014-11-19 16:04:45 +00:00
'use strict';
2014-11-21 14:51:11 +00:00
pandora.entity = function(options, callback) {
2014-11-20 16:12:52 +00:00
// options: {id, view}, view: 'annotation' or 'entity'
2014-11-20 12:24:28 +00:00
pandora.api.getEntity({
id: options.id
2014-11-20 13:19:46 +00:00
}, function(response) {
2014-11-20 12:24:28 +00:00
Ox.get(
2014-11-20 13:19:46 +00:00
'/static/html/entities.' + response.data.type + '.' + options.view + '.html',
2014-11-20 12:24:28 +00:00
function(html) {
2014-11-19 16:04:45 +00:00
html = html.replace(/\{(.+?)\}/g, function() {
var parts = arguments[1].split('|'),
2014-11-20 13:19:46 +00:00
value = response.data[parts[0]];
2014-11-19 16:04:45 +00:00
return Ox.isEmpty(value)
|| Ox.isNull(value)
|| Ox.isUndefined(value)
2014-11-20 16:12:52 +00:00
? Ox._(parts[1] || '<span class="OxLight">unknown</a>')
2014-11-19 16:04:45 +00:00
: Ox.isArray(value) ? value.join('; ')
: value;
});
callback(html);
2014-11-20 12:24:28 +00:00
}
);
});
2014-11-20 13:19:46 +00:00
};