Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 52.15.190.187
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /srv/modoboa/instance/sitestatic/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /srv/modoboa/instance/sitestatic/js/top_notifications.js
/**
 * Top notifications poller.
 */

var TopNotifications = function(options) {
    this.initialize(options);
};

TopNotifications.prototype = {
    constructor: TopNotifications,

    defaults: {
        container_id: "#top_notifications",
        global_counter_id: "#alerts-counter",
        url: null,
        interval: 1000
    },

    /**
     * Constructor.
     */
    initialize: function(options) {
        this.options = $.extend({}, this.defaults, options);
        this.poller = new Poller(this.options.url, {
            interval: this.options.interval,
            success_cb: $.proxy(this.update, this)
        });
        this.$container = $(this.options.container_id);
    },

    /**
     * Build a notification entry content.
     */
    build_link_content: function(data) {
        var content = "";

        if (data.counter) {
            content = "<span class='label label-" +
                data.level + "'>" + data.counter + "</span> " +
                data.text;
        } else {
            content = "<span class='fa fa-info-circle'></span> " + data.text;
        }
        return content;
    },

    /**
     * Append an entry to the notification list.
     */
    append_entry: function(data) {
        if ((data.counter !== undefined && data.counter === 0) ||
            (data.counter === undefined && data.text === undefined)) {
            return;
        }

        var $li = $("<li />");

        $li.append(
            $("<a />", {
                id: data.id, href: data.url,
                html: this.build_link_content(data)
            })
        );
        this.$container.find(".dropdown-menu").append($li);
    },

    /**
     * Update an existing entry in the notification list.
     */
    update_entry: function(data) {
        var $link = $("#" + data.id);

        if ((data.counter !== undefined && data.counter === 0) ||
            (data.counter === undefined && data.text === undefined)) {
            $link.parent().remove();
            return;
        }
        $link.html(this.build_link_content(data));
    },

    /**
     * Poller callback.
     */
    update: function(data) {
        for (var cpt = 0; cpt < data.length; cpt++) {
            var $link = $("#" + data[cpt].id);
            if (!$link.length) {
                this.append_entry(data[cpt]);
            } else {
                this.update_entry(data[cpt]);
            }
        }
        var $entries = this.$container.find(".dropdown-menu li");
        if ($entries.length) {
            this.$container.removeClass("hidden");
            $(this.options.global_counter_id).html($entries.length);
        } else {
            this.$container.addClass("hidden");
        }
    }
};

Anon7 - 2022
AnonSec Team