semantics_core.js
627 Bytes
// get position of an object from array with given id field value
function indexOfId(array, id) {
var i;
for (i = 0; i < array.length; i++) {
if (array[i].id == id) {
return i;
}
}
return -1;
}
function normalizeFormData(data) {
if ((typeof data) == 'string') {
return [data];
} else {
if ((typeof data) == 'undefined') {
return [];
} else {
return data;
}
}
}
function onlyUnique (value, index, self) {
return self.indexOf(value) === index;
}
function unique(list) {
return list.filter( onlyUnique );
}