aboutsummaryrefslogtreecommitdiff
path: root/point/plugins/doge/doge.js
diff options
context:
space:
mode:
Diffstat (limited to 'point/plugins/doge/doge.js')
-rw-r--r--point/plugins/doge/doge.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/point/plugins/doge/doge.js b/point/plugins/doge/doge.js
new file mode 100644
index 0000000..692ec03
--- /dev/null
+++ b/point/plugins/doge/doge.js
@@ -0,0 +1,89 @@
1/*
2 * This file is part of "What's The Point" <https://github.com/Pacien/WhatsThePoint>
3 * Copyright (C) 2014 Pacien TRAN-GIRARD
4 *
5 * "What's The Point" is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * "What's The Point" is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19define([ "css!plugins/doge/doge" ], function () {
20
21 var doge = {
22
23 TAG: "d-doge",
24 NUMBER: 2,
25 INTERVAL: 4000,
26 MAX_SIZE: 2,
27 MIN_SIZE: 3,
28 WORD: [ "wow", "so slides", "many points", "very slideshow", "such clear", "much serious" ],
29 COLOURS: [ "red", "green", "orange", "violet", "aqua", "yellow", "slateblue", "purple", "pink", "lime", "fuchsia", "gold", "indigo" ],
30
31 init: function () {
32 this.woofs = [];
33 this.c = 0;
34 setInterval(doge.spawn, this.INTERVAL);
35 },
36
37 getRandomFromInterval: function (min, max) {
38 return Math.random() * (max - min) + min;
39 },
40
41 getRandomFontSize: function () {
42 return doge.getRandomFromInterval(doge.MIN_SIZE, doge.MAX_SIZE);
43 },
44
45 getRandomItem: function (items) {
46 return items[Math.floor(Math.random() * items.length)];
47 },
48
49 getRandomColour: function () {
50 return doge.getRandomItem(doge.COLOURS);
51 },
52
53 getRandomWord: function () {
54 return doge.getRandomItem(doge.WORD);
55 },
56
57 woof: function () {
58 var woof = document.createElement(doge.TAG);
59
60 document.body.appendChild(woof);
61 doge.woofs.push(woof);
62
63 woof.appendChild(document.createTextNode(doge.getRandomWord()));
64
65 woof.style.animationDuration = doge.NUMBER * doge.INTERVAL + "ms";
66 woof.style.WebkitAnimationDuration = woof.style.animationDuration;
67
68 woof.style.fontSize = doge.getRandomFontSize() + "em";
69 woof.style.color = doge.getRandomColour();
70
71 woof.style.top = doge.getRandomFromInterval(0, window.innerHeight - woof.offsetHeight) + "px";
72 woof.style.left = doge.getRandomFromInterval(0, window.innerWidth - woof.offsetWidth) + "px";
73
74 },
75
76 spawn: function () {
77 if (doge.woofs.length >= doge.NUMBER) {
78 doge.woofs[0].remove();
79 doge.woofs.splice(0, 1);
80 }
81
82 doge.woof();
83 },
84
85 };
86
87 return doge;
88
89});