<commit_before>/*
 * The javascript code that brings the webmail to life!
 */
var Webmail = function(options) {
    this.initialize(options);
};

Webmail.prototype = {
    constructor: Webmail,

    defaults: {
        poller_interval: 300, /* in seconds */
        poller_url: "",
        move_url: "",
        submboxes_url: "",
        delattachment_url: "",
        ro_mboxes: ["INBOX"]
    },

    initialize: function(options) {
        this.options = $.extend({}, this.defaults, options);
        this.rtimer = null;
        this.editorid = "id_body";

        this.navobject = new History({
            deflocation: "?action=listmailbox",
            defcallback: $.proxy(this.listmailbox_callback, this)
        });
        this.poller = new Poller(this.options.poller_url, {
            interval: this.options.poller_interval * 1000,
            success_cb: $.proxy(this.poller_cb, this),
            args: this.get_visible_mailboxes
        });
        this.record_unseen_messages();

        $("#folders").css({
            bottom: $("#bottom-bar").outerHeight(true)
        });
        $("#mboxactions").css({
            bottom: $("#bottom-bar").outerHeight(true) + 10
        });
        this.resize();

        this.init_droppables();
        this.register_navcallbacks();
        this.listen();
    },

    register_navcallbacks: function() {
        this.navobject.register_callback("listmailbox",
            $.proxy(this.listmailbox_callback, this));
        this.navobject.register_callback("compose",
            $.proxy(this.compose_callback, this));
        this.navobject.register_callback("viewmail",
            $.proxy(this.viewmail_callback, this));

        this.navobject.register_callback("reply",
            $.proxy(this.compose_callback, this));
        this.navobject.register_callback("replyall",
            $.proxy(this.compose_callback, this));
        this.navobject.register_callback("forward",
            $.proxy(this.compose_callback, this));
        this.navobject.register_callback("delete",
            $.proxy(this.delete_callback, this));
    },

    listen: function() {
        $(window).resize(this.resize);

        $(document).on("click", "a[name=compose]",
            $.proxy(this.compose_loader, this));
        $(document).on("click", "a[name*=mark-]",
            $.proxy(this.send_mark_request, this));
        $(document).on("click", "a[name=compress]",
            $.proxy(this.compress, this));
        $(document).on("click", "a[name=empty]",
            $.proxy(this.empty, this));
        $(document).on("click", "#bottom-bar a",
            $.proxy(this.getpage_loader, this));

        $(document).on("click", "a[name=loadfolder]",
            $.proxy(this.listmailbox_loader, this));
        $(document).on("click", "a[name=selectfolder]",
            this.select_parent_mailbox),
        $(document).on("click", "div[class*=clickbox]",
            $.proxy(this.mbox_state_callback, this));
        $(document).on("click", "a[name=newmbox]",
            $.proxy(this.new_mailbox, this));
        $(document).on("click", "a[name=editmbox]",
            $.proxy(this.edit_mbox, this));
        $(document).on("click", "a[name=removembox]",
            $.proxy(this.remove_mbox, this));

        $(document).on("dblclick", "tbody>tr",
            $.proxy(this.viewmail_loader, this));

        $(document).on("click", "a[name=reply]",
            $.proxy(this.reply_loader, this));
        $(document).on("click", "a[name=replyall]",
            $.proxy(this.reply_loader, this));
        $(document).on("click", "a[name=forward]",
            $.proxy(this.reply_loader, this));
        $(document).on("click", "a[name=delete]",
            $.proxy(this.delete_message, this));
        $(document).on("click", "a[name=activate_links]",
            $.proxy(function(e) { this.display_mode(e, "1"); }, this));
        $(document).on("click", "a[name=disable_links]",
            $.proxy(function(e) { this.disable_mode(e, "0"); }, this));

        $(document).on("click", "a[name=sendmail]",
            $.proxy(this.sendmail, this));

        $(document).on("click", "#attachments", $.proxy(function(e) {
            modalbox(e, undefined, $("#attachments").attr("name"),
                $.proxy(this.attachments_init, this));
        }, this));
    },

    record_unseen_messages: function() {<commit_msg>fix ticket #325 : Open message on *simple click* event<commit_after>/*
 * The javascript code that brings the webmail to life!
 */
var Webmail = function(options) {
    this.initialize(options);
};

Webmail.prototype = {
    constructor: Webmail,

    defaults: {
        poller_interval: 300, /* in seconds */
        poller_url: "",
        move_url: "",
        submboxes_url: "",
        delattachment_url: "",
        ro_mboxes: ["INBOX"]
    },

    initialize: function(options) {
        this.options = $.extend({}, this.defaults, options);
        this.rtimer = null;
        this.editorid = "id_body";

        this.navobject = new History({
            deflocation: "?action=listmailbox",
            defcallback: $.proxy(this.listmailbox_callback, this)
        });
        this.poller = new Poller(this.options.poller_url, {
            interval: this.options.poller_interval * 1000,
            success_cb: $.proxy(this.poller_cb, this),
            args: this.get_visible_mailboxes
        });
        this.record_unseen_messages();

        $("#folders").css({
            bottom: $("#bottom-bar").outerHeight(true)
        });
        $("#mboxactions").css({
            bottom: $("#bottom-bar").outerHeight(true) + 10
        });
        this.resize();

        this.init_droppables();
        this.register_navcallbacks();
        this.listen();
    },

    register_navcallbacks: function() {
        this.navobject.register_callback("listmailbox",
            $.proxy(this.listmailbox_callback, this));
        this.navobject.register_callback("compose",
            $.proxy(this.compose_callback, this));
        this.navobject.register_callback("viewmail",
            $.proxy(this.viewmail_callback, this));

        this.navobject.register_callback("reply",
            $.proxy(this.compose_callback, this));
        this.navobject.register_callback("replyall",
            $.proxy(this.compose_callback, this));
        this.navobject.register_callback("forward",
            $.proxy(this.compose_callback, this));
        this.navobject.register_callback("delete",
            $.proxy(this.delete_callback, this));
    },

    listen: function() {
        $(window).resize(this.resize);

        $(document).on("click", "a[name=compose]",
            $.proxy(this.compose_loader, this));
        $(document).on("click", "a[name*=mark-]",
            $.proxy(this.send_mark_request, this));
        $(document).on("click", "a[name=compress]",
            $.proxy(this.compress, this));
        $(document).on("click", "a[name=empty]",
            $.proxy(this.empty, this));
        $(document).on("click", "#bottom-bar a",
            $.proxy(this.getpage_loader, this));

        $(document).on("click", "a[name=loadfolder]",
            $.proxy(this.listmailbox_loader, this));
        $(document).on("click", "a[name=selectfolder]",
            this.select_parent_mailbox),
        $(document).on("click", "div[class*=clickbox]",
            $.proxy(this.mbox_state_callback, this));
        $(document).on("click", "a[name=newmbox]",
            $.proxy(this.new_mailbox, this));
        $(document).on("click", "a[name=editmbox]",
            $.proxy(this.edit_mbox, this));
        $(document).on("click", "a[name=removembox]",
            $.proxy(this.remove_mbox, this));

        $(document).on("click", "tbody>tr",
            $.proxy(this.viewmail_loader, this));

        $(document).on("click", "a[name=reply]",
            $.proxy(this.reply_loader, this));
        $(document).on("click", "a[name=replyall]",
            $.proxy(this.reply_loader, this));
        $(document).on("click", "a[name=forward]",
            $.proxy(this.reply_loader, this));
        $(document).on("click", "a[name=delete]",
            $.proxy(this.delete_message, this));
        $(document).on("click", "a[name=activate_links]",
            $.proxy(function(e) { this.display_mode(e, "1"); }, this));
        $(document).on("click", "a[name=disable_links]",
            $.proxy(function(e) { this.disable_mode(e, "0"); }, this));

        $(document).on("click", "a[name=sendmail]",
            $.proxy(this.sendmail, this));

        $(document).on("click", "#attachments", $.proxy(function(e) {
            modalbox(e, undefined, $("#attachments").attr("name"),
                $.proxy(this.attachments_init, this));
        }, this));
    },

    record_unseen_messages: function() {
{'fraction_non_alphanumeric': 0.18127989068549305, 'fraction_numerical': 0.0028467319517194263, 'mean_word_length': 2.5132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7387935', 'n_tokens_mistral': 2605, 'n_tokens_neox': 2550, 'n_words': 380}