summaryrefslogtreecommitdiffstats
path: root/htdocs/js/bundle.js
blob: dc4fb9c5958da97b3d1dbfcfba6dee694d624944 (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
function parse_patch_id(id_str)
{
    var i;

    i = id_str.indexOf(':');
    if (i == -1)
        return null;

    return id_str.substring(i + 1);
}

function bundle_handle_drop(table, row)
{
    var relative, relation, current;
    var relative_id, current_id;

    current = $(row);
    relative = $(current).prev();
    relation = 'after';

    /* if we have no previous row, position ourselves before the next
     * row instead */
    if (!relative.length) {
        relative = current.next();
        relation = 'before';

        if (!relative)
            return;
    }

    current_id = parse_patch_id(current.attr('id'));
    relative_id = parse_patch_id(relative.attr('id'));

    alert("put patch " + current_id + " " + relation + " " + relative_id);
}

$(document).ready(function() {
    $("#patchlist").tableDnD({
        onDrop: bundle_handle_drop
    });
});