X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fxorg.js;h=39508a8b920a33fbd7de2b0fac9b7fde1962081b;hb=2700a4f5b414f91183460b2dbba33624b5bfd9b7;hp=68c1dabfca722bb523c53b46296ef875c90cb1ea;hpb=4d8e2051a1744a78acddfdad2074908aa1f7df1f;p=platal.git
diff --git a/htdocs/javascript/xorg.js b/htdocs/javascript/xorg.js
index 68c1dab..39508a8 100644
--- a/htdocs/javascript/xorg.js
+++ b/htdocs/javascript/xorg.js
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2008 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,49 +31,55 @@ 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',
- 'août', 'septembre', 'octobre', 'novembre', 'décembre']
+ months = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet',
+ 'août', 'septembre', 'octobre', 'novembre', 'décembre']
return days[dy]+' '+wd+' '+months[mh]+' '+yr+'
'+time;
}
// }}}
-// {{{ 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;
+// {{{ Search Engine
- if (obj.addEventListener) {
- obj.addEventListener(evt, f, useCapture);
+function canAddSearchEngine()
+{
+ if (((typeof window.sidebar == "object") && $.isFunction(window.sidebar.addSearchEngine))
+ || ((typeof window.external == "object") && $.isFunction(window.external.AddSearchProvider))) {
return true;
- } else if (obj.attachEvent) {
- return obj.attachEvent("on"+evt, f);
- }
+ }
return false;
}
+function addSearchEngine()
+{
+ 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");
+ }
+ }
+}
+
// }}}
// {{{ dynpost()
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');
@@ -87,6 +92,7 @@ function dynpost(action, values)
form.submit();
}
+
function dynpostkv(action, k, v)
{
var dict = {};
@@ -95,6 +101,23 @@ function dynpostkv(action, k, v)
}
// }}}
+// {{{ function RegExp.escape()
+
+RegExp.escape = function(text) {
+ if (!arguments.callee.sRE) {
+ var specials = [
+ '/', '.', '*', '+', '?', '|',
+ '(', ')', '[', ']', '{', '}',
+ '\\', '^' , '$'
+ ];
+ arguments.callee.sRE = new RegExp(
+ '(\\' + specials.join('|\\') + ')', 'g'
+ );
+ }
+ return text.replace(arguments.callee.sRE, '\\$1');
+}
+
+// }}}
/***************************************************************************
* POPUP THINGS
@@ -102,45 +125,220 @@ function dynpostkv(action, k, v)
// {{{ 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!'},
+ {'url_prefix': 'http://www.newsgator.com/ngs/subscriber/subext.aspx?url=',
+ 'img': 'images/goodies/add-newsgator.gif',
+ 'alt': 'Subscribe in NewsGator Online',
+ 'title': 'Ajouter à Newsgator'}
+ ]
+};
+
+function disableGoodiesPopups() {
+ __goodies_active = false;
+}
+
+function goodiesPopup(node, goodies) {
+ var text = '