summaryrefslogtreecommitdiffstats
path: root/schemas/OMNA Schema-based Namespace Registry_fichiers/Ticker.js
blob: 100c8c75cf82125b56ab12c043d0189d83f7bf05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
if (typeof window.RadControlsNamespace == "undefined")
{
	window.RadControlsNamespace = {};
}

RadControlsNamespace.Ticker = function (listener)
{
	this.Listener = listener;
	this.IntervalPointer = null;
}

RadControlsNamespace.Ticker.prototype =
{
	Configure : function (config)
	{
		this.Duration = config.Duration;
		this.Interval = 16;
	},
	
	Start : function ()
	{
		clearInterval(this.IntervalPointer);
		this.TimeElapsed = 0;
		var instance = this;
		var closure = function ()
		{
			instance.Tick();
		}
		
		this.Tick();
		this.IntervalPointer = setInterval(closure, this.Interval);
	},
	
	Tick : function ()
	{
		this.TimeElapsed += this.Interval;
		this.Listener.OnTick(this.TimeElapsed);
		
		if (this.TimeElapsed >= this.Duration)
		{
			this.Stop();
		}
	},
	
	Stop : function ()
	{
		if (this.IntervalPointer)
		{
			this.Listener.OnTickEnd();
			clearInterval(this.IntervalPointer);
			this.IntervalPointer = null;
		}
	}
	
}

//BEGIN_ATLAS_NOTIFY
if (typeof(Sys) != "undefined")
{
	if (Sys.Application != null && Sys.Application.notifyScriptLoaded != null)
	{
		Sys.Application.notifyScriptLoaded();
	}
}
//END_ATLAS_NOTIFY
OpenPOWER on IntegriCloud