-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) {
- var box = new Element("div");
- box.addStyle("confirmbox");
+qwebirc.ui.ConfirmBox = function(parentElement, callback, initialNickname, initialChannels, autoNick, networkName) {
+ var box = new Element("table");
+ box.addClass("qwebirc-confirmbox");
parentElement.appendChild(box);
+ var tbody = new Element("tbody");
+ box.appendChild(tbody);
+
+ var tr = new Element("tr");
+ tbody.appendChild(tr);
+ tr.addClass("tr1");
+
+ var text = new Element("td");
+ tr.appendChild(text);
+
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);
-
- var text = new Element("div");
- 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'."));
-
- box.appendChild(text);
+ }
- var form = new Element("form");
- box.appendChild(form);
+ 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 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) {
- var box = new Element("div");
+qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initialChannels, networkName) {
+ var box = new Element("table");
parentElement.appendChild(box);
- box.addStyle("loginbox");
+ box.addClass("qwebirc-loginbox");
+
+ var tbody = new Element("tbody");
+ box.appendChild(tbody);
+
+ var tr = new Element("tr");
+ tbody.appendChild(tr);
+ tr.addClass("tr1");
+
+ var td = new Element("td");
+ tr.appendChild(td);
+ td.set("html", "<h1>Connect to " + networkName + " IRC</h1>");
+
+ var tr = new Element("tr");
+ tbody.appendChild(tr);
+ tr.addClass("tr2");
+
+ var td = new Element("td");
+ tr.appendChild(td);
- var header = new Element("h1");
- header.set("text", "Connect to IRC");
- box.appendChild(header);
-
var form = new Element("form");
- box.appendChild(form);
+ td.appendChild(form);
var boxtable = new Element("table");
form.appendChild(boxtable);
var nick = new Element("input");
createRow("Nickname:", nick);
var chan = new Element("input");
- createRow("Channels (comma seperated):", chan);
+ createRow("Channels:", chan);
var connbutton = new Element("input", {"type": "submit"});
connbutton.set("value", "Connect");
chan.set("value", initialChannels);
nick.focus();
-}
\ No newline at end of file
+}