Commit | Line | Data |
---|---|---|
0337d704 | 1 | /*************************************************************************** |
5e1513f6 | 2 | * Copyright (C) 2003-2011 Polytechnique.org * |
0337d704 | 3 | * http://opensource.polytechnique.org/ * |
4 | * * | |
5 | * This program is free software; you can redistribute it and/or modify * | |
6 | * it under the terms of the GNU General Public License as published by * | |
7 | * the Free Software Foundation; either version 2 of the License, or * | |
8 | * (at your option) any later version. * | |
9 | * * | |
10 | * This program 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 General Public License for more details. * | |
14 | * * | |
15 | * You should have received a copy of the GNU General Public License * | |
16 | * along with this program; if not, write to the Free Software * | |
17 | * Foundation, Inc., * | |
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
19 | ***************************************************************************/ | |
20 | ||
0337d704 | 21 | // {{{ function getNow() |
80dcbd9a FB |
22 | var days = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi']; |
23 | var months = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', | |
34cc65fd | 24 | 'août', 'septembre', 'octobre', 'novembre', 'décembre']; |
0337d704 | 25 | |
0337d704 | 26 | function getNow() { |
80dcbd9a FB |
27 | var dt = new Date(); |
28 | var dy = dt.getDay(); | |
29 | var mh = dt.getMonth(); | |
30 | var wd = dt.getDate(); | |
31 | var yr = dt.getYear(); | |
80dcbd9a FB |
32 | var hr = dt.getHours(); |
33 | var mi = dt.getMinutes(); | |
34cc65fd FB |
34 | var se = dt.getSeconds(); |
35 | ||
36 | if (yr<1000) { | |
37 | yr += 1900; | |
38 | } | |
80dcbd9a FB |
39 | if (mi < 10) { |
40 | mi = '0' + mi; | |
41 | } | |
80dcbd9a FB |
42 | if (se < 10) { |
43 | se = '0' + se; | |
44 | } | |
9f449375 | 45 | |
80dcbd9a FB |
46 | $(".date-heure").html(days[dy] + ' ' + wd + ' ' + months[mh] + ' ' + yr + '<br />' |
47 | + hr + ':' + mi + ':' + se); | |
9f449375 | 48 | } |
49 | ||
50 | // }}} | |
a27c6df8 | 51 | // {{{ Search Engine |
52 | ||
53 | function canAddSearchEngine() | |
54 | { | |
34cc65fd FB |
55 | if (((typeof window.sidebar === "object") && $.isFunction(window.sidebar.addSearchEngine)) |
56 | || ((typeof window.external === "object") && $.isFunction(window.external.AddSearchProvider))) { | |
350ba5ac FB |
57 | return true; |
58 | } | |
59 | return false; | |
a27c6df8 | 60 | } |
39fd8f50 | 61 | |
b09e5dea | 62 | function addSearchEngine() |
63 | { | |
350ba5ac | 64 | var searchURI = "http://www.polytechnique.org/xorg.opensearch.xml"; |
34cc65fd | 65 | if ((typeof window.sidebar === "object") && $.isFunction(window.sidebar.addSearchEngine)) { |
350ba5ac FB |
66 | window.sidebar.addSearchEngine( |
67 | searchURI, | |
68 | "http://www.polytechnique.org/images/xorg.png", | |
69 | "Annuaire Polytechnique.org", | |
70 | "Academic"); | |
71 | } else { | |
72 | try { | |
73 | window.external.AddSearchProvider(searchURI); | |
74 | } catch(e) { | |
75 | alert("Impossible d'installer la barre de recherche"); | |
76 | } | |
b09e5dea | 77 | } |
39fd8f50 | 78 | } |
79 | ||
39fd8f50 | 80 | // }}} |
0337d704 | 81 | |
82 | /*************************************************************************** | |
83 | * POPUP THINGS | |
84 | */ | |
85 | ||
769dc7d5 VZ |
86 | // {{{ function goodiesPopup() |
87 | ||
048c44a3 FB |
88 | (function($) { |
89 | var goodies = { | |
90 | ical: { | |
91 | default_title: 'Calendrier iCal', | |
92 | sites: [ | |
93 | {url_prefix: '', | |
94 | img: 'images/icons/calendar_view_day.gif', | |
95 | title: 'Calendrier iCal'}, | |
96 | {url_prefix: 'http://www.google.com/calendar/render?cid=', | |
97 | img: 'images/goodies/add-google-calendar.gif', | |
98 | title: 'Ajouter à Google Calendar'}, | |
99 | {url_prefix: 'https://www.google.com/calendar/hosted/polytechnique.org/render?cid=', | |
100 | img: 'images/goodies/add-google-calendar.gif', | |
101 | title: 'Ajouter à Google Apps / Calendar'} | |
102 | ] | |
103 | }, | |
104 | ||
105 | rss: { | |
106 | default_title: 'Fils RSS', | |
107 | sites: [ | |
108 | {url_prefix: '', | |
109 | img: 'images/icons/feed.gif', | |
110 | title: 'Fil rss'}, | |
111 | {url_prefix: 'http://fusion.google.com/add?feedurl=', | |
112 | img: 'images/goodies/add-google.gif', | |
113 | alt: 'Add to Google', | |
114 | title: 'Ajouter à iGoogle/Google Reader'}, | |
115 | {url_prefix: 'http://www.netvibes.com/subscribe.php?url=', | |
116 | img: 'images/goodies/add-netvibes.gif', | |
117 | title: 'Ajouter à Netvibes'}, | |
118 | {url_prefix: 'http://add.my.yahoo.com/content?.intl=fr&url=', | |
119 | img: 'images/goodies/add-yahoo.gif', | |
120 | alt: 'Add to My Yahoo!', | |
121 | title: 'Ajouter à My Yahoo!'} | |
122 | ] | |
123 | } | |
124 | }; | |
125 | ||
126 | $.fn.extend({ | |
127 | goodiesPopup: function goodiesPopup(type) { | |
128 | var text = '<div style="text-align: center; line-height: 2.2">'; | |
34cc65fd FB |
129 | var site; |
130 | var entry; | |
131 | var s_alt; | |
132 | var s_img; | |
133 | var s_title; | |
134 | var s_url; | |
135 | ||
136 | for (site in goodies[type].sites) { | |
137 | entry = goodies[type].sites[site]; | |
138 | s_alt = entry.alt || ""; | |
139 | s_img = entry.img; | |
140 | s_title = entry.title || ""; | |
141 | s_url = entry.url_prefix.length > 0 ? entry.url_prefix + escape(this.href) : this.href; | |
048c44a3 FB |
142 | |
143 | text += '<a href="' + s_url + '"><img src="' + s_img + '" title="' + s_title + '" alt="' + s_alt + '"></a><br />'; | |
144 | } | |
145 | text += '<a href="https://www.polytechnique.org/Xorg/Goodies">Plus de bonus</a> ...</div>'; | |
769dc7d5 | 146 | |
048c44a3 FB |
147 | return this.overlib({ |
148 | text: text, | |
34cc65fd | 149 | caption: this.attr('title') || goodies.default_title, |
048c44a3 FB |
150 | close_text: 'Fermer', |
151 | delay: 800, | |
152 | sticky: true, | |
153 | width: 150 | |
154 | }); | |
155 | } | |
156 | }); | |
157 | }(jQuery)); | |
769dc7d5 VZ |
158 | |
159 | // }}} | |
0337d704 | 160 | // {{{ function auto_links() |
161 | ||
0337d704 | 162 | function auto_links() { |
80dcbd9a FB |
163 | var url = document.URL; |
164 | var fqdn = url.replace(/^https?:\/\/([^\/]*)\/.*$/,'$1'); | |
63c89179 FB |
165 | var light = url.indexOf('display=light') > url.indexOf('?'); |
166 | var resource_page = url.contains('rss') || url.contains('ical'); | |
e83d83e8 | 167 | |
b804b882 FB |
168 | $("a,link").each(function(i) { |
169 | var node = $(this); | |
170 | var href = this.href; | |
63c89179 FB |
171 | var matches; |
172 | var rss; | |
173 | var ical; | |
174 | ||
b804b882 | 175 | if(!href || node.hasClass('xdx') |
63c89179 | 176 | || href.startsWith('mailto:') || href.startsWith('javascript:')) { |
b804b882 FB |
177 | return; |
178 | } | |
63c89179 | 179 | if ((!href.contains(fqdn) && !this.className.contains('popup')) || node.hasClass('popup')) { |
b804b882 FB |
180 | node.click(function () { |
181 | window.open(href); | |
182 | return false; | |
183 | }); | |
184 | } | |
63c89179 | 185 | if (href.contains(fqdn) && light) { |
b804b882 FB |
186 | href = href.replace(/([^\#\?]*)\??([^\#]*)(\#.*)?/, "$1?display=light&$2$3"); |
187 | this.href = href; | |
188 | } | |
63c89179 FB |
189 | rss = href.contains('rss'); |
190 | ical = href.contains('ical'); | |
b804b882 | 191 | if (rss || ical) { |
63c89179 | 192 | if (!href.startsWith('http')) { |
b804b882 | 193 | href = 'http://' + fqdn + '/' + href; |
e83d83e8 | 194 | } |
b804b882 | 195 | } |
34cc65fd | 196 | if (this.nodeName.toLowerCase() === 'a' && !resource_page) { |
63c89179 | 197 | if (rss && !href.contains('prefs/rss') && (href.contains('xml') || href.contains('hash'))) { |
048c44a3 | 198 | node.goodiesPopup('rss'); |
b804b882 | 199 | } else if (ical) { |
048c44a3 | 200 | node.goodiesPopup('ical'); |
769dc7d5 | 201 | } |
3def38d5 | 202 | } |
34cc65fd FB |
203 | matches = /^popup_([0-9]*)x([0-9]*)$/.exec(this.className); |
204 | if (matches) { | |
205 | node.popWin(matches[1], matches[2]); | |
b804b882 FB |
206 | } |
207 | }); | |
208 | $('.popup2').popWin(840, 600); | |
209 | $('.popup3').popWin(640, 800); | |
0337d704 | 210 | } |
211 | ||
e83d83e8 | 212 | |
0337d704 | 213 | // }}} |
214 | ||
7143ad2b FB |
215 | /*************************************************************************** |
216 | * Password check | |
217 | */ | |
218 | ||
219 | // {{{ function checkPassword | |
220 | ||
5ff39ae1 FB |
221 | /* {{{ SHA1 Implementation */ |
222 | ||
223 | /* | |
224 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined | |
225 | * in FIPS PUB 180-1 | |
226 | * Version 2.1a Copyright Paul Johnston 2000 - 2002. | |
227 | * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet | |
228 | * Distributed under the BSD License | |
229 | * See http://pajhome.org.uk/crypt/md5 for details. | |
230 | */ | |
231 | ||
232 | /* | |
233 | * Configurable variables. You may need to tweak these to be compatible with | |
234 | * the server-side, but the defaults work in most cases. | |
235 | */ | |
236 | var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ | |
237 | var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ | |
238 | var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ | |
239 | ||
240 | /* | |
241 | * These are the functions you'll usually want to call | |
242 | * They take string arguments and return either hex or base-64 encoded strings | |
243 | */ | |
244 | function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));} | |
245 | function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));} | |
246 | function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));} | |
247 | function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));} | |
248 | function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));} | |
249 | function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));} | |
250 | ||
251 | /* | |
252 | * Perform a simple self-test to see if the VM is working | |
253 | */ | |
254 | function sha1_vm_test() | |
255 | { | |
34cc65fd | 256 | return hex_sha1("abc") === "a9993e364706816aba3e25717850c26c9cd0d89d"; |
5ff39ae1 FB |
257 | } |
258 | ||
259 | /* | |
260 | * Calculate the SHA-1 of an array of big-endian words, and a bit length | |
261 | */ | |
262 | function core_sha1(x, len) | |
263 | { | |
34cc65fd FB |
264 | var w, a, b, c, d, e; |
265 | var olda, oldb, oldc, oldd, olde; | |
266 | var i, j, t; | |
267 | ||
5ff39ae1 FB |
268 | /* append padding */ |
269 | x[len >> 5] |= 0x80 << (24 - len % 32); | |
270 | x[((len + 64 >> 9) << 4) + 15] = len; | |
271 | ||
34cc65fd FB |
272 | w = Array(80); |
273 | a = 1732584193; | |
274 | b = -271733879; | |
275 | c = -1732584194; | |
276 | d = 271733878; | |
277 | e = -1009589776; | |
5ff39ae1 | 278 | |
34cc65fd | 279 | for(i = 0; i < x.length; i += 16) |
5ff39ae1 | 280 | { |
34cc65fd FB |
281 | olda = a; |
282 | oldb = b; | |
283 | oldc = c; | |
284 | oldd = d; | |
285 | olde = e; | |
5ff39ae1 | 286 | |
34cc65fd | 287 | for(j = 0; j < 80; j++) |
5ff39ae1 FB |
288 | { |
289 | if(j < 16) w[j] = x[i + j]; | |
290 | else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1); | |
34cc65fd | 291 | t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), |
5ff39ae1 FB |
292 | safe_add(safe_add(e, w[j]), sha1_kt(j))); |
293 | e = d; | |
294 | d = c; | |
295 | c = rol(b, 30); | |
296 | b = a; | |
297 | a = t; | |
298 | } | |
299 | ||
300 | a = safe_add(a, olda); | |
301 | b = safe_add(b, oldb); | |
302 | c = safe_add(c, oldc); | |
303 | d = safe_add(d, oldd); | |
304 | e = safe_add(e, olde); | |
305 | } | |
306 | return Array(a, b, c, d, e); | |
307 | ||
308 | } | |
309 | ||
310 | /* | |
311 | * Perform the appropriate triplet combination function for the current | |
312 | * iteration | |
313 | */ | |
314 | function sha1_ft(t, b, c, d) | |
315 | { | |
316 | if(t < 20) return (b & c) | ((~b) & d); | |
317 | if(t < 40) return b ^ c ^ d; | |
318 | if(t < 60) return (b & c) | (b & d) | (c & d); | |
319 | return b ^ c ^ d; | |
320 | } | |
321 | ||
322 | /* | |
323 | * Determine the appropriate additive constant for the current iteration | |
324 | */ | |
325 | function sha1_kt(t) | |
326 | { | |
327 | return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : | |
328 | (t < 60) ? -1894007588 : -899497514; | |
329 | } | |
330 | ||
331 | /* | |
332 | * Calculate the HMAC-SHA1 of a key and some data | |
333 | */ | |
334 | function core_hmac_sha1(key, data) | |
335 | { | |
336 | var bkey = str2binb(key); | |
34cc65fd FB |
337 | var i, ipad, opad; |
338 | var hash; | |
339 | ||
5ff39ae1 FB |
340 | if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz); |
341 | ||
34cc65fd FB |
342 | ipad = Array(16); |
343 | opad = Array(16); | |
344 | for(i = 0; i < 16; i++) | |
5ff39ae1 FB |
345 | { |
346 | ipad[i] = bkey[i] ^ 0x36363636; | |
347 | opad[i] = bkey[i] ^ 0x5C5C5C5C; | |
348 | } | |
349 | ||
34cc65fd | 350 | hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz); |
5ff39ae1 FB |
351 | return core_sha1(opad.concat(hash), 512 + 160); |
352 | } | |
353 | ||
354 | /* | |
355 | * Add integers, wrapping at 2^32. This uses 16-bit operations internally | |
356 | * to work around bugs in some JS interpreters. | |
357 | */ | |
358 | function safe_add(x, y) | |
359 | { | |
360 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); | |
361 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); | |
362 | return (msw << 16) | (lsw & 0xFFFF); | |
363 | } | |
364 | ||
365 | /* | |
366 | * Bitwise rotate a 32-bit number to the left. | |
367 | */ | |
368 | function rol(num, cnt) | |
369 | { | |
370 | return (num << cnt) | (num >>> (32 - cnt)); | |
371 | } | |
372 | ||
373 | /* | |
374 | * Convert an 8-bit or 16-bit string to an array of big-endian words | |
375 | * In 8-bit function, characters >255 have their hi-byte silently ignored. | |
376 | */ | |
377 | function str2binb(str) | |
378 | { | |
379 | var bin = Array(); | |
380 | var mask = (1 << chrsz) - 1; | |
34cc65fd FB |
381 | var i; |
382 | for(i = 0; i < str.length * chrsz; i += chrsz) | |
5ff39ae1 FB |
383 | bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32); |
384 | return bin; | |
385 | } | |
386 | ||
387 | /* | |
388 | * Convert an array of big-endian words to a string | |
389 | */ | |
390 | function binb2str(bin) | |
391 | { | |
392 | var str = ""; | |
393 | var mask = (1 << chrsz) - 1; | |
34cc65fd FB |
394 | var i; |
395 | for(i = 0; i < bin.length * 32; i += chrsz) | |
5ff39ae1 FB |
396 | str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask); |
397 | return str; | |
398 | } | |
399 | ||
400 | /* | |
401 | * Convert an array of big-endian words to a hex string. | |
402 | */ | |
403 | function binb2hex(binarray) | |
404 | { | |
405 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; | |
406 | var str = ""; | |
34cc65fd FB |
407 | var i; |
408 | for(i = 0; i < binarray.length * 4; i++) | |
5ff39ae1 FB |
409 | { |
410 | str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + | |
411 | hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); | |
412 | } | |
413 | return str; | |
414 | } | |
415 | ||
416 | /* | |
417 | * Convert an array of big-endian words to a base-64 string | |
418 | */ | |
419 | function binb2b64(binarray) | |
420 | { | |
421 | var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
422 | var str = ""; | |
34cc65fd FB |
423 | var i, j, triplet; |
424 | for(i = 0; i < binarray.length * 4; i += 3) | |
5ff39ae1 | 425 | { |
34cc65fd | 426 | triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16) |
5ff39ae1 FB |
427 | | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 ) |
428 | | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF); | |
34cc65fd | 429 | for(j = 0; j < 4; j++) |
5ff39ae1 FB |
430 | { |
431 | if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; | |
432 | else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); | |
433 | } | |
434 | } | |
435 | return str; | |
436 | } | |
437 | ||
438 | /* }}} */ | |
439 | ||
440 | function hash_encrypt(a) { | |
441 | return hex_sha1(a); | |
442 | } | |
443 | ||
444 | var hexa_h = "0123456789abcdef"; | |
445 | ||
446 | function dechex(a) { | |
447 | return hexa_h.charAt(a); | |
448 | } | |
449 | ||
450 | function hexdec(a) { | |
451 | return hexa_h.indexOf(a); | |
452 | } | |
453 | ||
454 | function hash_xor(a, b) { | |
34cc65fd | 455 | var c,i,j,k,d; |
5ff39ae1 FB |
456 | c = ""; |
457 | i = a.length; | |
458 | j = b.length; | |
459 | if (i < j) { | |
5ff39ae1 FB |
460 | d = a; a = b; b = d; |
461 | k = i; i = j; j = k; | |
462 | } | |
34cc65fd | 463 | for (k = 0; k < j; k++) { |
5ff39ae1 | 464 | c += dechex(hexdec(a.charAt(k)) ^ hexdec(b.charAt(k))); |
34cc65fd FB |
465 | } |
466 | for (; k < i; k++) { | |
5ff39ae1 | 467 | c += a.charAt(k); |
34cc65fd | 468 | } |
5ff39ae1 FB |
469 | return c; |
470 | } | |
471 | ||
0ba43ee4 VZ |
472 | function getType(c) { |
473 | if (c >= 'a' && c <= 'z') { | |
7143ad2b | 474 | return 1; |
0ba43ee4 | 475 | } else if (c >= 'A' && c <= 'Z') { |
7143ad2b | 476 | return 2; |
0ba43ee4 | 477 | } else if (c >= '0' && c <= '9') { |
7143ad2b FB |
478 | return 3; |
479 | } else { | |
480 | return 4; | |
481 | } | |
482 | } | |
483 | ||
4baa7323 | 484 | function differentTypes(password) { |
7143ad2b | 485 | var prev = 0; |
34cc65fd | 486 | var type; |
4baa7323 SJ |
487 | |
488 | for (i = 0 ; i < password.length ; ++i) { | |
34cc65fd FB |
489 | type = getType(password.charAt(i)); |
490 | if (prev !== 0 && prev !== type) { | |
4baa7323 SJ |
491 | return true; |
492 | } | |
493 | prev = type; | |
494 | } | |
495 | return false; | |
496 | } | |
497 | ||
498 | function passwordStrength(password) { | |
7143ad2b | 499 | var prop = 0; |
4baa7323 | 500 | var prev = 0; |
eaa3f284 | 501 | var firstType = true; |
4baa7323 | 502 | var types = Array(0, 0, 0, 0, 0); |
34cc65fd | 503 | var type; |
4baa7323 SJ |
504 | |
505 | for (i = 0 ; i < password.length ; ++i) { | |
34cc65fd FB |
506 | type = getType(password.charAt(i)); |
507 | if (prev !== 0 && prev !== type) { | |
7143ad2b | 508 | prop += 5; |
4baa7323 | 509 | firstType = false; |
7143ad2b | 510 | } |
eaa3f284 | 511 | prop += i; |
34cc65fd | 512 | if (types[type] === 0 && !firstType) { |
eaa3f284 | 513 | prop += 15; |
7143ad2b FB |
514 | } |
515 | types[type]++; | |
516 | prev = type; | |
517 | } | |
4baa7323 SJ |
518 | if (password.length < 6) { |
519 | prop *= 0.75; | |
520 | } | |
521 | if (firstType) { | |
aca1582e | 522 | prop *= 0.75; |
eaa3f284 | 523 | } |
7143ad2b FB |
524 | if (prop > 100) { |
525 | prop = 100; | |
526 | } else if (prop < 0) { | |
527 | prop = 0; | |
528 | } | |
4baa7323 SJ |
529 | |
530 | return prop; | |
531 | } | |
532 | ||
533 | function checkPassword(box, okLabel) { | |
534 | var password = box.value; | |
535 | var prop = passwordStrength(password); | |
34cc65fd | 536 | var submitButton; |
4baa7323 | 537 | |
de99248c | 538 | if (prop >= 60) { |
00681970 FB |
539 | color = "#4f4"; |
540 | bgcolor = "#050"; | |
de99248c | 541 | ok = true; |
23f6d4cc | 542 | } else if (prop >= 35) { |
de99248c | 543 | color = "#ff4"; |
00681970 | 544 | bgcolor = "#750"; |
b19839fd | 545 | ok = true; |
de99248c FB |
546 | } else { |
547 | color = "#f20"; | |
00681970 | 548 | bgcolor = "#700"; |
de99248c FB |
549 | ok = false; |
550 | } | |
551 | $("#passwords_measure") | |
00681970 FB |
552 | .stop() |
553 | .animate({ width: prop + "%", | |
554 | backgroundColor: color | |
555 | }, 750) | |
556 | .parent().stop() | |
557 | .animate({ backgroundColor: bgcolor }, 750); | |
34cc65fd | 558 | submitButton = $(":submit[name='" + passwordprompt_submit + "']"); |
4baa7323 | 559 | if (ok && password.length >= 6 && differentTypes(password)) { |
7b7d0970 | 560 | submitButton.attr("value", okLabel); |
de99248c | 561 | submitButton.removeAttr("disabled"); |
7143ad2b | 562 | } else { |
7b7d0970 | 563 | submitButton.attr("value", "Mot de passe trop faible"); |
de99248c | 564 | submitButton.attr("disabled", "disabled"); |
7143ad2b FB |
565 | } |
566 | } | |
567 | ||
5ff39ae1 | 568 | function hashResponse(password1, password2, hasConfirmation) { |
34cc65fd FB |
569 | var pw1 = $('[name=' + password1 + ']').val(); |
570 | var pw2; | |
5ff39ae1 FB |
571 | |
572 | if (hasConfirmation) { | |
573 | pw2 = $('[name=' + password2 + ']').val(); | |
34cc65fd | 574 | if (pw1 !== pw2) { |
5ff39ae1 FB |
575 | alert("\nErreur : les deux champs ne sont pas identiques !"); |
576 | return false; | |
577 | } | |
578 | $('[name=' + password2 + ']').val(''); | |
34cc65fd | 579 | } else if (pw1 === '********') { |
5ff39ae1 FB |
580 | return true; |
581 | } | |
582 | ||
583 | if (pw1.length < 6) { | |
584 | alert("\nErreur : le nouveau mot de passe doit faire au moins 6 caractères !"); | |
585 | return false; | |
586 | } | |
587 | if (!differentTypes(pw1)) { | |
588 | alert ("\nErreur : le nouveau mot de passe doit comporter au moins deux types de caractères parmi les suivants : lettres minuscules, lettres majuscules, chiffres, caractères spéciaux."); | |
589 | return false; | |
590 | } | |
591 | ||
592 | alert("Le mot de passe que tu as rentré va être chiffré avant de nous parvenir par Internet ! Ainsi il ne circulera pas en clair."); | |
593 | $('[name=' + password1 + ']').val(''); | |
594 | $('[name=pwhash]').val(hash_encrypt(pw1)); | |
595 | return true; | |
596 | } | |
597 | ||
598 | function correctUserName() { | |
599 | var u = document.forms.login.username; | |
34cc65fd FB |
600 | var mots; |
601 | ||
5ff39ae1 | 602 | // login with no space |
460098c8 | 603 | if (!u.value.contains(' ')) { |
34cc65fd FB |
604 | return true; |
605 | } | |
606 | mots = u.value.split(' '); | |
5ff39ae1 | 607 | // jean paul.du pont -> jean-paul.du-pont |
460098c8 | 608 | if (u.value.contains('.')) { |
34cc65fd FB |
609 | u.value = mots.join('-'); |
610 | return true; | |
611 | } | |
5ff39ae1 | 612 | // jean dupont -> jean.dupont |
34cc65fd FB |
613 | if (mots.length === 2) { |
614 | u.value = mots[0] + "." + mots[1]; | |
615 | return true; | |
616 | } | |
5ff39ae1 | 617 | // jean dupont 2001 -> jean.dupont.2001 |
34cc65fd FB |
618 | if (mots.length === 3 && mots[2] > 1920 && mots[2] < 3000) { |
619 | u.value = mots.join('.'); | |
620 | return true; | |
621 | } | |
5ff39ae1 | 622 | // jean de la vallee -> jean.de-la-vallee |
34cc65fd FB |
623 | if (mots[1].toUpperCase() === 'DE') { |
624 | u.value = mots[0] + "." + mots.join('-').substr(mots[0].length+1); | |
625 | return true; | |
626 | } | |
5ff39ae1 | 627 | // jean paul dupont -> jean-paul.dupont |
34cc65fd FB |
628 | if (mots.length === 3 && mots[0].toUpperCase() === 'JEAN') { |
629 | u.value = mots[0] + "-" + mots[1] + "." + mots[2]; | |
630 | return true; | |
631 | } | |
5ff39ae1 FB |
632 | |
633 | alert('Ton email ne doit pas contenir de blanc.\nLe format standard est\n\nprenom.nom.promotion\n\nSi ton nom ou ton prenom est composé,\nsépare les mots par des -'); | |
634 | ||
635 | return false; | |
636 | } | |
637 | ||
638 | function doChallengeResponse() { | |
34cc65fd | 639 | var new_pass, old_pass, str; |
5ff39ae1 | 640 | |
34cc65fd FB |
641 | if (!correctUserName()) { |
642 | return false; | |
643 | } | |
5ff39ae1 | 644 | |
34cc65fd FB |
645 | new_pass = hash_encrypt(document.forms.login.password.value); |
646 | old_pass = hash_encrypt(document.forms.login.password.value.substr(0, 10)); | |
5ff39ae1 FB |
647 | |
648 | str = document.forms.login.username.value + ":" + | |
649 | new_pass + ":" + | |
650 | document.forms.loginsub.challenge.value; | |
651 | ||
652 | document.forms.loginsub.response.value = hash_encrypt(str); | |
34cc65fd | 653 | if (new_pass !== old_pass) { |
5ff39ae1 FB |
654 | document.forms.loginsub.xorpass.value = hash_xor(new_pass, old_pass); |
655 | } | |
656 | document.forms.loginsub.username.value = document.forms.login.username.value; | |
657 | document.forms.loginsub.remember.value = document.forms.login.remember.checked; | |
658 | document.forms.loginsub.domain.value = document.forms.login.domain.value; | |
659 | document.forms.login.password.value = ""; | |
660 | document.forms.loginsub.submit(); | |
661 | } | |
662 | ||
663 | function doChallengeResponseLogged() { | |
34cc65fd | 664 | var str = document.forms.loginsub.username.value + ":" + |
5ff39ae1 FB |
665 | hash_encrypt(document.forms.login.password.value) + ":" + |
666 | document.forms.loginsub.challenge.value; | |
667 | ||
668 | document.forms.loginsub.response.value = hash_encrypt(str); | |
669 | document.forms.loginsub.remember.value = document.forms.login.remember.checked; | |
670 | document.forms.login.password.value = ""; | |
671 | document.forms.loginsub.submit(); | |
672 | } | |
673 | ||
7143ad2b | 674 | // }}} |
b0e935d6 FB |
675 | // {{{ send test email |
676 | ||
677 | function sendTestEmail(token, hruid) | |
678 | { | |
679 | var url = 'emails/test'; | |
680 | var msg = "Un email a été envoyé avec succès"; | |
34cc65fd | 681 | if (hruid) { |
b0e935d6 FB |
682 | url += '/' + hruid; |
683 | msg += " sur l'adresse de " + hruid + "."; | |
684 | } else { | |
685 | msg += " sur ton addresse."; | |
686 | } | |
687 | $('#mail_sent').successMessage($url + '?token=' + token, msg); | |
688 | return false; | |
689 | } | |
690 | ||
691 | // }}} | |
6a686adb FB |
692 | // {{{ jQuery object extension |
693 | ||
694 | (function($) { | |
102f3fc2 FB |
695 | /* Add new functions to jQuery namesapce */ |
696 | $.extend({ | |
063410c8 FB |
697 | /* The goal of the following functions is to provide an AJAX API that |
698 | * take a different callback in case of HTTP success code (2XX) and in | |
699 | * other cases. | |
700 | */ | |
701 | ||
102f3fc2 FB |
702 | xajax: function(source, method, data, onSuccess, onError, type) { |
703 | /* Shift argument */ | |
704 | if ($.isFunction(data)) { | |
705 | type = type || onError; | |
706 | onError = onSuccess; | |
707 | onSuccess = data; | |
708 | data = null; | |
6a686adb | 709 | } |
102f3fc2 FB |
710 | if (onError != null && !$.isFunction(onError)) { |
711 | type = type || onError; | |
712 | onError = null; | |
6a686adb | 713 | } |
6a686adb | 714 | |
102f3fc2 FB |
715 | function ajaxHandler(data, textStatus, xhr) { |
716 | if (textStatus == 'success') { | |
717 | if (onSuccess) { | |
718 | onSuccess(data, textStatus, xhr); | |
719 | } | |
720 | } else if (textStatus == 'error') { | |
721 | if (onError) { | |
722 | onError(data, textStatus, xhr); | |
723 | } else { | |
724 | alert("Une error s'est produite lors du traitement de la requête.\n" | |
725 | + "Ta session a peut-être expiré"); | |
726 | } | |
727 | } | |
728 | } | |
729 | return $.ajax({ | |
730 | url: source, | |
731 | type: method, | |
732 | success: ajaxHandler, | |
733 | data : data, | |
734 | dataType: type | |
735 | }); | |
736 | }, | |
737 | ||
738 | xget: function(source, data, onSuccess, onError, type) { | |
739 | return $.xajax(source, 'GET', data, onSuccess, onError, type); | |
740 | }, | |
741 | ||
742 | xgetJSON: function(source, data, onSuccess, onError) { | |
743 | return $.xget(source, data, onSuccess, onError, 'json'); | |
744 | }, | |
745 | ||
746 | xgetScript: function(source, onSuccess, onError) { | |
747 | return $.xget(source, null, onSuccess, onError, 'script'); | |
748 | }, | |
749 | ||
063410c8 FB |
750 | xgetText: function(source, data, onSuccess, onError) { |
751 | return $.xget(source, data, onSuccess, onError, 'text'); | |
752 | }, | |
753 | ||
102f3fc2 FB |
754 | xpost: function(source, data, onSuccess, onError, type) { |
755 | return $.xajax(source, 'POST', data, onSuccess, onError, type); | |
6a686adb | 756 | } |
102f3fc2 FB |
757 | }); |
758 | ||
759 | /* Add new functions to jQuery objects */ | |
760 | $.fn.extend({ | |
761 | tmpMessage: function(message, success) { | |
762 | if (success) { | |
763 | this.html("<img src='images/icons/wand.gif' alt='' /> " + message) | |
764 | .css('color', 'green'); | |
765 | } else { | |
766 | this.html("<img src='images/icons/error.gif' alt='' /> " + message) | |
767 | .css('color', 'red'); | |
768 | } | |
769 | return this.css('fontWeight', 'bold') | |
770 | .show() | |
771 | .delay(1000) | |
772 | .fadeOut(500); | |
773 | }, | |
774 | ||
775 | updateHtml: function(source, callback) { | |
776 | var elements = this; | |
777 | function handler(data) { | |
778 | elements.html(data); | |
779 | if (callback) { | |
780 | callback(data); | |
781 | } | |
782 | } | |
783 | $.xget(source, handler, 'text'); | |
784 | return this; | |
785 | }, | |
786 | ||
787 | successMessage: function(source, message) { | |
788 | var elements = this; | |
789 | $.xget(source, function() { | |
790 | elements.tmpMessage(message, true); | |
791 | }); | |
792 | return this; | |
793 | }, | |
794 | ||
795 | wiki: function(text, withTitle) { | |
796 | if (text == '') { | |
797 | return this.html(''); | |
798 | } | |
799 | var url = 'wiki_preview'; | |
800 | if (!withTitle) { | |
801 | url += '/notitile'; | |
802 | } | |
803 | var $this = this; | |
804 | $.post(url, { text: text }, | |
805 | function (data) { | |
806 | $this.html(data); | |
807 | }, 'text'); | |
808 | return this; | |
063410c8 FB |
809 | }, |
810 | ||
811 | popWin: function(w, h) { | |
812 | return this.click(function() { | |
813 | window.open(this.href, '_blank', | |
814 | 'toolbar=0,location=0,directories=0,status=0,' | |
815 | +'menubar=0,scrollbars=1,resizable=1,' | |
816 | +'width='+w+',height='+h); | |
817 | return false; | |
818 | }); | |
6a686adb | 819 | } |
102f3fc2 | 820 | }); |
6a686adb FB |
821 | })(jQuery); |
822 | ||
823 | // }}} | |
824 | // {{{ preview wiki | |
825 | ||
826 | function previewWiki(idFrom, idTo, withTitle, idShow) | |
827 | { | |
828 | $('#' + idTo).wiki($('#' + idFrom).val(), withTitle); | |
829 | if (idShow != null) { | |
830 | $('#' + idShow).show(); | |
831 | } | |
832 | } | |
833 | ||
834 | // }}} | |
835 | // {{{ send test email | |
836 | ||
837 | function sendTestEmail(token, hruid) | |
838 | { | |
839 | var url = 'emails/test'; | |
840 | var msg = "Un email a été envoyé avec succès"; | |
841 | if (hruid != null) { | |
842 | url += '/' + hruid; | |
843 | msg += " sur l'adresse de " + hruid + "."; | |
844 | } else { | |
845 | msg += " sur ton addresse."; | |
846 | } | |
847 | $('#mail_sent').successMessage($url + '?token=' + token, msg); | |
848 | return false; | |
849 | } | |
850 | ||
851 | // }}} | |
7143ad2b | 852 | |
aaffb7b2 FB |
853 | /*************************************************************************** |
854 | * Quick search | |
855 | */ | |
856 | ||
60a4e0b3 | 857 | /* quick search {{{ */ |
aaffb7b2 FB |
858 | (function($) { |
859 | function findPos(obj) { | |
860 | var curleft = obj.offsetLeft || 0; | |
861 | var curtop = obj.offsetTop || 0; | |
862 | while (obj = obj.offsetParent) { | |
863 | curleft += obj.offsetLeft | |
864 | curtop += obj.offsetTop | |
865 | } | |
866 | return {x:curleft,y:curtop}; | |
867 | } | |
868 | ||
869 | $.template('quickMinifiche', | |
0b2c582e | 870 | '<div class="contact grayed" style="clear: both">' + |
aaffb7b2 FB |
871 | '<div class="identity">' + |
872 | '<div class="photo"><img src="photo/${hrpid}" alt="${directory_name}" /></div>' + | |
873 | '<div class="nom">' + | |
874 | '{{if is_female}}•{{/if}}<a href="profile/${hrpid}">${directory_name}</a>' + | |
875 | '</div>' + | |
876 | '<div class="edu">${promo}</div>' + | |
877 | '</div>' + | |
878 | '<div class="noprint bits"></div>' + | |
879 | '<div class="long"></div>' + | |
880 | '</div>'); | |
881 | ||
60a4e0b3 | 882 | |
b1ae686e | 883 | function buildPopup(input, destination, linkBindFunction) |
60a4e0b3 FB |
884 | { |
885 | var pos = findPos(input.get(0)); | |
b1ae686e | 886 | var $popup = destination; |
60a4e0b3 FB |
887 | var selected = null; |
888 | ||
889 | function updateSelection() | |
890 | { | |
891 | var sel = $popup.children('.contact').addClass('grayed'); | |
892 | if (selected !== null) { | |
893 | while (selected < 0) { | |
894 | selected += sel.length; | |
895 | } | |
896 | if (selected >= sel.length) { | |
897 | selected -= sel.length; | |
898 | } | |
899 | sel.eq(selected).removeClass('grayed'); | |
900 | } | |
901 | } | |
902 | ||
903 | function formatProfile(i, profile) { | |
904 | var data = $.tmpl('quickMinifiche', profile) | |
905 | .hover(function() { | |
906 | selected = i; | |
907 | updateSelection(); | |
908 | }, function() { | |
909 | if (selected === i) { | |
910 | selected = null; | |
911 | updateSelection(); | |
912 | } | |
913 | }).mouseup(function() { | |
914 | if (!($(this).find('a').is(':hover'))) { | |
915 | $(this).find('a').click(); | |
916 | } | |
917 | }); | |
918 | return data; | |
919 | } | |
920 | ||
b1ae686e FB |
921 | if (!$popup) { |
922 | $popup = $('<div>').hide() | |
923 | .addClass('contact-list') | |
924 | .css({ | |
925 | position: 'absolute', | |
926 | width: '300px', | |
927 | top: input.css('bottom'), | |
928 | left: pos.x - 300 + input.width(), | |
929 | clear: 'both', | |
930 | 'text-align': 'left' | |
931 | }); | |
932 | input.after($popup); | |
933 | } | |
60a4e0b3 FB |
934 | |
935 | return { | |
936 | hide: function(ignoreIfHover) { | |
937 | if (ignoreIfHover && $popup.is(':hover')) { | |
938 | return true; | |
939 | } | |
940 | selected = null; | |
941 | updateSelection(); | |
942 | $popup.hide(); | |
943 | return true; | |
944 | }, | |
945 | ||
946 | show: function() { | |
947 | $popup.show(); | |
948 | return true; | |
949 | }, | |
950 | ||
951 | selected: function() { | |
952 | return selected !== null; | |
953 | }, | |
954 | ||
955 | unselect: function() { | |
956 | selected = null; | |
957 | updateSelection(); | |
958 | }, | |
959 | ||
960 | selectNext: function() { | |
961 | if (selected === null) { | |
962 | selected = 0; | |
963 | } else { | |
964 | selected++; | |
965 | } | |
966 | updateSelection(); | |
967 | return true; | |
968 | }, | |
969 | ||
970 | selectPrev: function() { | |
971 | if (selected === null) { | |
972 | selected = -1; | |
973 | } else { | |
974 | selected--; | |
975 | } | |
976 | updateSelection(); | |
977 | return true; | |
978 | }, | |
979 | ||
980 | activeCurrent: function() { | |
981 | var sel = $popup.children('.contact'); | |
982 | if (selected !== null) { | |
983 | sel.eq(selected).find('a').click(); | |
984 | return false; | |
985 | } | |
986 | return true; | |
987 | }, | |
988 | ||
989 | updateContent: function(profiles) { | |
990 | var profile; | |
991 | $popup.empty(); | |
992 | for (var i = 0, len = profiles.length; i < len; i++) { | |
993 | profile = formatProfile(i, profiles[i]); | |
994 | profile.find('a').each(linkBindFunction); | |
995 | profile.appendTo($popup); | |
996 | } | |
997 | if (len === 1) { | |
998 | selected = 0; | |
999 | } else { | |
1000 | selected = null; | |
1001 | } | |
1002 | updateSelection(); | |
1003 | if (len > 0) { | |
1004 | this.show(); | |
1005 | } else { | |
1006 | this.hide(); | |
1007 | } | |
1008 | return true; | |
1009 | } | |
1010 | }; | |
1011 | } | |
1012 | ||
aaffb7b2 | 1013 | $.fn.extend({ |
c2c5ac82 | 1014 | quickSearch: function(options) { |
c2c5ac82 FB |
1015 | var $this = this; |
1016 | var $input = $this.get(0); | |
aaffb7b2 | 1017 | var $popup; |
b1ae686e | 1018 | var previous = null; |
599ff0d3 | 1019 | var pending = false; |
aaffb7b2 FB |
1020 | var disabled = false; |
1021 | var updatePopup; | |
b1ae686e | 1022 | var loadingClass; |
aaffb7b2 | 1023 | |
c2c5ac82 | 1024 | options = options || { }; |
b1ae686e FB |
1025 | options = $.extend({ |
1026 | destination: null, | |
1027 | minChars: 3, | |
1028 | shortChars: 5, | |
1029 | shortTimeout: 300, | |
1030 | longTimeout: 100, | |
1031 | queryParams: { | |
1032 | offset: 0, | |
1033 | count: 10, | |
1034 | }, | |
1035 | loadingClassLeft: 'ac_loading', | |
1036 | loadingClassRight: 'ac_loading_left', | |
1037 | selectAction: function() { | |
1038 | $(this).popWin(840, 600); | |
1039 | } | |
1040 | }, options); | |
1041 | console.log(options); | |
1042 | options.loadingClass = $this.css('text-align') === 'right' ? options.loadingClassRight | |
1043 | : options.loadingClassLeft; | |
1044 | ||
1045 | $popup = buildPopup(this, options.destination, function() { | |
1046 | options.selectAction.apply(this, arguments); | |
1047 | $(this).click(function() { | |
1048 | $popup.hide(); | |
1049 | }); | |
60a4e0b3 | 1050 | }); |
aaffb7b2 FB |
1051 | |
1052 | function markPending() { | |
1053 | pending = true; | |
1054 | } | |
1055 | ||
599ff0d3 | 1056 | function performUpdate(quick) |
aaffb7b2 | 1057 | { |
599ff0d3 | 1058 | if (updatePopup === markPending) { |
aaffb7b2 FB |
1059 | return true; |
1060 | } | |
599ff0d3 | 1061 | updatePopup = markPending; |
c2c5ac82 FB |
1062 | $this.addClass(options.loadingClass); |
1063 | $.xapi('search', $.extend({ 'quick': quick }, options.queryParams), function(data) { | |
b1ae686e | 1064 | if (data.profile_count > options.queryParams.count || data.profile_count < 0) { |
599ff0d3 | 1065 | return $popup.hide(); |
aaffb7b2 | 1066 | } |
60a4e0b3 | 1067 | $popup.updateContent(data.profiles); |
aaffb7b2 | 1068 | previous = quick; |
c54829c1 FB |
1069 | }, function(data, text) { |
1070 | if (text !== 'abort') { | |
1071 | disabled = true; | |
1072 | } | |
599ff0d3 | 1073 | }).complete(function() { |
c2c5ac82 | 1074 | $this.removeClass(options.loadingClass); |
aaffb7b2 FB |
1075 | updatePopup = doUpdatePopup; |
1076 | if (pending) { | |
c2c5ac82 | 1077 | updatePopup(); |
aaffb7b2 | 1078 | } |
599ff0d3 | 1079 | }); |
aaffb7b2 FB |
1080 | return true; |
1081 | } | |
0b2c582e | 1082 | |
599ff0d3 FB |
1083 | function doUpdatePopup(dontDelay) |
1084 | { | |
c2c5ac82 | 1085 | var quick = $this.val(); |
599ff0d3 | 1086 | if ($.isFunction(quick.trim)) { |
599ff0d3 FB |
1087 | quick = quick.trim(); |
1088 | } | |
1089 | pending = false; | |
b1ae686e | 1090 | if (disabled || quick.length < options.minChars) { |
599ff0d3 FB |
1091 | previous = quick; |
1092 | return $popup.hide(); | |
1093 | } else if (!dontDelay) { | |
b1ae686e | 1094 | var timeout = quick.length < options.shortChars ? options.shortTimeout : options.longTimeout; |
599ff0d3 | 1095 | setTimeout(function() { |
c2c5ac82 | 1096 | updatePopup(true); |
599ff0d3 FB |
1097 | }, timeout); |
1098 | return true; | |
1099 | } else if (previous === quick) { | |
1100 | return $popup.show(); | |
1101 | } | |
c2c5ac82 | 1102 | return performUpdate(quick); |
599ff0d3 FB |
1103 | } |
1104 | ||
aaffb7b2 FB |
1105 | updatePopup = doUpdatePopup; |
1106 | ||
1107 | return this.keyup(function(e) { | |
0b2c582e FB |
1108 | if (e.keyCode !== 27 /* escape */ && e.keyCode !== 13 /* enter */ |
1109 | && e.keyCode !== 9 /* tab */ && e.keyCode !== 38 /* up */ | |
1110 | && e.keyCode !== 40 /* down */) { | |
c2c5ac82 | 1111 | return updatePopup(); |
aaffb7b2 FB |
1112 | } |
1113 | return true; | |
1114 | }) | |
1115 | .keydown(function(e) { | |
0b2c582e FB |
1116 | switch (e.keyCode) { |
1117 | case 9: /* Tab */ | |
1118 | case 40: /* Down */ | |
60a4e0b3 | 1119 | $popup.selectNext(); |
0b2c582e FB |
1120 | return false; |
1121 | ||
1122 | case 38: | |
60a4e0b3 | 1123 | $popup.selectPrev(); |
0b2c582e FB |
1124 | return false; |
1125 | ||
1126 | case 13: /* Return */ | |
60a4e0b3 | 1127 | return $popup.activeCurrent(); |
0b2c582e FB |
1128 | |
1129 | case 27: /* Escape */ | |
60a4e0b3 FB |
1130 | if ($popup.selected()) { |
1131 | $popup.unselect(); | |
1132 | } else { | |
1133 | $popup.hide(); | |
1134 | } | |
1135 | return true; | |
aaffb7b2 FB |
1136 | } |
1137 | return true; | |
1138 | }) | |
1139 | .blur(function() { | |
60a4e0b3 | 1140 | return $popup.hide(true); |
aaffb7b2 FB |
1141 | }) |
1142 | .focus(updatePopup); | |
1143 | } | |
1144 | }); | |
1145 | }(jQuery)); | |
7143ad2b | 1146 | |
0337d704 | 1147 | /*************************************************************************** |
048c44a3 FB |
1148 | * Overlib made simple |
1149 | */ | |
1150 | ||
1151 | (function($) { | |
1152 | $.fn.extend({ | |
1153 | overlib: function(text, width, height) { | |
1154 | var args = [ ]; | |
34cc65fd FB |
1155 | var key; |
1156 | ||
1157 | if (typeof text === 'string') { | |
048c44a3 | 1158 | args.push(text); |
34cc65fd FB |
1159 | if (width) { |
1160 | args.push(width); | |
1161 | } | |
1162 | if (height) { | |
1163 | args.push(height); | |
1164 | } | |
048c44a3 | 1165 | } else { |
34cc65fd | 1166 | for (key in text) { |
048c44a3 FB |
1167 | switch (key) { |
1168 | case 'text': | |
1169 | args.unshift(text[key]); | |
1170 | break; | |
1171 | case 'caption': | |
1172 | args.push(CAPTION, text[key]); | |
1173 | break; | |
1174 | case 'close_text': | |
1175 | args.push(CLOSETEXT, text[key]); | |
1176 | break; | |
1177 | case 'delay': | |
1178 | args.push(DELAY, text[key]); | |
1179 | break; | |
1180 | case 'sticky': | |
1181 | if (text[key]) { | |
1182 | args.push(STICKY); | |
1183 | } | |
1184 | break; | |
1185 | case 'width': | |
1186 | args.push(WIDTH, text[key]); | |
1187 | break; | |
1188 | case 'height': | |
1189 | args.push(HEIGHT, text[key]); | |
1190 | break; | |
1191 | } | |
1192 | } | |
1193 | } | |
1194 | return this | |
1195 | .mouseover(function () { | |
1196 | return overlib.apply(null, args); | |
1197 | }) | |
1198 | .mouseout(nd); | |
1199 | } | |
1200 | }); | |
1201 | }(jQuery)); | |
60a4e0b3 | 1202 | /* }}} */ |
048c44a3 FB |
1203 | |
1204 | /*************************************************************************** | |
0337d704 | 1205 | * The real OnLoad |
1206 | */ | |
1207 | ||
4171c0bf | 1208 | $(function() { |
80dcbd9a FB |
1209 | auto_links(); |
1210 | getNow(); | |
1211 | setInterval(getNow, 1000); | |
1212 | $("#quick") | |
1213 | .focus(function() { | |
1214 | if ($(this).val() === 'Recherche dans l\'annuaire') { | |
1215 | $(this).val(''); | |
1216 | } | |
1217 | $("#quick_button").show(); | |
1218 | }) | |
1219 | .blur(function() { | |
1220 | $("#quick_button").hide(); | |
aaffb7b2 FB |
1221 | }) |
1222 | .quickSearch(); | |
80dcbd9a FB |
1223 | $("#quick_button").click(function() { |
1224 | if ($("#quick").val() === 'Recherche dans l\'annuaire' | |
1225 | || $("#quick").val() === '') { | |
1226 | return false; | |
1227 | } | |
1228 | return true; | |
1229 | }); | |
1230 | }); | |
0337d704 | 1231 | |
a14159bf | 1232 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |