-
Notifications
You must be signed in to change notification settings - Fork 9
/
entity.js
31 lines (26 loc) · 775 Bytes
/
entity.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* A simple database of all entities */
var entities;
var internalIDCounter;
function resetEntities() {
entities = [];
internalIDCounter = 0;
}
resetEntities();
function Entity(initialVals) {
this["/rec_ui/id"] = internalIDCounter++
entities[this["/rec_ui/id"]] = this;
for (var key in initialVals)
this[key] = initialVals[key];
}
Entity.prototype.getChainedProperty = function(prop) {
return getChainedProperty(this,prop);
}
Entity.prototype.freebaseLink = function(linkText) {
linkText = linkText || this.name || this.id;
return freebase.link(linkText,this.id);
}
Entity.prototype.displayValue = function() {
if (!this.id)
return displayValue(this['/type/object/name'] || this.id);
return this.freebaseLink();
};