summaryrefslogtreecommitdiff
path: root/www/static/js/glitter.js
blob: 9aed159aae71a902847e6dfe06f7942e49d8c6da (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
var Glitter =
	{
	path: "/img/glitter/",
	delay: 50,
	count: 0,
	radius: $(window).height() / 3,
	direction: false,
	centerX: $(window).width() * 2 / 7,
	centerY: $(window).height() / 3,
	loopTimer: false,
	loopers: [],
	rotate: function (id, angle, radius, direction, opacity)
		{
		if (direction)
			angle += 2
		else
			angle -= 2
		radians = angle * Math.PI / 180
		newX = Math.sin(radians) * radius + Glitter.centerX
		newY = Math.cos(radians) * radius + Glitter.centerY
		$(id).css({ "left": newX, "top": newY, "opacity": opacity/100 })
		opacity -= 1
		if (opacity === 0)
			{
			$(id).remove()
			return false
			}
		return [id, angle, radius, direction, opacity]
		},
	loop: function ()
		{
		var newLoopers = []
		for (i in Glitter.loopers)
			{
			var l = Glitter.loopers[i]
			var r = Glitter.rotate(l[0], l[1], l[2], l[3], l[4])
			if (r)
				newLoopers.push(r)
			}
		Glitter.loopers = newLoopers
		Glitter.loopTimer = setTimeout(Glitter.loop, Glitter.delay)
		},
	go: function ()
		{
		Glitter.count += 1
		// if (Glitter.count % 20 === 0)
		//	Glitter.direction = ! Glitter.direction
		var index = Math.floor( Math.random() * GLITTER_DATA.length )
		var radius = Glitter.radius + Math.floor( Math.random() * 100 )
		var angle = Math.floor( Math.random() * 360 )
		var opacity = 100
		var newsrc = GLITTER_DATA[index]
		var newid = "glitter_" + Glitter.count
		var newdiv = "<div id='"+newid+"' class='glitter'><img src='"+Glitter.path+newsrc+"'/></div>"
		// console.log(newdiv)
		$("body").append(newdiv)
		Glitter.loopers.push(["#"+newid, angle, radius, Glitter.direction, opacity])
		if (! Glitter.loopTimer)
		 	Glitter.loop()
		},
	generate: function (count)
		{
		if (count > 1)
			count = 1
		for (var i = 0; i < count; i++)
			setTimeout(Glitter.go, 50)
		},
	oldTextareaMap: Keyboard.textareaMap,
	oldStandardMap: Keyboard.standardMap,
	oldFullscreenMap: Keyboard.fullscreenMap,
	fullscreenMap: function (event)
		{
		Chat.callback(1)
		return Glitter.oldFullscreenMap(event)
		},
	standardMap: function (event)
		{
		Chat.callback(1)
		return Glitter.oldStandardMap(event)
		},
	textareaMap: function (event)
		{
		Chat.callback(1)
		return Glitter.oldTextareaMap(event)
		},
	init: function ()
		{
		$("#glitter-go").bind("click", Glitter.go)
		$("#flower img").attr("src", "/img/glitter_flower.gif")
		Chat.callback = Glitter.generate
		Like.likeVideoDelay = 10000
		var newtitle = "<img src='/img/glitter_scannerjammer.gif' />"
		setTimeout('$("#heading").html("'+newtitle+'")', 6000)
		$("#topic").css({position:"fixed", top: 40, left: 750})
		Room.loadCallback = function ()
			{
			setTimeout(Viewport.fullscreenOn, 500)
			setTimeout('$("#logobg").css({width: "100%"})', 1000)
			Keyboard.textareaMap = Glitter.textareaMap
			Keyboard.standardMap = Glitter.standardMap
			Keyboard.fullscreenMap = Glitter.fullscreenMap
			Keyboard.focusTextarea()
			}
		},
	}
Glitter.init()