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
|
/*
* This file is part of "What's The Point" <https://github.com/Pacien/WhatsThePoint>
* Copyright (C) 2014 Pacien TRAN-GIRARD
*
* "What's The Point" is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* "What's The Point" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([ "css!plugins/doge/doge" ], function () {
var doge = {
TAG: "d-doge",
NUMBER: 2,
INTERVAL: 4000,
MAX_SIZE: 2,
MIN_SIZE: 3,
WORD: [ "wow", "so slides", "many points", "very slideshow", "such clear", "much serious" ],
COLOURS: [ "red", "green", "orange", "violet", "aqua", "yellow", "slateblue", "purple", "pink", "lime", "fuchsia", "gold", "indigo" ],
init: function () {
this.woofs = [];
this.c = 0;
setInterval(doge.spawn, this.INTERVAL);
},
getRandomFromInterval: function (min, max) {
return Math.random() * (max - min) + min;
},
getRandomFontSize: function () {
return doge.getRandomFromInterval(doge.MIN_SIZE, doge.MAX_SIZE);
},
getRandomItem: function (items) {
return items[Math.floor(Math.random() * items.length)];
},
getRandomColour: function () {
return doge.getRandomItem(doge.COLOURS);
},
getRandomWord: function () {
return doge.getRandomItem(doge.WORD);
},
woof: function () {
var woof = document.createElement(doge.TAG);
document.body.appendChild(woof);
doge.woofs.push(woof);
woof.appendChild(document.createTextNode(doge.getRandomWord()));
woof.style.animationDuration = doge.NUMBER * doge.INTERVAL + "ms";
woof.style.WebkitAnimationDuration = woof.style.animationDuration;
woof.style.fontSize = doge.getRandomFontSize() + "em";
woof.style.color = doge.getRandomColour();
woof.style.top = doge.getRandomFromInterval(0, window.innerHeight - woof.offsetHeight) + "px";
woof.style.left = doge.getRandomFromInterval(0, window.innerWidth - woof.offsetWidth) + "px";
},
spawn: function () {
if (doge.woofs.length >= doge.NUMBER) {
doge.woofs[0].remove();
doge.woofs.splice(0, 1);
}
doge.woof();
},
};
return doge;
});
|