| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2003-2004 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 | |
| 22 | /*************************************************************************** |
| 23 | * MISC |
| 24 | */ |
| 25 | |
| 26 | // {{{ function getNow() |
| 27 | |
| 28 | /** |
| 29 | * function used to print the client's computer datetime on the page |
| 30 | */ |
| 31 | function getNow() { |
| 32 | dt=new Date(); |
| 33 | dy=dt.getDay(); |
| 34 | mh=dt.getMonth(); |
| 35 | wd=dt.getDate(); |
| 36 | yr=dt.getYear(); |
| 37 | if (yr<1000) yr += 1900; |
| 38 | hr=dt.getHours(); |
| 39 | mi=dt.getMinutes(); |
| 40 | if (mi<10) |
| 41 | time=hr+":0"+mi; |
| 42 | else |
| 43 | time=hr+":"+mi; |
| 44 | days=new Array ("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"); |
| 45 | months=new Array ("janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"); |
| 46 | return days[dy]+" "+wd+" "+months[mh]+" "+yr+"<br />"+time; |
| 47 | } |
| 48 | |
| 49 | // }}} |
| 50 | |
| 51 | /*************************************************************************** |
| 52 | * POPUP THINGS |
| 53 | */ |
| 54 | |
| 55 | // {{{ function popWin() |
| 56 | |
| 57 | /** |
| 58 | * function that pops an anchor |
| 59 | * |
| 60 | * @param theNode anchor the anchor we are talking about |
| 61 | * @param w int the desired width for the popup |
| 62 | * @param h int the desired height for the popup |
| 63 | */ |
| 64 | function popWin(theNode,w,h) { |
| 65 | window.open(theNode.href, '_blank', |
| 66 | 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h); |
| 67 | } |
| 68 | |
| 69 | // }}} |
| 70 | // {{{ function auto_links() |
| 71 | |
| 72 | /** |
| 73 | * parses an html file, and update the onclik handlers for anchors that need it. |
| 74 | * |
| 75 | * anchors : |
| 76 | * - that points to another host are opened in a new window (mimic the target=_new) |
| 77 | * - of class popup(2) or popup_###x### create real popups (no url bar, ...) |
| 78 | * This function is designed to be used in <body onload="javascript:auto_links()"> |
| 79 | */ |
| 80 | function auto_links() { |
| 81 | nodes = document.getElementsByTagName('a'); |
| 82 | fqdn = document.URL; |
| 83 | fqdn = fqdn.replace(/^https?:\/\/([^\/]*)\/.*$/,'$1'); |
| 84 | for(var i=0; i<nodes.length; i++) { |
| 85 | node = nodes[i]; |
| 86 | if(!node.href || node.className == 'xdx' || node.href.indexOf('mailto:') > -1 || node.href.indexOf('javascript:')>-1) continue; |
| 87 | if(node.href.indexOf(fqdn)<0 || node.className == 'popup') { |
| 88 | node.onclick = function () { window.open(this.href); return false; }; |
| 89 | } |
| 90 | if(node.className == 'popup2') { |
| 91 | node.onclick = function () { popWin(this,840,600); return false; }; |
| 92 | } |
| 93 | if(matches = (/^popup_([0-9]*)x([0-9]*)$/).exec(node.className)) { |
| 94 | var w = matches[1], h = matches[2]; |
| 95 | node.onclick = function () { popWin(this,w,h); return false; }; |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // }}} |
| 101 | |
| 102 | /*************************************************************************** |
| 103 | * The real OnLoad |
| 104 | */ |
| 105 | |
| 106 | // {{{ function pa_onload |
| 107 | |
| 108 | function pa_onload() { |
| 109 | auto_links(); |
| 110 | } |
| 111 | |
| 112 | // }}} |
| 113 | |