X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fxorg.js;h=89c35b208c31bc5cb552473044e27be9d584e441;hb=be638e733bce413df4324d985297d9a4d94dcbca;hp=02ef26a8abd78a0a9404eb03973bdaa1d804243d;hpb=9f449375aa254a3af970d5eb0bd7f0478ed7363a;p=platal.git
diff --git a/htdocs/javascript/xorg.js b/htdocs/javascript/xorg.js
index 02ef26a..89c35b2 100644
--- a/htdocs/javascript/xorg.js
+++ b/htdocs/javascript/xorg.js
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2003-2004 Polytechnique.org *
+ * Copyright (C) 2003-2009 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,34 +31,90 @@ 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
+// {{{ Search Engine
-function eventClosure(obj, methodName) {
- return (function(e) {
- e = e || window.event;
- return obj[methodName](e);
- });
+function canAddSearchEngine()
+{
+ if (((typeof window.sidebar == "object") && $.isFunction(window.sidebar.addSearchEngine))
+ || ((typeof window.external == "object") && $.isFunction(window.external.AddSearchProvider))) {
+ return true;
+ }
+ return false;
}
-function attachEvent(obj, evt, f, useCapture) {
- if (!useCapture) useCapture = 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");
+ }
+ }
+}
- if (obj.addEventListener) {
- obj.addEventListener(evt, f, useCapture);
- return true;
- } else if (obj.attachEvent) {
- return obj.attachEvent("on"+evt, f);
+// }}}
+// {{{ dynpost()
+
+function dynpost(action, values)
+{
+ var form = document.createElement('form');
+ form.action = action;
+ form.method = 'post';
+
+ $('body').get(0).appendChild(form);
+
+ for (var k in values) {
+ var input = document.createElement('input');
+ input.type = 'hidden';
+ input.name = k;
+ input.value = values[k];
+ form.appendChild(input);
}
+
+ form.submit();
+}
+
+
+function dynpostkv(action, k, v)
+{
+ var dict = {};
+ dict[k] = v;
+ dynpost(action, dict);
+}
+
+// }}}
+// {{{ 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');
}
// }}}
@@ -70,43 +125,220 @@ function attachEvent(obj, evt, f, useCapture) {
// {{{ 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 = '