daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Jan 17th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // refresh roundcube to get the latest mail
  2. rcmail.command("checkmail","",this,"");
  3.  
  4. // tag all the folders that have unread messages in them or in their subfolders
  5. // with the class "has_unread"
  6. $("ul.folderlist").children("li").filter(function() {
  7.     if( $(this).hasClass("unread") || $(this).find(".unread").length !== 0 ) {
  8.         $(this).addClass("has_unread");
  9.     }
  10. });
  11.  
  12. // order the folder list alphabetically
  13. var mylist = $(".folderlist");
  14. var listitems = mylist.children("li").get();
  15. listitems.sort(function(a, b) {
  16.    return $(a).text().toUpperCase().localeCompare($(b).text().toUpperCase());
  17. });
  18. $.each(listitems, function(idx, itm) { mylist.append(itm); });
  19.  
  20. // order_of_list is the order the mailboxes should appear in the folder list,
  21. // for ease of reading we put this in the order we want and then reverse it
  22. var order_of_list = ["inbox", "drafts", "sent", "junk", "trash", "archive", "has_unread"].reverse();
  23. // order the list
  24. $.each(order_of_list , function(index, value) {
  25.     // in the folderlist select the children who have a li element with the
  26.     // class equal to the value of the each loop and put them to the top
  27.     // of the folderlist
  28.     $("ul.folderlist").children("li." + value).prependTo(".folderlist");
  29. });
  30.  
  31. // remove the "has_unread" tag
  32. $("ul.folderlist li").removeClass("has_unread");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top