HEX
Server: Apache/2.4.25 (Debian)
System: Linux server17 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
User: web37 (1062)
PHP: 7.4.30
Disabled: show_source, highlight_file, apache_child_terminate, apache_get_modules, apache_note, apache_setenv, virtual, dl, disk_total_space, posix_getpwnam, posix_getpwuid, posix_mkfifo, posix_mknod, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_nice, openlog, syslog, pfsockopen
Upload Files
File: /var/www/web37/htdocs/fickanzeiger/moderation/javascript/site/jquery.waitingSitesUpdater.js
(function($){

    $.waitingSitesUpdater = function(){
    
        var that = {
        
            waitingSitesIds: new Array(),
            
            init: function(){
                $("#waitingSitesForm input[name=siteIds\\[\\]]").each(function(){
                    that.waitingSitesIds.push($(this).val());
                });
                
                setInterval(that.refreshWaitingSites, 1000 /* milliseconds */ * 10 /* seconds */);
            },
            
            updateWaitingForms: function(){
                // display new waiting sites count
                $('#countOfWaitingSites').text(that.waitingSitesIds.length);
                
                // set alternative colours (repaint list items after removing/adding)
                var alt = true;
                $('#holderOfWaitingSites > div').each(function(){
                    if (alt) {
                        this.className = "column_in_waiting_site_grey";
                    }
                    else {
                        this.className = "column_in_waiting_site_blue";
                    }
                    
                    alt = !alt;
                });
                
            },
            
            waitingSitesHtmlSuccess: function(responseHtml){
                $('#holderOfWaitingSites').html($('#holderOfWaitingSites').html() + responseHtml);
                that.updateWaitingForms();
            },
            
            compareWaitingSitesSuccess: function(sites){
                that.waitingSitesIds = sites.waiting;
                
                // remove moderated sites
                for (var i = 0; i < sites.toRemove.length; i++) {
                    var siteId = sites.toRemove[i];
                    $("#siteItem" + siteId).remove();
                }
                
                // add newly appeared waiting sites
                if (sites.toAdd.length) {
                
                    $.post(AppRouter.getRewrittedUrl('/moderation/site/getWaitingSitesHtml'), {
                        'siteIds': sites.toAdd.join(",")
                    }, that.waitingSitesHtmlSuccess);
                }
                else {
                    that.updateWaitingForms();
                }
                
            },
            
            refreshWaitingSites: function(){
                var sitesList = that.waitingSitesIds.join(',');
                $.post(AppRouter.getRewrittedUrl('/moderation/site/compareWaitingSites'), {
                    'waitingSitesIds': sitesList
                }, that.compareWaitingSitesSuccess, 'json');
            }
            
        }
        
        that.init();
        
    }
    
})(jQuery);