| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2003-2006 Polytechnique.org * |
| 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 | |
| 21 | var is_netscape = (navigator.appName.substring(0,8) == "Netscape"); |
| 22 | var is_IE = (navigator.appName.substring(0,9) == "Microsoft"); |
| 23 | |
| 24 | // {{{ function getNow() |
| 25 | |
| 26 | function getNow() { |
| 27 | dt = new Date(); |
| 28 | dy = dt.getDay(); |
| 29 | mh = dt.getMonth(); |
| 30 | wd = dt.getDate(); |
| 31 | yr = dt.getYear(); |
| 32 | if (yr<1000) yr += 1900; |
| 33 | hr = dt.getHours(); |
| 34 | mi = dt.getMinutes(); |
| 35 | |
| 36 | time = (mi < 10) ? hr +':0'+mi : hr+':'+mi; |
| 37 | days = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi']; |
| 38 | months = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', |
| 39 | 'août', 'septembre', 'octobre', 'novembre', 'décembre'] |
| 40 | |
| 41 | return days[dy]+' '+wd+' '+months[mh]+' '+yr+'<br />'+time; |
| 42 | } |
| 43 | |
| 44 | // }}} |
| 45 | // {{{ Events |
| 46 | |
| 47 | function eventClosure(obj, methodName) { |
| 48 | return (function(e) { |
| 49 | e = e || window.event; |
| 50 | return obj[methodName](e); |
| 51 | }); |
| 52 | } |
| 53 | |
| 54 | function attachEvent(obj, evt, f, useCapture) { |
| 55 | if (!useCapture) useCapture = false; |
| 56 | |
| 57 | if (obj.addEventListener) { |
| 58 | obj.addEventListener(evt, f, useCapture); |
| 59 | return true; |
| 60 | } else if (obj.attachEvent) { |
| 61 | return obj.attachEvent("on"+evt, f); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // }}} |
| 66 | // {{{ dynpost() |
| 67 | |
| 68 | function dynpost(action, values) |
| 69 | { |
| 70 | var body = document.getElementsByTagName('body')[0]; |
| 71 | |
| 72 | var form = document.createElement('form'); |
| 73 | form.action = action; |
| 74 | form.method = 'post'; |
| 75 | |
| 76 | body.appendChild(form); |
| 77 | |
| 78 | for (var k in values) { |
| 79 | var input = document.createElement('input'); |
| 80 | input.type = 'hidden'; |
| 81 | input.name = k; |
| 82 | input.value = values[k]; |
| 83 | form.appendChild(input); |
| 84 | } |
| 85 | |
| 86 | form.submit(); |
| 87 | } |
| 88 | |
| 89 | function dynpostkv(action, k, v) |
| 90 | { |
| 91 | dynpost(action, {k: v}); |
| 92 | } |
| 93 | |
| 94 | // }}} |
| 95 | |
| 96 | /*************************************************************************** |
| 97 | * POPUP THINGS |
| 98 | */ |
| 99 | |
| 100 | // {{{ function popWin() |
| 101 | |
| 102 | function popWin(theNode,w,h) { |
| 103 | window.open(theNode.href, '_blank', |
| 104 | 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h); |
| 105 | } |
| 106 | |
| 107 | // }}} |
| 108 | // {{{ function auto_links() |
| 109 | |
| 110 | function auto_links() { |
| 111 | nodes = document.getElementsByTagName('a'); |
| 112 | fqdn = document.URL; |
| 113 | fqdn = fqdn.replace(/^https?:\/\/([^\/]*)\/.*$/,'$1'); |
| 114 | for(var i=0; i<nodes.length; i++) { |
| 115 | node = nodes[i]; |
| 116 | if(!node.href || node.className == 'xdx' || node.href.indexOf('mailto:') > -1 || node.href.indexOf('javascript:')>-1) continue; |
| 117 | if(node.href.indexOf(fqdn)<0 || node.className == 'popup') { |
| 118 | node.onclick = function () { window.open(this.href); return false; }; |
| 119 | } |
| 120 | if(node.className == 'popup2') { |
| 121 | node.onclick = function () { popWin(this,840,600); return false; }; |
| 122 | } |
| 123 | if(matches = (/^popup_([0-9]*)x([0-9]*)$/).exec(node.className)) { |
| 124 | var w = matches[1], h = matches[2]; |
| 125 | node.onclick = function () { popWin(this,w,h); return false; }; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | // }}} |
| 131 | |
| 132 | /*************************************************************************** |
| 133 | * The real OnLoad |
| 134 | */ |
| 135 | |
| 136 | // {{{ function pa_onload |
| 137 | |
| 138 | attachEvent(window, 'load', auto_links); |
| 139 | |
| 140 | // }}} |
| 141 | |