srchub

srchub Git Source Tree


Root/indefero/www/media/idf/js/logo.cache.js

$(function () {
    var logoCache = {};
    var waiting = 0;
    function logoUpdate() {
        if (waiting == 0) {
            $(".logo").each(function () {
                var self = $(this);
                var logo = $(this).data("logo");
                if (logo == "") {
                    logo = undefined;
                }
                self.attr("src", logoCache[logo]);
            });
        } else {
            waiting -= 1;
        }
    }
    $(".logo").each(function () {
        var logoSrc = $(this).data("src");
        var logo = $(this).data("logo");
        var self = $(this);
        if (!logoSrc) {
            return;
        }

        if (logo == "") {
            logo = undefined;
        }

        if (!(logo in logoCache)) {
            logoCache[logo] = logoSrc;
        }
    });

    waiting = Object.keys(logoCache).length - 1;
    $.each(logoCache, function (index, element) {
        $.ajax({
            url: logoCache[index],
            success: function(data) {
                logoCache[index] = data;
                logoUpdate();
            },
            async: true
        });
    });
});

Archive Download this file

Branches

Number of commits:
Page rendered in 0.08099s using 11 queries.