summaryrefslogtreecommitdiff
path: root/web/viewsjs/search.js.erb
blob: 8c2efcc30dccc1eaa3263bd206748dcf3f199479 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var create_flexigrid_for = {
    search: {
        keys: function(query) {
            create_flexigrid('grid-keys', {
                url: '/api/2/db/keys?query=' + encodeURIComponent(query),
                colModel: [
                    { display: texts.misc.count, name: 'count_all', width: 80, sortable: true, align: 'right' },
                    { display: texts.osm.key, name: 'key', width: 500, sortable: true }
                ],
                sortname: 'count_all',
                sortorder: 'desc',
                emptymsg: 'No keys found.',
                preProcess: function(data) {
                    data.rows = jQuery.map(data.data, function(row, i) {
                        return { 'cell': [
                            print_with_ts(row.count_all),
                            link_to_key_with_highlight(row.key, query)
                        ] };
                    });
                    return data;
                }
            });
        },
        values: function(query) {
            create_flexigrid('grid-values', {
                url: '/api/2/search/values?q=' + encodeURIComponent(query),
                colModel: [
                    { display: texts.misc.count, name: 'count_all', width: 80, sortable: true, align: 'right' },
                    { display: texts.osm.key, name: 'key', width: 250, sortable: true },
                    { display: texts.osm.value, name: 'value', width: 500, sortable: true }
                ],
                sortname: 'count_all',
                sortorder: 'desc',
                emptymsg: 'No values found.',
                preProcess: function(data) {
                    data.rows = jQuery.map(data.data, function(row, i) {
                        return { 'cell': [
                            print_with_ts(row.count_all),
                            link_to_key(row.key),
                            link_to_value_with_highlight(row.key, row.value, query)
                        ] };
                    });
                    return data;
                }
            });
        },
        tags: function(query) {
            var q = query.split('=', 2);
            create_flexigrid('grid-tags', {
                url: '/api/2/search/tags?q=' + encodeURIComponent(query),
                colModel: [
                    { display: texts.misc.count, name: 'count_all', width: 80, sortable: true, align: 'right' },
                    { display: texts.osm.key, name: 'key', width: 300, sortable: true },
                    { display: texts.osm.value, name: 'value', width: 500, sortable: true }
                ],
                sortname: 'count_all',
                sortorder: 'desc',
                emptymsg: 'No tags found.',
                preProcess: function(data) {
                    data.rows = jQuery.map(data.data, function(row, i) {
                        return { 'cell': [
                            print_with_ts(row.count_all),
                            link_to_key_with_highlight(row.key, q[0]),
                            link_to_value_with_highlight(row.key, row.value, q[1])
                        ] };
                    });
                    return data;
                }
            });
        }
    }
};

function page_init() {
    page_init2();
}