Blame view

semantics/static/js/semantics_core.js 627 Bytes
Bartłomiej Nitoń authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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;
        }
    }
}
Tomasz Bartosiak authored
23
24
25
26
27
28
29
30

function onlyUnique (value, index, self) {
    return self.indexOf(value) === index;
}

function unique(list) {
    return list.filter( onlyUnique );
}