Huggle/JS/uptime.js

From MediaWiki.org
< Huggle‎ | JS
Jump to navigation Jump to search
function ext_is_working()
{
    return true;
}

function round_time(time)
{
    if (time <= 9)
        return "0" + time;
    return time;
}

function show()
{
    var uptime = huggle.get_uptime();
    var ts = huggle.seconds_to_time_span(uptime);
    var text = ts["days"] + " days " + round_time(ts["hours"]) + ":" + round_time(ts["minutes"]) + ":" + round_time(ts["seconds"]);
    huggle_ui.message_box("Uptime", text);
}

function register_menus()
{
    menu_id = huggle_ui.create_menu_item(huggle_ui_menu_scripting, "Uptime", "show");
}

function ext_init()
{
    if (huggle_ui.mainwindow_is_loaded())
    {
        register_menus();
    } else if (!huggle.register_hook("main_open", "register_menus"))
    {
        return false;
    }
    return true;
}

function ext_get_info()
{
    var info = {};
    info["name"] = "uptime";
    info["version"] = "1.0.0";
    info["description"] = "Shows uptime";
    info["author"] = "Petr Bena";
    info["min_huggle_version"] = "3.4.5";
    info["required_context"] = "huggle_ui";
    info["requires_unsafe"] = false;
    return info;
}