Changeset 3781:a86e029cb95d for admin/js
- Timestamp:
- 07/23/18 14:42:23 (7 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/_index.js
r3706 r3781 2 2 'use strict'; 3 3 4 dotclear.dbCommentsCount = function() { 5 var params = { 6 f: 'getCommentsCount', 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.dbCommentsCount_Counter) { 17 // First pass or counter changed 18 var icon = $('#dashboard-main #icons p a[href="comments.php"]'); 19 if (icon.length) { 20 // Update count if exists 21 var nb_label = icon.children('span.db-icon-title'); 22 if (nb_label.length) { 23 nb_label.text(nb); 24 } 25 } 26 // Store current counter 27 dotclear.dbCommentsCount_Counter = nb; 28 } 29 } 30 }); 31 }; 32 dotclear.dbPostsCount = function() { 33 var params = { 34 f: 'getPostsCount', 35 xd_check: dotclear.nonce, 36 }; 37 $.get('services.php', params, function(data) { 38 if ($('rsp[status=failed]', data).length > 0) { 39 // For debugging purpose only: 40 // console.log($('rsp',data).attr('message')); 41 window.console.log('Dotclear REST server error'); 42 } else { 43 var nb = $('rsp>count', data).attr('ret'); 44 if (nb != dotclear.dbPostsCount_Counter) { 45 // First pass or counter changed 46 var icon = $('#dashboard-main #icons p a[href="posts.php"]'); 47 if (icon.length) { 48 // Update count if exists 49 var nb_label = icon.children('span.db-icon-title'); 50 if (nb_label.length) { 51 nb_label.text(nb); 52 } 53 } 54 // Store current counter 55 dotclear.dbPostsCount_Counter = nb; 56 } 57 } 58 }); 59 }; 4 60 $(function() { 5 61 function quickPost(f, status) { … … 127 183 } 128 184 }); 185 186 // run counters' update on some dashboard icons 187 // Comments (including everything) 188 var icon_com = $('#dashboard-main #icons p a[href="comments.php"]'); 189 if (icon_com.length) { 190 // Icon exists on dashboard 191 // First pass 192 dotclear.dbCommentsCount(); 193 // Then fired every 60 seconds (1 minute) 194 dotclear.dbCommentsCount_Timer = setInterval(dotclear.dbCommentsCount, 60 * 1000); 195 } 196 // Posts 197 var icon_com = $('#dashboard-main #icons p a[href="posts.php"]'); 198 if (icon_com.length) { 199 // Icon exists on dashboard 200 // First pass 201 dotclear.dbPostsCount(); 202 // Then fired every 600 seconds (10 minutes) 203 dotclear.dbPostsCount_Timer = setInterval(dotclear.dbCommentsPost, 600 * 1000); 204 } 129 205 });
Note: See TracChangeset
for help on using the changeset viewer.