MDL-21400 improved coding style
[moodle.git] / admin / report / spamcleaner / module.js
CommitLineData
9edea336 1M.report_spamcleaner = {
d825355a
PS
2 Y: null,
3 row: null,
4 me: null,
9edea336 5
d825355a 6 del_all: function() {
9edea336
PS
7 var yes = confirm(mstr.report_spamcleaner.spamdeleteallconfirm);
8 if (yes) {
d825355a
PS
9 var cfg = {
10 method: "POST",
11 on: {
12 success : function(id, o, args) {
13 try {
14 var resp = M.report_spamcleaner.Y.JSON.parse(o.responseText);
15 } catch(e) {
16 alert(mstr.report_spamcleaner.spaminvalidresult);
17 return;
18 }
19 if (resp == true) {
20 window.location.href=window.location.href;
21 }
22 }
23 }
24 }
25 M.report_spamcleaner.Y.io(M.report_spamcleaner.me+'?delall=yes&sesskey='+M.cfg.sesskey, cfg);
9edea336 26 }
d825355a
PS
27 },
28
29 del_user: function(obj, id) {
30 var yes = confirm(mstr.report_spamcleaner.spamdeleteconfirm);
31 if (yes) {
32 M.report_spamcleaner.row = obj;
33 var cfg = {
34 method: "POST",
35 on: {
36 success : function(id, o, args) {
37 try {
38 var resp = M.report_spamcleaner.Y.JSON.parse(o.responseText);
39 } catch(e) {
40 alert(mstr.report_spamcleaner.spaminvalidresult);
41 return;
42 }
43 if (M.report_spamcleaner.row) {
44 if (resp == true) {
45 while(M.report_spamcleaner.row.tagName != 'TR') {
46 M.report_spamcleaner.row = M.report_spamcleaner.row.parentNode;
47 }
48 M.report_spamcleaner.row.parentNode.removeChild(M.report_spamcleaner.row);
49 M.report_spamcleaner.row = null;
50 } else {
51 alert(mstr.report_spamcleaner.spamcannotdelete);
52 }
53 }
54 }
55 }
56 }
57 M.report_spamcleaner.Y.io(M.report_spamcleaner.me+'?del=yes&sesskey='+M.cfg.sesskey+'&id='+id, cfg);
58 }
59 },
9edea336 60
d825355a
PS
61 ignore_user: function(obj, id) {
62 M.report_spamcleaner.row = obj;
63 var cfg = {
64 method: "POST",
65 on: {
66 success : function(id, o, args) {
67 try {
68 var resp = M.report_spamcleaner.Y.JSON.parse(o.responseText);
69 } catch(e) {
70 alert(mstr.report_spamcleaner.spaminvalidresult);
71 return;
72 }
73 if (M.report_spamcleaner.row) {
74 if (resp == true){
75 while(M.report_spamcleaner.row.tagName != 'TR') {
76 M.report_spamcleaner.row = M.report_spamcleaner.row.parentNode;
77 }
78 M.report_spamcleaner.row.parentNode.removeChild(M.report_spamcleaner.row);
79 M.report_spamcleaner.row = null;
80 }
81 }
82 }
83 }
84 }
85 M.report_spamcleaner.Y.io(M.report_spamcleaner.me+'?ignore=yes&sesskey='+M.cfg.sesskey+'&id='+id, cfg);
86 },
9edea336
PS
87
88 init: function(Y, me) {
d825355a
PS
89 M.report_spamcleaner.Y = Y.use('json', 'io');
90 M.report_spamcleaner.me = me;
91 Y.on("click", M.report_spamcleaner.del_all, "#removeall_btn");
92 }
9edea336 93}