-function GenericLoginBox(parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick) {
+qwebirc.ui.GenericLoginBox = function(parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick, networkName) {
if(autoConnect) {
- ConfirmBox(parentElement, callback, initialNickname, initialChannels, autoNick);
+ qwebirc.ui.ConfirmBox(parentElement, callback, initialNickname, initialChannels, autoNick, networkName);
} else {
- LoginBox(parentElement, callback, initialNickname, initialChannels);
+ qwebirc.ui.LoginBox(parentElement, callback, initialNickname, initialChannels, networkName);
}
-
}
-function ConfirmBox(parentElement, callback, initialNickname, initialChannels, autoNick) {
+qwebirc.ui.ConfirmBox = function(parentElement, callback, initialNickname, initialChannels, autoNick, networkName) {
var box = new Element("table");
- box.addClass("confirmbox");
+ box.addClass("qwebirc-confirmbox");
parentElement.appendChild(box);
var tbody = new Element("tbody");
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 " + networkName + " 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);
- }
+ }
+
text.appendChild(document.createTextNode(" click 'Connect'."));
-
+
var tr = new Element("tr");
tbody.appendChild(tr);
tr.addClass("tr2");
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});
});
+
+ if(!qwebirc.auth.loggedin()) {
+ 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/";
+ });
+ }
}
-function LoginBox(parentElement, callback, initialNickname, initialChannels) {
+qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initialChannels, networkName) {
var box = new Element("table");
parentElement.appendChild(box);
- box.addClass("loginbox");
+ box.addClass("qwebirc-loginbox");
var tbody = new Element("tbody");
box.appendChild(tbody);
var td = new Element("td");
tr.appendChild(td);
- td.set("html", "<h1>Connect to IRC</h1>");
+ td.set("html", "<h1>Connect to " + networkName + " IRC</h1>");
var tr = new Element("tr");
tbody.appendChild(tr);
chan.set("value", initialChannels);
nick.focus();
-}
\ No newline at end of file
+}