<script>
enqueLists.push([{
    res: 'registrations_slice',
    widgetName: "SubscriberRegisterOverview",
    cb: function(data) {
        //console.log(data);
        var registrations = data.widget_data;
        if (registrations.length == 0) {
            $("#subscriber_registration_overview_lazy_items_list").append('<li>[% c.escape_js(c.loc('No devices registered')) %]</li>');
        } else {
            for (var i = 0; i < registrations.length; i++) {
                var registration = registrations[i];
                $("#subscriber_registration_overview_lazy_items_list").append('<li>' +
                    '<div class="row-fluid"><div>' +
                        (registration.user_agent.length > 48 ?
                            registration.user_agent.length.substring(0,45) + '...'
                        :
                            registration.user_agent
                        ) +
                    '</div></div>' +
                '</li>');
            }
        }
    }
},{
    res: 'registrations_count',
    widgetName: "SubscriberRegisterOverview",
    cb: function(data) {
        //console.log(data);
        $("#subscriber_registration_overview_lazy_loading").remove();
        $("#subscriber_registration_overview_lazy_items_header").append(
            '<div class="plan-price">' +
                '<span>' + data.widget_data + '</span>' +
                '<span class="term">' + (data.widget_data == 1 ? '[% c.escape_js(c.loc('Registered Device')) %]' : '[% c.escape_js(c.loc('Registered Devices')) %]') + '</span>' +
            '</div>');
    }
}]);
</script>
<div class="plan-container">
    <div class="plan">
        <div class="plan-header" id="subscriber_registration_overview_lazy_items_header">
            <div class="plan-title">[% c.loc('Registered Devices') %]</div>
            <div class="plan-price widget-loading" id="subscriber_registration_overview_lazy_loading"><span>0</span><span class="term">processing ...</span></div>
        </div>
        <div class="plan-features large">
            <ul id="subscriber_registration_overview_lazy_items_list">
            </ul>
        </div>
        <div class="plan-actions">
            <a href="[% c.uri_for_action('/subscriber/reglist', [c.user.voip_subscriber.id]) %]" class="btn">[% c.loc('View All Registered Devices') %]</a>
        </div>
    </div>
</div>
[% # vim: set tabstop=4 syntax=html expandtab: -%]
