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

« back to all changes in this revision

Viewing changes to www/media/groups/groups.js

  • Committer: dcoles
  • Date: 2008-08-09 08:05:13 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1001
Groups: Added the view half of the group admin panel. This lets people with the 
MANAGEGROUPS capibility to see all the project sets and groups in each subject 
offering for that subject. Next is to use the new userservice calls to add and 
modify these groups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * Date: 21/7/2008
21
21
 */
22
22
 
 
23
serviceapp = 'userservice';
 
24
 
 
25
function create(offeringid)
 
26
{
 
27
    /* TODO: Write this function */
 
28
}
 
29
 
 
30
/* Displays the selected group in the group adminsitration area
 
31
 */
 
32
function manage_subject()
 
33
{
 
34
    /* Get the subject id from the select box */
 
35
    var subject_select = document.getElementById("subject_select");
 
36
    var subject_div = document.getElementById("subject_div");
 
37
    var subjectid = parseInt(subject_select.value);
 
38
 
 
39
    /* List active offerings */
 
40
    dom_removechildren(subject_div);
 
41
    var p = dom_make_text_elem("h2", "Active Offerings");
 
42
    subject_div.appendChild(p);
 
43
    var callback = function(xhr) 
 
44
    {
 
45
        var offerings = JSON.parse(xhr.responseText);
 
46
        for (var i=0; i<offerings.length; i++)
 
47
        {
 
48
            var offering = offerings[i];
 
49
            var text = offering.subj_name + ", Semester " + offering.semester + " " + offering.year;
 
50
            var h3 = dom_make_text_elem("h3", text);
 
51
            subject_div.appendChild(h3);
 
52
            var div = document.createElement("div");
 
53
            subject_div.appendChild(div);
 
54
            manage_subject_offering(offering['offeringid'], div);
 
55
        }
 
56
    }
 
57
    ajax_call(callback, serviceapp, 'get_active_offerings', {'subjectid': subjectid}, 'GET');
 
58
}
 
59
 
 
60
/* Manages the display of a single offerings groups
 
61
 * Takes a offeringid and element to attach the results to
 
62
 */
 
63
function manage_subject_offering(offeringid, elem)
 
64
{
 
65
    var callback = function(xhr)
 
66
    {
 
67
        var projectsets = JSON.parse(xhr.responseText);
 
68
        for (var i=0; i<projectsets.length; i++)
 
69
        {
 
70
            var projectset = projectsets[i];
 
71
            var groups = projectset.groups;
 
72
            var dl = document.createElement("dl");
 
73
            dl.appendChild(dom_make_text_elem("dt", "Project Set "+(i+1)));
 
74
            var dd = document.createElement("dd");
 
75
            var ul = document.createElement("ul");
 
76
            dd.appendChild(ul);
 
77
            /* Add each group in the project set */
 
78
            for (var j=0; j<groups.length; j++)
 
79
            {
 
80
                var group = groups[j];
 
81
                ul.appendChild(dom_make_text_elem("li", group['groupnm']))
 
82
            }
 
83
            dl.appendChild(dd);
 
84
            elem.appendChild(dl);
 
85
        }
 
86
    }
 
87
    ajax_call(callback, serviceapp, 'get_project_groups', {'offeringid': offeringid}, 'GET')
 
88
}