X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fxorg.js;h=e8b795235f8b6b962403fca170584cc4d19fde35;hb=55546c0db778c2d8f9d7debd30117931dc39ff16;hp=0e5f5d0f016d3501768204a444c140eb26873d52;hpb=d0327f6de73e81c4bcc656471ca4161e4f1e1e1b;p=platal.git diff --git a/htdocs/javascript/xorg.js b/htdocs/javascript/xorg.js index 0e5f5d0..e8b7952 100644 --- a/htdocs/javascript/xorg.js +++ b/htdocs/javascript/xorg.js @@ -32,7 +32,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', @@ -66,7 +66,7 @@ function addSearchEngine() try { window.external.AddSearchProvider(searchURI); } catch(e) { - alert("Impossible d'installer la barre de recherche"); + alert("Impossible d'installer la barre de recherche"); } } } @@ -89,7 +89,7 @@ function attachEvent(obj, evt, f, useCapture) { return true; } else if (obj.attachEvent) { return obj.attachEvent("on"+evt, f); - } + } return false; } @@ -160,18 +160,26 @@ function popWin(theNode,w,h) { function goodiesPopup(node) { if (node.href.indexOf('ical') > -1) { __goodies_popup(node, __goodies_ical_sites, 'Calendrier iCal'); - } else if (node.href.indexOf('rss') > -1 && (node.href.indexOf('xml') > -1 || node.href.indexOf('hash'))) { + } else if (node.href.indexOf('rss') > -1 && node.href.indexOf('prefs/rss') < 0 && (node.href.indexOf('xml') > -1 || node.href.indexOf('hash'))) { __goodies_popup(node, __goodies_rss_sites, 'Fil rss'); } } +function disableGoodiesPopups() { + __goodies_active = false; +} + +var __goodies_active = true; var __goodies_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'} + '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_sites = [ {'url_prefix': '', @@ -187,7 +195,11 @@ var __goodies_rss_sites = [ {'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!'} + '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 __goodies_popupText(url, sites) { @@ -206,9 +218,11 @@ function __goodies_popupText(url, sites) { function __goodies_popup(node, sites, default_title) { var mouseover_cb = function() { - var rss_text = __goodies_popupText(node.href, sites); - var rss_title = (node.title ? node.title : default_title); - return overlib(rss_text, CAPTION, rss_title, CLOSETEXT, 'Fermer', DELAY, 800, STICKY, WIDTH, 150); + if (__goodies_active) { + var rss_text = __goodies_popupText(node.href, sites); + var rss_title = (node.title ? node.title : default_title); + return overlib(rss_text, CAPTION, rss_title, CLOSETEXT, 'Fermer', DELAY, 800, STICKY, WIDTH, 150); + } } var mouseout_cb = function() { nd(); @@ -266,6 +280,86 @@ function auto_links_nodes(nodes) { // }}} + +/*************************************************************************** + * Password check + */ + +// {{{ function checkPassword + +function getType(char) { + if (char >= 'a' && char <= 'z') { + return 1; + } else if (char >= 'A' && char <= 'Z') { + return 2; + } else if (char >= '0' && char <= '9') { + return 3; + } else { + return 4; + } +} + +function checkPassword(box, okLabel) { + var prev = 0; + var prop = 0; + var pass = box.value; + var types = Array(0, 0, 0, 0, 0); + var firstType = true; + for (i = 0 ; i < pass.length ; ++i) { + type = getType(pass.charAt(i)); + if (prev != 0 && prev != type) { + prop += 5; + } + prop += i; + if (types[type] == 0 && !firstType) { + prop += 15; + } else { + firstType = false; + } + types[type]++; + prev = type; + } + if (pass.length < 6) { + prop *= 0.75; + } + if (prop > 100) { + prop = 100; + } else if (prop < 0) { + prop = 0; + } + if (prop >= 60) { + color = "#4f4"; + bgcolor = "#050"; + ok = true; + } else if (prop >= 40) { + color = "#ff4"; + bgcolor = "#750"; + ok = true; + } else { + color = "#f20"; + bgcolor = "#700"; + ok = false; + } + $("#passwords_measure") + .stop() + .animate({ width: prop + "%", + backgroundColor: color + }, 750) + .parent().stop() + .animate({ backgroundColor: bgcolor }, 750); + var submitButton = $(":submit[@name='" + passwordprompt_submit + "']"); + if (ok && pass.length >= 6) { + submitButton.attr("value", okLabel); + submitButton.removeAttr("disabled"); + } else { + submitButton.attr("value", "Mot de passe trop faible"); + submitButton.attr("disabled", "disabled"); + } +} + +// }}} + + /*************************************************************************** * The real OnLoad */