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

« back to all changes in this revision

Viewing changes to ivle/webapp/groups/media/groups.js

  • Committer: David Coles
  • Date: 2010-08-30 03:26:13 UTC
  • Revision ID: coles.david@gmail.com-20100830032613-d14vng0jkelniu3l
python-console: Fix globals broken with new JSON library.

simplejson always returns unicode strings. cJSON would return ordinary strings 
if possible. cPickle.loads() only accepts strings. At present we use pickle 
version 0 so they should all works as ASCII strings. Higher versions of pickle 
are not plain ASCII and are likely to break this and so this should be fixed 
at some point.

Also replaced unconditional exception with one that catches Pickle errors. Not 
sure the best way to report failures of these functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
/* Creates a group */
26
26
function create_new_group(projectsetid)
27
27
{
28
 
    groupnm = window.prompt('Please enter a name for the group');
29
 
    args = {'projectsetid': projectsetid, 'groupnm':groupnm, 'nick': groupnm};
30
 
    response = ajax_call(null, serviceapp, 'create_group', args, 'POST');
31
 
    if (response.status == 200)
32
 
    {
33
 
        /* pass */
34
 
    }
35
 
    else
36
 
    {
37
 
        alert("Error: Could not add group. Does it already exist?");
38
 
    }
39
 
    /* Reload the display */
40
 
    window.location.href = window.location.href;
 
28
    groupnm = window.prompt('Please enter a name for the group','');
 
29
 
 
30
    /* If the provided name is empty, or the prompt is cancelled, stop. */
 
31
    if (groupnm)
 
32
    {
 
33
        args = {
 
34
            'projectsetid': projectsetid,
 
35
            'groupnm':groupnm,
 
36
            'nick': groupnm
 
37
        };
 
38
        response = ajax_call(null, serviceapp, 'create_group', args, 'POST');
 
39
        if (response.status == 200)
 
40
        {
 
41
            /* pass */
 
42
        }
 
43
        else if (response.status == 400)
 
44
        {
 
45
            alert("Could not create group: " + response.getResponseHeader('X-IVLE-Error'));
 
46
        }
 
47
        else
 
48
        {
 
49
            alert("Error: Could not add group. Does it already exist?");
 
50
        }
 
51
        /* Reload the display */
 
52
        window.location.href = window.location.href;
 
53
    }
41
54
}
42
55
 
43
56
function manage_group(offeringid, groupid, namespace)
44
57
{
45
 
    var elem = document.getElementById(namespace);
46
58
    var button = document.getElementById(namespace+"_button");
47
59
    var manage_div = document.createElement("div")
48
60
    manage_div.id = namespace + "_contents";
49
 
    elem.insertBefore(manage_div, button);
50
 
    
 
61
 
 
62
    /* Get the td which is button's parent (the 'actions' column) */
 
63
    button_td = button.parentNode;
 
64
    button_td.appendChild(manage_div);
 
65
 
51
66
    /* Refresh contents */
52
67
    list_projectgroup_contents(offeringid, groupid, manage_div.id);
53
68
 
54
69
    /* Remove the button element */
55
 
    elem.removeChild(button);
 
70
    button_td.removeChild(button);
56
71
}
57
72
 
58
73
/* Lists the information about a particular project group identified by groupid 
76
91
            var member = groupmembers[i];
77
92
 
78
93
            var li = dom_make_text_elem("li", member.fullname + " (" +
79
 
                                              member.login + ")");
 
94
                                              member.login + ") ");
80
95
            var rmbutton = document.createElement("input");
81
96
            rmbutton.value = "Remove";
82
97
            rmbutton.type = "image";
83
98
            /* XXX: There must be a better way to do this! */
84
 
            rmbutton.src = "/+media/ivle.webapp.groups/cross.png";
 
99
            rmbutton.src = "/+media/ivle.webapp.core/images/interface/delete.png";
85
100
 
86
101
            $(rmbutton).click(function(offeringid, login, groupid, elemnm)
87
102
            {