Typo.
[platal.git] / htdocs / javascript / xorg.js
index 0bd885f..67d106a 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($.plURL(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;
 }
 
@@ -655,7 +662,6 @@ function doChallengeResponse() {
     }
     document.forms.loginsub.username.value = document.forms.login.username.value;
     document.forms.loginsub.remember.value = document.forms.login.remember.checked;
-    document.forms.loginsub.domain.value = document.forms.login.domain.value;
     document.forms.login.password.value = "";
     document.forms.loginsub.submit();
 }
@@ -684,7 +690,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;
 }
 
@@ -810,7 +816,7 @@ function sendTestEmail(token, hruid)
 
         popWin: function(w, h) {
             return this.click(function() {
-                window.open(this.href, '_blank',
+                window.open($.plURL(this.href), '_blank',
                             'toolbar=0,location=0,directories=0,status=0,'
                            +'menubar=0,scrollbars=1,resizable=1,'
                            +'width='+w+',height='+h);
@@ -832,20 +838,23 @@ function previewWiki(idFrom, idTo, withTitle, idShow)
 }
 
 // }}}
-// {{{ send test email
-
-function sendTestEmail(token, hruid)
-{
-    var url = 'emails/test';
-    var msg = "Un email a été envoyé avec succès";
-    if (hruid != null) {
-        url += '/' + hruid;
-        msg += " sur l'adresse de " + hruid + ".";
-    } else {
-        msg += " sur ton addresse.";
+// {{{ updatepromofields
+
+function updatepromofields(egal1, egal2, promo2) {
+    var comparator = egal1.val();
+
+    if (comparator == '=') {
+        egal2.attr('disabled', 'disabled');
+        promo2.attr('disabled', 'disabled');
+    } else if (comparator == '<=' || comparator == '>=') {
+        egal2.removeAttr('disabled');
+        promo2.removeAttr('disabled');
+        if (comparator == '<=') {
+            egal2.val('>=');
+        } else {
+            egal2.val('<=');
+        }
     }
-    $('#mail_sent').successMessage($url + '?token=' + token, msg);
-    return false;
 }
 
 // }}}
@@ -1042,7 +1051,7 @@ function sendTestEmail(token, hruid)
                 queryParams:       {
                     offset: 0,
                     count:  10,
-                    allow_special: true,
+                    allow_special: true
                 },
                 loadingClassLeft:  'ac_loading',
                 loadingClassRight: 'ac_loading_left',
@@ -1056,7 +1065,7 @@ function sendTestEmail(token, hruid)
                         break;
                       case 'admin':
                         $(this).attr('href', 'admin/user/' + profile.hrpid)
-                        .click(function() { window.open($(this).attr('href')); return false });
+                        .click(function() { window.open($.plURL(this.href)); return false });
                         break;
                     }
                 }