/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$(window).on('load', function () {
    $('.panel-collapse').on('shown.bs.collapse', function (e) {
        return $($(this).attr("id")).html(updateSelectedGateStatus($(this).attr("id")));
    });
    $('.panel-collapse').on('hidden.bs.collapse', function (e) {
    });


    checkForUpdates = function () {
        $('.panel-collapse').each(function () {
            if ($(this).attr("class").indexOf("collapse in") >= 0) {
//                return $($(this).attr("id")).html(updateSelectedGateStatus($(this).attr("id")));
                updateSelectedGateStatus($(this).attr("id"));
            }
        });
    };

    updateSelectedGateStatus = function (gateId) {
        $.ajax({
            type: "GET",
            url: settings.baseUrl + "/gatesStatus/viewGateList/" + gateId,
            success: function (html) {
                return $('#' + gateId).html(html);
            }
        });
    };

    setInterval(checkForUpdates, settings.gate_status_refresh_time);
}
);

 