Merge branch 'xorg/master' into xorg/f/geocoding
[platal.git] / htdocs / javascript / xorg.js
index 20221e2..47bf78b 100644 (file)
@@ -132,16 +132,17 @@ function addSearchEngine()
             var s_img;
             var s_title;
             var s_url;
+            var href = this.attr('href');
 
             for (site in goodies[type].sites) {
                 entry = goodies[type].sites[site];
                 s_alt   = entry.alt || "";
                 s_img   = entry.img;
                 s_title = entry.title || "";
-                s_url   = entry.url_prefix.length > 0 ? entry.url_prefix + escape(this.href) : this.href;
+                s_url   = entry.url_prefix.length > 0 ? entry.url_prefix + escape(href) : href;
 
                 text += '<a href="' + s_url + '"><img src="' + s_img + '" title="' + s_title + '" alt="' + s_alt + '"></a><br />';
-                }
+            }
             text += '<a href="https://www.polytechnique.org/Xorg/Goodies">Plus de bonus</a> ...</div>';
 
             return this.overlib({
@@ -178,7 +179,7 @@ function auto_links() {
         }
         if ((!href.contains(fqdn) && !this.className.contains('popup')) || node.hasClass('popup')) {
             node.click(function () {
-                window.open(href);
+                window.open(this.href);
                 return false;
             });
         }
@@ -565,7 +566,7 @@ function checkPassword(box, okLabel) {
     }
 }
 
-function hashResponse(password1, password2, hasConfirmation) {
+function hashResponse(password1, password2, hasConfirmation, doAuth) {
     var pw1 = $('[name=' + password1 + ']').val();
     var pw2;
 
@@ -589,9 +590,15 @@ function hashResponse(password1, password2, hasConfirmation) {
         return false;
     }
 
-    alert("Le mot de passe que tu as rentré va être chiffré avant de nous parvenir par Internet ! Ainsi il ne circulera pas en clair.");
+    alert("Le mot de passe va être chiffré avant de nous parvenir par Internet ! Ainsi il ne circulera pas en clair.");
     $('[name=' + password1 + ']').val('');
     $('[name=pwhash]').val(hash_encrypt(pw1));
+
+    if (doAuth) {
+        $('[name=password]').val(pw1);
+        doChallengeResponse();
+    }
+
     return true;
 }
 
@@ -684,7 +691,7 @@ function sendTestEmail(token, hruid)
     } else {
         msg += " sur ton addresse.";
     }
-    $('#mail_sent').successMessage($url + '?token=' + token, msg);
+    $('#mail_sent').successMessage(url + '?token=' + token, msg);
     return false;
 }
 
@@ -882,7 +889,6 @@ function sendTestEmail(token, hruid)
 
     function buildPopup(input, destination, linkBindFunction)
     {
-        var pos    = findPos(input.get(0));
         var $popup = destination;
         var selected = null;
         var hovered  = 0;
@@ -932,7 +938,6 @@ function sendTestEmail(token, hruid)
                 position: 'absolute',
                 width: '300px',
                 top: input.css('bottom'),
-                left: pos.x - 300 + input.width(),
                 clear: 'both',
                 'text-align': 'left'
             });
@@ -951,7 +956,8 @@ function sendTestEmail(token, hruid)
             },
 
             show: function() {
-                $popup.show();
+                var pos = findPos(input.get(0));
+                $popup.css('left', pos.x - 300 + input.width()).show();
                 return true;
             },
 
@@ -1043,7 +1049,7 @@ function sendTestEmail(token, hruid)
                 queryParams:       {
                     offset: 0,
                     count:  10,
-                    allow_special: true,
+                    allow_special: true
                 },
                 loadingClassLeft:  'ac_loading',
                 loadingClassRight: 'ac_loading_left',