diff rlgterm.js @ 93:104409bf5f03

rlgterm.js: improve registration failure messages. Provide more user-friendly explanations when registration fails.
author John "Elwin" Edwards <elwin@sdf.org>
date Wed, 11 Jul 2012 07:37:56 -0700
parents a4d3ecf188b7
children 597e9477b8ae
line wrap: on
line diff
--- a/rlgterm.js	Tue Jul 10 18:39:36 2012 -0700
+++ b/rlgterm.js	Wed Jul 11 07:37:56 2012 -0700
@@ -707,7 +707,25 @@
     }
     else if (reply.t == 'E') {
       debug(1, "Could not register: " + reply.s);
-      message("Registration failed.");
+      var failmsg = "Registration failed.";
+      if (reply.c == 2) {
+        var errdesc = reply.s.match(/Invalid data: (.*)/)[1];
+        if (errdesc.match(/No name/))
+          failmsg += " You need to choose a name.";
+        else if (errdesc.match(/No password/))
+          failmsg += " You need to choose a password.";
+        else if (errdesc.match(/Invalid/)) {
+          failmsg += " Names must be letters and numbers. E-mail addresses " +
+                     "can also contain these characters: @.-_";
+        }
+        else if (errdesc.match(/Username/))
+          failmsg += " Someone else is already using that name.";
+        else
+          failmsg += " This is probably a bug.";
+      }
+      else
+        failmsg += " This is probably a bug.";
+      message(failmsg);
       document.getElementById("regin_name").value = "";
       document.getElementById("regin_pw").value = "";
       document.getElementById("regin_email").value = "";