<script src="/js/jquery.ajaxq.js"></script>
<script src="/js/sprintf.js"></script>
<script>
var enqueLists = [];
$(document).ready(function () {
    if (enqueLists.length > 0) {
        var queue = $.ajaxq.Queue(2); //enqueLists.length);
        var i = 0;
        var widgetDone = 0;
        while (widgetDone < enqueLists.length) {
            var ajaxCall = enqueLists[i].shift();
            if (ajaxCall) {
                queue.getJSON('[% c.uri_for('/dashboard/ajax') %]/' + ajaxCall.res, {"widget":ajaxCall.widgetName}, ajaxCall.cb);
            } else {
                widgetDone++;
            }
            i = (i + 1) % enqueLists.length
        }
        //console.log('widget data loading enqueued (' + enqueLists.length + ')');
    }
});
</script>

[% site_config.title = c.loc('Dashboard') -%]

[% enabled_widgets = [] -%]
[% FOR w IN widgets -%]
    [% IF w -%]
        [% enabled_widgets.push(w) -%]
    [% END -%]
[% END -%]
[% wcount = enabled_widgets.size() > 4 ? 4 : enabled_widgets.size() -%]

<div class="row">
    <div [% IF !framed -%]class="span12"[% END -%]>
        <div class="pricing-plans plans-[% wcount %]">
            [% FOR w IN enabled_widgets -%]
                [% INCLUDE $w -%]
            [% END -%]
        </div>
    </div>
</div>

[% # vim: set tabstop=4 syntax=html expandtab: -%]
