~azzar1/unity/add-show-desktop-key

1099.4.2 by Nick Chadwick
Working on the template for worksheet_admin, to make it able to
1
/* IVLE - Informatics Virtual Learning Environment
2
 * Copyright (C) 2007-2009 The University of Melbourne
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 2 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
 *
18
 * Author: Nick Chadwick
19
 */
20
21
/* Called when a form upload comes back (from an iframe).
22
 * Refreshes the page.
23
 */
1099.1.197 by Nick Chadwick
Modified worksheets edit view, so now there are links to edit, add,
24
 
25
//XXX: Make this actually move the element, not just reload the page
26
function move_up(worksheet)
27
{
1548 by William Grant
Unbreak worksheet reordering.
28
    var ws_row = document.getElementById("worksheet_row_" + worksheet);
1099.1.197 by Nick Chadwick
Modified worksheets edit view, so now there are links to edit, add,
29
    var ws_row_index = ws_row.rowIndex;
30
    
31
    if (ws_row_index == 1) {
32
        alert('Item already at top of list.');
33
        return;
34
    }
35
    
36
    var callback = function(xhr)
37
    {
38
        var testresponse;
39
        try
40
        {
41
            testresponse = JSON.parse(xhr.responseText);
42
            window.location.reload();
43
        }
44
        catch(ex)
45
        {
46
            alert('There was an error updating the worksheets list.');
47
            return;
48
        }
49
    }
50
    
51
    update_path = "api/subjects/" + subject + "/" + year + "/" + 
52
                   semester + "/+worksheets";
53
    var args = {'ivle.op': 'move_up', 'worksheetid': worksheet}
54
    
55
    ajax_call(callback, update_path, "", args, 'POST');
56
}
57
58
//XXX: Make this actually move the element, not just reload the page
59
function move_down(worksheet)
60
{
61
    var ws_table = document.getElementById('worksheets_table');
1548 by William Grant
Unbreak worksheet reordering.
62
    var ws_row = document.getElementById("worksheet_row_" + worksheet);
1099.1.197 by Nick Chadwick
Modified worksheets edit view, so now there are links to edit, add,
63
    var ws_row_index = ws_row.rowIndex;
64
    
1099.1.212 by Nick Chadwick
Added a new page to display exercises. This will then be modified to
65
    if (ws_row_index == (ws_table.rows.length - 1)) {
1099.1.197 by Nick Chadwick
Modified worksheets edit view, so now there are links to edit, add,
66
        alert('Item already at bottom of list.');
67
        return;
68
    }
69
    
70
    var callback = function(xhr)
71
    {
72
        var testresponse;
73
        try
74
        {
75
            testresponse = JSON.parse(xhr.responseText);
76
            window.location.reload();
77
        }
78
        catch(ex)
79
        {
80
            alert('There was an error updating the worksheets list.');
81
            return;
82
        }
83
    }
84
    
85
    update_path = "api/subjects/" + subject + "/" + year + "/" + 
86
                   semester + "/+worksheets";
87
    var args = {'ivle.op': 'move_down', 'worksheetid': worksheet}
88
    
89
    ajax_call(callback, update_path, "", args, 'POST');
90
}
1099.4.2 by Nick Chadwick
Working on the template for worksheet_admin, to make it able to
91