Bonjour,

J'ai quelque petits problèmes pour faire appel à un code javascript depuis un "module" dans un forum ForumActif.

Je ne comprend pas d'ou vient le problème... Est ce l'appel qui ne fonctionne pas? Ou est-ce le javascript? Ou bien le code fonctionne mais rien ne s'affiche?
Le problème ne doit pas venir du script en lui même, il y a quelque chose que je rate ailleurs...
J'ai un doute sur les "document.getElementById" étant donné que mon code se trouve dans un module et non sur une page HTML.


Voici le code à l'intérieure de mon module :

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
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
<head>
<script type="text/javascript" src="http://originslinkshell.forumgratuit.fr/12078.js">
 
</script>
 
</head>
<body onload="RunEorzeaClock(1325692136);">
 
	<style type="text/css">
        .MoonTime {
                color: #BABEBE;
                text-align: center;
        }
        .Moon {
                color: #BABEBE;
                text-align: center;
                vertical-align: bottom;
                padding: 0 3px;
        }
        .current_moon {
                font-weight: bold;
        }
        .moon_width {
                width: 69px;
        }
        #EorzeaTime {
                color: #BABEBE;
                text-align: center;
        }
        #leverefreshdiv {
                color: #BABEBE;
                text-align: center;
        }
        </style>
 
	<table style="width: 987px;margin: 0 auto;">
 
		<tr>
			<td class="moon_width">
				<div class="Moon"><img src="http://i45.servimg.com/u/f45/16/35/50/30/newm10.png" width="32px" /><div id="lunar_m1" class="MoonTime"></div></div>
			</td>
			<td class="moon_width">
				<div class="Moon"><img src="http://i45.servimg.com/u/f45/16/35/50/30/waxc10.png" width="32px" /><div id="lunar_m2" class="MoonTime"></div></div>
			</td>
			<td class="moon_width">
				<div class="Moon"><img src="http://i45.servimg.com/u/f45/16/35/50/30/firstq10.png" width="32px" /><div id="lunar_m3" class="MoonTime"></div></div>
 
			</td>
			<td class="moon_width">
				<div class="Moon"><img src="http://i45.servimg.com/u/f45/16/35/50/30/waxg10.png" width="32px" /><div id="lunar_m4" class="MoonTime"></div></div>
			</td>
			<td class="moon_width">
				<div class="Moon"><img src="http://i45.servimg.com/u/f45/16/35/50/30/fullm10.png" width="32px" /><div id="lunar_m5" class="MoonTime"></div></div>
			</td>
			<td class="moon_width">
				<div class="Moon"><img src="http://i45.servimg.com/u/f45/16/35/50/30/wang10.png" width="32px" /><div id="lunar_m6" class="MoonTime"></div></div>
 
			</td>
			<td class="moon_width">
				<div class="Moon"><img src="http://i45.servimg.com/u/f45/16/35/50/30/lastq10.png" width="32px" /><div id="lunar_m7" class="MoonTime"></div></div>
			</td>
			<td class="moon_width">
				<div class="Moon"><img src="http://i45.servimg.com/u/f45/16/35/50/30/wanc10.png" width="32px" /><div id="lunar_m8" class="MoonTime"></div></div>
			</td>
			<td class="Moon">
				<div class="Moon"><span class="current_moon">Eorzea Time:</span><div id="EorzeaTime"></div></div>
 
			</td>
			<td class="Moon">
				<div class="Moon"><span class="current_moon">Reset mandats:</span><div id="leverefreshdiv"></div></div>
			</td>
		</tr>
</table>
</body>

Et voici le script Javascript appelé :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
var timestamp;
var localTimestamp;
var ratio;
var formula;
var mooncount;
var offset2;
var moonstart;
var newmoon;
var waxcrescent;
var firstquarter;
var waxgibbous;
var fullmoon;
var wangibbous;
var lastquarter;
var wancrescent;
 
function RunEorzeaClock(serverTimestamp) {
 
    //Adjusting the time
    serverTimestamp = (serverTimestamp + 5) * 1000;
    //Setting timestamp to that of the server
    timestamp = serverTimestamp;
    //Settting local time stamp to current dates time
    localTimestamp = new Date().getTime();
    updateEorzeaTime();
 
    //Information for moonphases
    ratio = 1440 / 70;
    formula = 1000 * 60 * 60 * 24 * 4 / ratio;
    mooncount = new Date();
    offset2 = 21 - mooncount.getTimezoneOffset() / 60;
    moonstart = new Date(2010, 7, 15, offset2, 20, 0);
 
    newmoon = new Date(moonstart.getTime());
    waxcrescent = new Date(moonstart.getTime() + formula);
    firstquarter = new Date(moonstart.getTime() + formula * 2);
    waxgibbous = new Date(moonstart.getTime() + formula * 3);
    fullmoon = new Date(moonstart.getTime() + formula * 4);
    wangibbous = new Date(moonstart.getTime() + formula * 5);
    lastquarter = new Date(moonstart.getTime() + formula * 6);
    wancrescent = new Date(moonstart.getTime() + formula * 7);
 
    UpdateMoons();
 
    LeveRefresh();
 
}
 
function updateEorzeaTime() {
 
    var now = new Date();
 
    //Converting current time to Eorzean
    //getTime function returns UNIX UTC timestamp
    var tmpTime = ((timestamp + now.getTime() - localTimestamp) / 1000) * 4188615725;
 
    var EorzeanYear = parseInt(tmpTime / 562949953421312);
    EorzeanYear -= 9519;
    EorzeanYear /= 12;
    EorzeanYear = parseInt(EorzeanYear);
 
    var EorzeanMonth = parseInt(tmpTime / 562949953421312);
    EorzeanMonth = EorzeanMonth % 12;
    EorzeanMonth++;
    EorzeanMonth = parseInt(EorzeanMonth);
 
    var EorzeanDay = parseInt(tmpTime / 17592186044416);
    EorzeanDay &= 31;
    EorzeanDay++;
    EorzeanDay = parseInt(EorzeanDay);
 
    var tmpTime = ((timestamp + now.getTime() - localTimestamp) / 1000) * 24
    var EorzeanHour = parseInt(tmpTime / 4200);
    EorzeanHour %= 24;
 
    tmpTime = ((timestamp + now.getTime() - localTimestamp) / 1000) * 1440;
    var EorzeanMinute = parseInt(tmpTime / 4200);
    EorzeanMinute -= 10;
    EorzeanMinute %= 60;
 
    //adding '0' before hours and minutes if less than 10
    if (EorzeanHour < 10) EorzeanHour = "0" + EorzeanHour;
    if (EorzeanMinute < 10) EorzeanMinute = "0" + EorzeanMinute;
 
    document.getElementById("EorzeaTime").innerHTML = EorzeanHour + ':' + EorzeanMinute + ', ' + EorzeanMonth + '/' + EorzeanDay + '/' + EorzeanYear;
 
    t = setTimeout('updateEorzeaTime()', 1000);
}
 
function UpdateMoons() {
 
    //gets the value per moon
    var moon1 = LunarCalendarRefresh(newmoon, 'moon1');
    var moon2 = LunarCalendarRefresh(waxcrescent, 'moon2');
    var moon3 = LunarCalendarRefresh(firstquarter, 'moon3');
    var moon4 = LunarCalendarRefresh(waxgibbous, 'moon4');
    var moon5 = LunarCalendarRefresh(fullmoon, 'moon5');
    var moon6 = LunarCalendarRefresh(wangibbous, 'moon6');
    var moon7 = LunarCalendarRefresh(lastquarter, 'moon7');
    var moon8 = LunarCalendarRefresh(wancrescent, 'moon8');
 
    //transfer the content to the dom respectively
    if (document.getElementById("lunar_m1"))
        document.getElementById("lunar_m1").innerHTML = moon1;
    if (document.getElementById("lunar_m2"))
        document.getElementById("lunar_m2").innerHTML = moon2;
    if (document.getElementById("lunar_m3"))
        document.getElementById("lunar_m3").innerHTML = moon3;
    if (document.getElementById("lunar_m4"))
        document.getElementById("lunar_m4").innerHTML = moon4;
    if (document.getElementById("lunar_m5"))
        document.getElementById("lunar_m5").innerHTML = moon5;
    if (document.getElementById("lunar_m6"))
        document.getElementById("lunar_m6").innerHTML = moon6;
    if (document.getElementById("lunar_m7"))
        document.getElementById("lunar_m7").innerHTML = moon7;
    if (document.getElementById("lunar_m8"))
        document.getElementById("lunar_m8").innerHTML = moon8;
 
    //if moons' value is default then we need much faster refresh to get the proper time the soonest
    if (moon1 == '00 : 00 : 00' && moon2 == '00 : 00 : 00' && moon3 == '00 : 00 : 00' && moon4 == '00 : 00 : 00' && moon5 == '00 : 00 : 00' && moon6 == '00 : 00 : 00' && moon7 == '00 : 00 : 00' && moon8 == '00 : 00 : 00')
        m = setTimeout('UpdateMoons()', 1);
    else
        m = setTimeout('UpdateMoons()', 500);
}
 
function LunarCalendarRefresh(adjust, moon) {
    //00 : 00 : 00 set as the default value
    var value = '00 : 00 : 00';
    var now = new Date();
    // difference will be the countdown time for each moon
    difference = adjust.getTime() - (timestamp + now.getTime() - localTimestamp);
    if (difference > 0) {
        //translate to hours
        hours = Math.floor(difference / (60 * 60 * 1000));
        difference -= hours * 60 * 60 * 1000;
        //translate to min
        minutes = Math.floor(difference / (60 * 1000));
        difference -= minutes * 60 * 1000;
        //translate to sec
        seconds = Math.floor(difference / 1000);
 
        //if single digit then add padding-left '0'
        if (hours < 10) hours = "0" + hours;
        if (minutes < 10) minutes = "0" + minutes;
        if (seconds < 10) seconds = "0" + seconds;
 
        value = hours + " : " + minutes + " : " + seconds;
    }
    else {
        if ((adjust.getTime() + formula) < (timestamp + now.getTime() - localTimestamp)) {
            temp = adjust.getTime();
            adjust.setTime(temp + formula * 8);
        }
        else {
            //if difference <= 0 then the moon will be the current moon
            value = '<span class="current_moon">&nbsp&nbsp;&nbsp;&nbsp;Current&nbsp;&nbsp;&nbsp;</span>';
            //change the big moon current
            if (document.getElementById("lb_lunar_calendar_icon"))
                document.getElementById("lb_lunar_calendar_icon").className = 'icon ' + moon;
            //change the langbar moon current
            if (document.getElementById("moon_image"))
                document.getElementById("moon_image").className = 'moon ' + moon;
        }
    }
    return value;
}
 
function LeveRefresh() {
    var now = new Date();
    //compute time passed between a UNIX timestamp when we had a guild refresh and the current UNIX timestamp
    var difference = (timestamp + now.getTime() - localTimestamp) - Date.UTC(2010, 11, 10, 12);
    if (isNaN(difference))
        return;
 
    //resets happens every 36 hrs, so find out how many resets we had in the passed time
    var resetsSoFar = Math.floor(difference / (12 * 60 * 60 * 1000));
    //compute the next reset
    var nextReset = (resetsSoFar + 1) * 12 * 60 * 60 * 1000;
    //next reset will occur in
    difference = nextReset - difference;
 
    //translate to hours
    var hours = Math.floor(difference / (60 * 60 * 1000));
    difference -= hours * 60 * 60 * 1000;
    //translate to min
    var minutes = Math.floor(difference / (60 * 1000));
    difference -= minutes * 60 * 1000;
    //translate to sec
    var seconds = Math.floor(difference / 1000);
 
    //if single digit then add padding-left '0'
    if (hours < 10) hours = "0" + hours;
    if (minutes < 10) minutes = "0" + minutes;
    if (seconds < 10) seconds = "0" + seconds;
 
    //refresh the lunar clock with current value
    if (document.getElementById("leverefreshdiv"))
        document.getElementById("leverefreshdiv").innerHTML = hours + "h " + minutes + "m " + seconds + "s";
 
    setTimeout('LeveRefresh()', 200);
}