pandora/static/js/entity.js

28 lines
901 B
JavaScript
Raw Normal View History

2014-11-19 16:04:45 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.entity = function(options, callback) {
2014-11-20 12:24:28 +00:00
// options: {id, view}
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)
? Ox._(parts[1] || 'unknown')
: Ox.isArray(value) ? value.join('; ')
: value;
});
callback(html);
2014-11-20 12:24:28 +00:00
}
);
});
2014-11-20 13:19:46 +00:00
};