]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/genericlogin.js
TODO update, also include more instead of sortables.
[irc/quakenet/qwebirc.git] / js / ui / genericlogin.js
index 1d7fba6e83403d6fb13e84ce1cb482a87417cf01..1693fa3d80539b16b6dc354860bdf6e49e3a9155 100644 (file)
@@ -24,22 +24,20 @@ qwebirc.ui.ConfirmBox = function(parentElement, callback, initialNickname, initi
   var nick = new Element("b");
   nick.set("text", initialNickname);
   
-  var c = initialChannels.split(",");
-  var ctext;
+  var c = initialChannels.split(" ")[0].split(",");
   
-  if(c.length > 1) { 
-    var last = c.pop();
-    ctext = c.join(", ") + " and " + last;
-  } else {
-    ctext = c.join(", ");
+  text.appendChild(document.createTextNode("To connect to IRC and join channel" + ((c.length>1)?"s":"") + " "));
+
+  for(var i=0;i<c.length;i++) {
+    if((c.length > 1) && (i == c.length - 1)) {
+      text.appendChild(document.createTextNode(" and "));
+    } else if(i > 0) {
+      text.appendChild(document.createTextNode(", "));
+    }
+    text.appendChild(new Element("b").set("text", c[i]));
+    
   }
   
-  var channels = new Element("b");
-  channels.set("text", ctext);
-  
-  text.appendChild(document.createTextNode("To connect to IRC and join channels "));
-  text.appendChild(channels);
-  
   if(!autoNick) {
     text.appendChild(document.createTextNode(" as "));
     text.appendChild(nick);
@@ -53,17 +51,23 @@ qwebirc.ui.ConfirmBox = function(parentElement, callback, initialNickname, initi
   var td = new Element("td");
   tr.appendChild(td);
 
-  var form = new Element("form");
-  td.appendChild(form);
-  
   var yes = new Element("input", {"type": "submit", "value": "Connect"});
-  form.appendChild(yes);
-  
-  form.addEvent("submit", function(e) {
-    new Event(e).stop();
+  td.appendChild(yes);
+  yes.focus();
+  yes.addEvent("click", function(e) {
     parentElement.removeChild(box);
     callback({"nickname": initialNickname, "autojoin": initialChannels});
   });
+  
+  var user = Cookie.read("user")
+  if(!$defined(user)) {
+    var auth = new Element("input", {"type": "submit", "value": "Log in"});
+    td.appendChild(auth);
+    auth.addEvent("click", function(e) {
+      var cookie = Cookie.write("redirect", document.location);
+      document.location = "./auth/";
+    });
+  }
 }
 
 qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initialChannels) {
@@ -144,4 +148,4 @@ qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initial
   chan.set("value", initialChannels);
 
   nick.focus();
-}
\ No newline at end of file
+}