"MDL-19118, comments api"
[moodle.git] / comment / admin.js
1 YAHOO.util.Event.onDOMReady(init); 
2 function init() {
3     var select_all = document.getElementById('comment_select_all');
4     select_all.onclick = function() {
5         var comments = document.getElementsByName('comments');
6         var checked = false;
7         for (var i in comments) {
8             if (comments[i].checked) {
9                 checked=true;
10             }
11         }
12         for (var i in comments) {
13             comments[i].checked = !checked;
14         }
15         this.checked = !checked;
16     }
17     var comments_delete = document.getElementById('comments_delete');
18     comments_delete.onclick = function() {
19         delete_comments();
20     }
21 }
22 function delete_comments() {
23     var url = moodle_cfg.wwwroot + '/comment/index.php';
24     var cb = {
25         success:function(o) {
26             if (o.responseText == 'yes') {
27                 location.reload();
28             }
29         }
30     }
31     var comments = document.getElementsByName('comments');
32     var list = '';
33     for (var i in comments) {
34         if (comments[i].checked) {
35             list += (comments[i].value + '-');
36         }
37     }
38     var data = {
39         'commentids': list,
40         'sesskey': moodle_cfg.sesskey 
41     }
42     var trans = YAHOO.util.Connect.asyncRequest('POST',
43         url+'?action=delete', cb, build_querystring(data));
44 }