/* See license.txt for terms of usage */

with ($.domplate) {

// ************************************************************************************************
// Constants

var TimeInfoTip = domplate(
{
    tag:
        TABLE({"class": "timeInfoTip"},
            TBODY(
                TR(
                    TD({"class": "netResolvingBar timeInfoTipBar"}),
                    TD("$file|getResolvingTime : " + $STR("requestinfo.DNS Lookup"))
                ),
                TR(
                    TD({"class": "netConnectingBar timeInfoTipBar"}),
                    TD("$file|getConnectintTime : " + $STR("requestinfo.Connecting"))
                ),
                TR(
                    TD({"class": "netWaitingBar timeInfoTipBar"}),
                    TD("$file|getWaitingTime : " + $STR("requestinfo.Queuing"))
                ),
                TR(
                    TD({"class": "netRespondedBar timeInfoTipBar"}),
                    TD("$file|getResponseTime : " + $STR("requestinfo.Waiting For Response"))
                ),
                TR({$loaded: "$file.loaded",
                    $fromCache: "$file.fromCache"},
                    TD({"class": "netTimeBar timeInfoTipBar"}),
                    TD("$file|getLoadingTime : " + $STR("requestinfo.Receiving Data"))
                ),
                TR(
                    TD({align: "center"},
                        DIV({"class": "netContentLoadBar timeInfoTipBar"})
                    ),
                    TD("$file|getContentLoadTime : " + $STR("requestinfo.DOMContentLoaded"))
                ),
                TR(
                    TD({align: "center"},
                        DIV({"class": "netWindowLoadBar timeInfoTipBar"})
                    ),
                    TD("$file|getWindowLoadTime : " + $STR("requestinfo.Load"))
                )
            )
        ),

    getResolvingTime: function(file)
    {
        return formatTime(file.resolvingTime - file.startTime);
    },

    getConnectintTime: function(file)
    {
        return formatTime(file.connectingTime - file.startTime);
    },

    getWaitingTime: function(file)
    {
        return formatTime(file.waitingForTime - file.connectingTime);
    },

    getResponseTime: function(file)
    {
        return formatTime(file.respondedTime - file.waitingForTime);
    },

    getLoadingTime: function(file)
    {
        return formatTime(file.endTime - file.respondedTime);
    },

    getWindowLoadTime: function(file)
    {
        if (!file.phase.windowLoadTime)
            return "";

        var time = file.phase.windowLoadTime - file.startTime;
        return (time > 0 ? "+" : "") + formatTime(time);
    },

    getContentLoadTime: function(file)
    {
        if (!file.phase.contentLoadTime)
            return "";

        var time = file.phase.contentLoadTime - file.startTime;
        return (time > 0 ? "+" : "") + formatTime(time);
    }
});

// ************************************************************************************************

var SizeInfoTip = domplate(
{
    tag:
        DIV({"class": "sizeInfoTip"}, "$file|getSize"),

    getSize: function(file)
    {
        return $STRF("net.file.SizeInfotip", [formatSize(file.size),
            (file.size < 0) ? "?" : formatNumber(file.size)]);
    }
});

// ************************************************************************************************
};