gnuru.js
1.95 KB
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
gnuru = new Image ();
gnuru_t = new Image ();
gnuru.src = "images/gnuru.png"
gnuru_t.src = "images/gnuru-trans.png"
/* Klasse die Weisheiten aufnehmen kann. */
function GnuruWisdom (ti, te, so)
{
var title = ti;
var text = te;
var source = so;
this.setTitle = function (ti)
{
title = ti;
}
this.setText = function (te)
{
text = te;
}
this.setSource = function (so)
{
source = so;
}
this.getTitle = function ()
{
return title;
}
this.getText = function ()
{
return text;
}
this.getSource = function ()
{
return source;
}
}
/* an array with all weisheiten (will be filled through php in gnuru.tpl) */
var gnuruWisArray = new Array ()
/* Eventhandler */
function gnuruWake ()
{
document.getElementById ('GNURU_IMG').src = gnuru.src;
}
function gnuruMeditate ()
{
document.getElementById ('GNURU_IMG').src = gnuru_t.src;
}
function gnuruAsk ()
{
divShow ('GNURU_BUBBLE', 2);
}
function gnuruAskEnd ()
{
divHide ('GNURU_BUBBLE', 2);
}
var wisIndex;
var lastWisIndex;
function gnuruSais ()
{
gnuruAskEnd ();
/* create the index for the wisdom that should be displayed, but ensure
not to create the same index twice */
while (wisIndex == lastWisIndex)
wisIndex = Math.round (Math.random () * 100) % gnuruWisArray.length;
lastWisIndex = wisIndex;
/* The following clears all childdata from title, text and source ...*/
/* ... and then refills it with our own data */
node = document.getElementById('GNURU_WIS_TITLE');
pnode = node.parentNode;
pnode.replaceChild (gnuruWisArray[wisIndex].getTitle (), node);
node = document.getElementById('GNURU_WIS_TEXT')
pnode = node.parentNode;
pnode.replaceChild (gnuruWisArray[wisIndex].getText (), node);
node = document.getElementById('GNURU_WIS_SOURCE')
pnode = node.parentNode;
pnode.replaceChild (gnuruWisArray[wisIndex].getSource (), node);
/* and finally display the whole stuff */
divShow ('GNURU_SAIS', 3);
}
function gnuruSilence ()
{
divHide ('GNURU_SAIS', 3);
}