X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=htdocs%2Fjavascript%2Fxorg.js;h=ccc9c0b2217f08c51f8091249f44520b51bc8036;hb=c76545c351fae4e2298624ff9ee5bf854dc5a5b6;hp=0ce316941a1dd2f855cde78f1b74caf1ba7ee7f5;hpb=e173ee9b7e29b11c13c3bc5124d200cba6675cce;p=platal.git diff --git a/htdocs/javascript/xorg.js b/htdocs/javascript/xorg.js index 0ce3169..ccc9c0b 100644 --- a/htdocs/javascript/xorg.js +++ b/htdocs/javascript/xorg.js @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2003-2007 Polytechnique.org * + * Copyright (C) 2003-2010 Polytechnique.org * * http://opensource.polytechnique.org/ * * * * This program is free software; you can redistribute it and/or modify * @@ -18,8 +18,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -var is_netscape = (navigator.appName.substring(0,8) == "Netscape"); -var is_IE = (navigator.appName.substring(0,9) == "Microsoft"); +var is_IE = $.browser.msie; // {{{ function getNow() @@ -32,7 +31,7 @@ function getNow() { if (yr<1000) yr += 1900; hr = dt.getHours(); mi = dt.getMinutes(); - + time = (mi < 10) ? hr +':0'+mi : hr+':'+mi; days = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi']; months = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', @@ -46,51 +45,29 @@ function getNow() { function canAddSearchEngine() { - if (((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) - || ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function"))) { - return true; - } - return false; + if (((typeof window.sidebar == "object") && $.isFunction(window.sidebar.addSearchEngine)) + || ((typeof window.external == "object") && $.isFunction(window.external.AddSearchProvider))) { + return true; + } + return false; } function addSearchEngine() { - var searchURI = "http://www.polytechnique.org/xorg.opensearch.xml"; - if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) { - window.sidebar.addSearchEngine( - searchURI, - "http://www.polytechnique.org/images/xorg.png", - "Annuaire Polytechnique.org", - "Academic"); - } else { - try { - window.external.AddSearchProvider(searchURI); - } catch(e) { - alert("Impossible d'installer la barre de recherche"); + var searchURI = "http://www.polytechnique.org/xorg.opensearch.xml"; + if ((typeof window.sidebar == "object") && $.isFunction(window.sidebar.addSearchEngine)) { + window.sidebar.addSearchEngine( + searchURI, + "http://www.polytechnique.org/images/xorg.png", + "Annuaire Polytechnique.org", + "Academic"); + } else { + try { + window.external.AddSearchProvider(searchURI); + } catch(e) { + alert("Impossible d'installer la barre de recherche"); + } } - } -} - -// }}} -// {{{ Events - -function eventClosure(obj, methodName) { - return (function(e) { - e = e || window.event; - return obj[methodName](e); - }); -} - -function attachEvent(obj, evt, f, useCapture) { - if (!useCapture) useCapture = false; - - if (obj.addEventListener) { - obj.addEventListener(evt, f, useCapture); - return true; - } else if (obj.attachEvent) { - return obj.attachEvent("on"+evt, f); - } - return false; } // }}} @@ -98,13 +75,11 @@ function attachEvent(obj, evt, f, useCapture) { function dynpost(action, values) { - var body = document.getElementsByTagName('body')[0]; - var form = document.createElement('form'); form.action = action; form.method = 'post'; - body.appendChild(form); + $('body').get(0).appendChild(form); for (var k in values) { var input = document.createElement('input'); @@ -117,6 +92,7 @@ function dynpost(action, values) form.submit(); } + function dynpostkv(action, k, v) { var dict = {}; @@ -149,54 +125,240 @@ RegExp.escape = function(text) { // {{{ function popWin() -function popWin(theNode,w,h) { +function popWin(theNode, w, h) { window.open(theNode.href, '_blank', - 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h); + 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h); + return false; +} + +// }}} +// {{{ function goodiesPopup() + +var __goodies_active = true; + +var __goodies_ical = { + default_title: 'Calendrier iCal', + sites: [ + {'url_prefix': '', + 'img': 'images/icons/calendar_view_day.gif', + 'title': 'Calendrier iCal'}, + {'url_prefix': 'http://www.google.com/calendar/render?cid=', + 'img': 'images/goodies/add-google-calendar.gif', + 'title': 'Ajouter à Google Calendar'}, + {'url_prefix': 'https://www.google.com/calendar/hosted/polytechnique.org/render?cid=', + 'img': 'images/goodies/add-google-calendar.gif', + 'title': 'Ajouter à Google Apps / Calendar'} + ] +}; + +var __goodies_rss = { + default_title: 'Fils RSS', + sites: [ + {'url_prefix': '', + 'img': 'images/icons/feed.gif', + 'title': 'Fil rss'}, + {'url_prefix': 'http://fusion.google.com/add?feedurl=', + 'img': 'images/goodies/add-google.gif', + 'alt': 'Add to Google', + 'title': 'Ajouter à iGoogle/Google Reader'}, + {'url_prefix': 'http://www.netvibes.com/subscribe.php?url=', + 'img': 'images/goodies/add-netvibes.gif', + 'title': 'Ajouter à Netvibes'}, + {'url_prefix': 'http://add.my.yahoo.com/content?.intl=fr&url=', + 'img': 'images/goodies/add-yahoo.gif', + 'alt': 'Add to My Yahoo!', + 'title': 'Ajouter à My Yahoo!'} + ] +}; + +function disableGoodiesPopups() { + __goodies_active = false; +} + +function goodiesPopup(node, goodies) { + var text = '