Dotclear

source: plugins/antispam/js/dashboard.js @ 3787:24c2472a688c

Revision 3787:24c2472a688c, 1.7 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Use css3 flex rather than <br > to vertical align supplemental labels under dashboard icons

Line 
1/*global $, dotclear */
2'use strict';
3
4dotclear.dbSpamsCount = function() {
5  var params = {
6    f: 'getSpamsCount',
7    xd_check: dotclear.nonce,
8  };
9  $.get('services.php', params, function(data) {
10    if ($('rsp[status=failed]', data).length > 0) {
11      // For debugging purpose only:
12      // console.log($('rsp',data).attr('message'));
13      window.console.log('Dotclear REST server error');
14    } else {
15      var nb = $('rsp>count', data).attr('ret');
16      if (nb != dotclear.dbSpamsCount_Counter) {
17        // First pass or counter changed
18        var icon = $('#dashboard-main #icons p a[href="comments.php?status=-2"]');
19        if (icon.length) {
20          // Update count if exists
21          var nb_label = icon.children('span.db-icon-title-spam');
22          if (nb_label.length) {
23            nb_label.text(nb);
24          }
25        } else {
26          if (nb != '') {
27            // Add full element (link + counter)
28            var icon = $('#dashboard-main #icons p a[href="comments.php"]');
29            if (icon.length) {
30              var xml = ' <a href="comments.php?status=-2"><span class="db-icon-title-spam">' + nb + '</span></a>';
31              icon.after(xml);
32            }
33          }
34        }
35        // Store current counter
36        dotclear.dbSpamsCount_Counter = nb;
37      }
38    }
39  });
40};
41
42$(function() {
43  // run counters' update on some dashboard icons
44  // Spam comments
45  var icon_spam = $('#dashboard-main #icons p a[href="comments.php"]');
46  if (icon_spam.length) {
47    // Icon exists on dashboard
48    // First pass
49    dotclear.dbSpamsCount();
50    // Then fired every 60 seconds (1 minute)
51    dotclear.dbSpamsCount_Timer = setInterval(dotclear.dbSpamsCount, 60 * 1000);
52  }
53});
Note: See TracBrowser for help on using the repository browser.

Sites map