1 function junk_keyword_message_set(junk_uids
, nonjunk_uids
) {
3 for (i
=0; i
<junk_uids
.length
; i
++) {
4 var uid
= junk_uids
[i
];
5 var message
= rcmail
.env
.messages
[uid
];
6 var row
= rcmail
.message_list
.rows
[uid
];
7 var rowobj
= $(row
.junk_icon
);
8 if (!rowobj
.hasClass('junk')) {
9 rowobj
.addClass('junk');
10 message
.flags
.junk
= true;
12 rcmail
.set_message(uid
, 'unread', false);
13 rcmail
.update_thread_root(uid
, 'read');
14 if (rcmail
.env
.unread_counts
[rcmail
.env
.mailbox
]) {
15 rcmail
.env
.unread_counts
[rcmail
.env
.mailbox
] -= 1;
16 rcmail
.set_unread_count(rcmail
.env
.mailbox
17 , rcmail
.env
.unread_counts
[rcmail
.env
.mailbox
]
18 , rcmail
.env
.mailbox
== 'INBOX');
20 if (rcmail
.env
.preview_pane_mark_read
> 0)
21 rcmail
.http_post('mark', '_uid='+id
+'&_flag=read&_quiet=1');
23 for (i
=0; i
<nonjunk_uids
.length
; i
++) {
24 var uid
= nonjunk_uids
[i
];
25 var message
= rcmail
.env
.messages
[uid
];
26 var row
= rcmail
.message_list
.rows
[uid
];
27 var rowobj
= $(row
.junk_icon
);
28 if (rowobj
.hasClass('junk')) {
29 rowobj
.removeClass('junk');
30 message
.flags
.junk
= false;
33 var lock
= rcmail
.set_busy(true, 'loading');
34 var str_junk_uids
= junk_uids
.join(',');
35 var str_nonjunk_uids
= nonjunk_uids
.join(',');
36 rcmail
.http_request('plugin.junk_keyword.set_keywords'
37 , '&_junk_uids=' + str_junk_uids
38 + '&_nonjunk_uids=' + str_nonjunk_uids
39 + '&_mbox=' + urlencode(rcmail
.env
.mailbox
)
40 //+ '&_search='+ (this.env.search_request ? this.env.search_request : '')
43 function junk_keyword_message_toggle(uid
) {
44 var uids
= [], junk_uids
= [], nonjunk_uids
= []
46 , list
= rcmail
.message_list
;
50 else if (rcmail
.env
.uid
)
51 uids
[0] = rcmail
.env
.uid
;
53 uids
= list
.get_selection();
56 for (i
=0; i
<uids
.length
; i
++) {
58 if (list
.rows
[id
].flags
.junk
)
59 nonjunk_uids
.push(id
);
63 junk_keyword_message_set(junk_uids
, nonjunk_uids
);
65 function junk_keyword_icon_toggle(props
) {
66 if (props
&& !props
._row
)
68 junk_keyword_message_toggle(props
._row
.uid
);
72 function junk_keyword_menu() {
73 $('#rcmjunk_keyword').html(rcmail
.env
.junk_keywordicon
);
76 rcmail
.addEventListener('init', function(evt
) {
77 rcmail
.register_command('plugin.junk_keyword.icon_toggle', junk_keyword_icon_toggle
, true);
80 rcmail
.addEventListener('listupdate','junk_keyword_menu');
81 rcmail
.addEventListener('insertrow', function(evt
) {
82 var row
= evt
.row
, uid
= evt
.uid
;
83 var message
= rcmail
.env
.messages
[uid
];
84 //if (message.flags) {
85 // var rowobj = $(row.obj);
86 // if (message.flags.junk)
87 // rowobj.addClass('junk');
89 if ((found
= $.inArray('junk_keyword', rcmail
.env
.coltypes
)) >= 0) {
90 rcmail
.set_env('junk_keyword_col', found
);
92 if (rcmail
.env
.junk_keyword_col
!= null) {
93 var junk_icon
= 'rcmjunk_keyword' + row
.uid
;
94 if (row
.junk_icon
= document
.getElementById(junk_icon
)) {
95 row
.junk_icon
._row
= row
.obj
;
96 row
.junk_icon
.onmousedown = function(e
) {
97 rcmail
.command('plugin.junk_keyword.icon_toggle', this);
98 rcube_event
.cancel(e
);
104 $(document
).ready(function() {
106 var li
= '<li><input type="checkbox" name="list_col[]" value="junk_keyword" id="cols_junk_keyword" /><label for="cols_junk_keyword">'+rcmail
.get_label('junk_keyword.junk_keyword')+'</label></li>';
107 $("#listmenu fieldset ul input#cols_threads").parent().after(li
);