Sha256: e1a3688ed3582ccc98bdc23a5b243d24a44965db7f86de256653870faa738277

Contents?: true

Size: 1.63 KB

Versions: 17

Compression:

Stored size: 1.63 KB

Contents

/*jslint browser: true, forin: true */
(function($, window)
{
    "use strict";
    var REFRESH_SERVICES_TIMEOUT = 5000;

    $.ajaxSetup({
        error: function(e, req, options, error)
        {
            $('#url').text(options.url);
            $('#error').show();
        }
    });

    var needRefreshServices, refreshServices;
    refreshServices = function()
    {
        refreshServices.timer = null;
        $.ajax({
            url: '/services',
            cache: false
        }).error(function()
        {
            $('#url').text('/services');
            $('#error').show();
        }).success(function(html)
        {
            $('#error').hide();
            $('#services').html(html);
        }).complete(function()
        {
            needRefreshServices(false);
        });
    };
    refreshServices.timer = null;

    needRefreshServices = function(now)
    {
        if (refreshServices.timer !== null)
        {
            window.clearTimeout(refreshServices.timer);
            refreshServices.timer = null;
        }
        if (now)
        {
            refreshServices();
        }
        else
        {
            refreshServices.timer = window.setTimeout(refreshServices, REFRESH_SERVICES_TIMEOUT);
        }
    };

    $('#services').delegate('form.service-action,form.service-signal', 'submit', function(e)
    {
        e.preventDefault();
        $.post($(this).attr('action')).complete(function()
        {
            needRefreshServices(true);
        });
        return false;
    });

    $('#service-refresh-interval').text(REFRESH_SERVICES_TIMEOUT / 1000);

    needRefreshServices(true);
})(jQuery, window);

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
runit-man-2.3.12 public/js/runit-man.js
runit-man-2.3.11 public/js/runit-man.js
runit-man-2.3.9 public/js/runit-man.js
runit-man-2.3.8 public/js/runit-man.js
runit-man-2.3.7 public/js/runit-man.js
runit-man-2.3.6 public/js/runit-man.js
runit-man-2.3.5 public/js/runit-man.js
runit-man-2.3.4 public/js/runit-man.js
runit-man-2.3.3 public/js/runit-man.js
runit-man-2.3.2 public/js/runit-man.js
runit-man-2.3.1 public/js/runit-man.js
runit-man-2.2.9 public/js/runit-man.js
runit-man-2.2.8 public/js/runit-man.js
runit-man-2.2.7 public/js/runit-man.js
runit-man-2.2.6 public/js/runit-man.js
runit-man-2.2.5 public/js/runit-man.js
runit-man-2.2.4 public/js/runit-man.js