Support Incident Tracker GIT4.x
activity.js File Reference

Go to the source code of this file.

Functions

function Activity ()
function addActivity (act)
function setClosedDuration (closed)
function formatSeconds (secondsOpen)
function countUp ()

Variables

var dataArray = new Array()
var count = 0
var closedDuration = 0

Function Documentation

function Activity ( )
Author:
Paul Heaney

Definition at line 4 of file activity.js.

{
    var id;
    var start;
}
function addActivity (   act)
Author:
Paul Heaney

Definition at line 17 of file activity.js.

References count, and dataArray.

{
    dataArray[count] = act;
    count++;
}
function countUp ( )
Author:
Paul Heaney

Definition at line 119 of file activity.js.

References closedDuration, dataArray, formatSeconds(), and now.

{
    var now = new Date();

    var sinceEpoch = Math.round(new Date().getTime()/1000.0);

    var closed = closedDuration;

    var i = 0;
    for(i=0; i < dataArray.length; i++)
    {
        var secondsOpen = sinceEpoch-dataArray[i].start;

        closed += secondsOpen;

        var str = formatSeconds(secondsOpen);

        $("duration"+dataArray[i].id).innerHTML = "<em>"+str+"</em>";
    }

    if ($('totalduration') != null)
    {
        $('totalduration').innerHTML = formatSeconds(closed);
     }
}
function formatSeconds (   secondsOpen)
Author:
Paul Heaney

Definition at line 34 of file activity.js.

Referenced by countUp().

{
    var str = '';
    if (secondsOpen >= 86400)
    {   //days
        var days = Math.floor(secondsOpen/86400);
        if (days < 10)
        {
            str += "0"+days;
        }
        else
        {
            str += days;
        }
        secondsOpen-=(days*86400);
    }
    else
    {
        str += "00";
    }

    str += ":";

    if (secondsOpen >= 3600)
    {   //hours
        var hours = Math.floor(secondsOpen/3600);
        if (hours < 10)
        {
            str += "0"+hours;
        }
        else
        {
            str += hours;
        }
        secondsOpen-=(hours*3600);
    }
    else
    {
        str += "00";
    }

    str += ":";

    if (secondsOpen > 60)
    {   //minutes
        var minutes = Math.floor(secondsOpen/60);
        if (minutes < 10)
        {
            str += "0"+minutes;
        }
        else
        {
            str += minutes;
        }
        secondsOpen-=(minutes*60);
    }
    else
    {
        str +="00";
    }

    str += ":";

    if (secondsOpen > 0)
    {  // seconds
        if (secondsOpen < 10)
        {
            str += "0"+secondsOpen;
        }
        else
        {
            str += secondsOpen;
        }
    }
    else
    {
        str += "00";
    }

    return str;
}
function setClosedDuration (   closed)
Author:
Paul Heaney

Definition at line 26 of file activity.js.

References closedDuration.

{
    closedDuration = closed;
}

Variable Documentation

var closedDuration = 0

Definition at line 12 of file activity.js.

Referenced by countUp(), and setClosedDuration().

var dataArray = new Array()

Definition at line 10 of file activity.js.

Referenced by addActivity(), and countUp().