Add better login boxes by default.
del /q compiled\*.js\r
\r
cd js\r
-copy version.js + jslib.js + irc\ircconnection.js + irc\irclib.js + irc\baseircclient.js + irc\irctracker.js + irc\commandparser.js + irc\ircclient.js + ui\baseui.js + ui\baseuiwindow.js + ui\colour.js + ui\url.js + ui\theme.js + qwebircinterface.js ..\compiled\qwebirc-concat.js /b\r
+copy version.js + jslib.js + irc\ircconnection.js + irc\irclib.js + irc\baseircclient.js + irc\irctracker.js + irc\commandparser.js + irc\ircclient.js + ui\baseui.js + ui\baseuiwindow.js + ui\colour.js + ui\url.js + ui\theme.js + ui\genericlogin.js + qwebircinterface.js ..\compiled\qwebirc-concat.js /b\r
copy ui\swmlayout.js + ui\swmui.js + irc\commandhistory.js ..\compiled\swmui-concat.js /b\r
cd ..\compiled\r
\r
rm -f compiled/*.js
cd js
-cat version.js jslib.js irc/ircconnection.js irc/irclib.js irc/baseircclient.js irc/irctracker.js irc/commandparser.js irc/ircclient.js ui/baseui.js ui/baseuiwindow.js ui/colour.js ui/url.js ui/theme.js irc/commandhistory.js qwebircinterface.js > ../compiled/qwebirc-concat.js
+cat version.js jslib.js irc/ircconnection.js irc/irclib.js irc/baseircclient.js irc/irctracker.js irc/commandparser.js irc/ircclient.js ui/baseui.js ui/baseuiwindow.js ui/colour.js ui/url.js ui/theme.js ui/genericlogin.js irc/commandhistory.js qwebircinterface.js > ../compiled/qwebirc-concat.js
cat ui/swmlayout.js ui/swmui.js > ../compiled/swmui-concat.js
error() {
obj.setSelectionRange(pos, pos);
}
}
+
+/* returns the arguments */
+function parseURI(uri) {
+ var result = {}
+
+ var start = uri.indexOf('?');
+ if(start == -1)
+ return result;
+
+ var querystring = uri.substring(start + 1);
+
+ var args = querystring.split("&");
+
+ for(i=0;i<args.length;i++) {
+ var r = args[i].splitMax("=", 2);
+ if(r.length < 2)
+ continue;
+
+ result[unescape(r[0])] = unescape(r[1]);
+ }
+
+ return result;
+}
options: {
initialNickname: "qwebirc" + Math.ceil(Math.random() * 100000),
initialChannels: "",
- searchURL: false,
+ searchURL: true,
theme: undefined
},
initialize: function(element, ui, options) {
window.addEvent("domready", function() {
var ui_ = new ui($(element), new Theme(this.options.theme));
-
- if(this.options.searchURL) {
- /* TODO: look at URI and detect nickname/channels... */
- }
-
- var details = ui_.loginBox(function(options) {
+ var inick = this.options.initialNickname;
+ var ichans = this.options.initialChannels;
+ var autoNick = true;
+
+ var callback = function(options) {
var IRC = new IRCClient(options, ui_);
IRC.connect();
window.addEvent("beforeunload", function() {
IRC.quit("Page closed");
});
- }, this.options.initialNickname, this.options.initialChannels);
+ };
+
+ var supplied = false;
+ if(this.options.searchURL) {
+ var args = parseURI(String(document.location));
+
+ var chans = args["channels"];
+ var nick = args["nick"];
+
+ if(chans) {
+ chans = chans.split(",");
+ var chans2 = [];
+
+ for(i=0;i<chans.length;i++) {
+ chans2[i] = chans[i];
+
+ if(chans[i].charAt(0) != '#')
+ chans2[i] = "#" + chans2[i]
+ }
+ ichans = chans2.join(",");
+ supplied = true;
+ }
+
+ if(nick) {
+ inick = nick;
+ autoNick = false;
+ }
+ }
+
+ var details = ui_.loginBox(callback, inick, ichans, supplied, autoNick);
}.bind(this));
}
});
delete this.windows[window.client][window.identifier];
},
- loginBox: function(callback, initialNickname, initialChannels) {
/*
this shouldn't be called by overriding classes!
+ they should implement their own!
some form of user input MUST be received before an
IRC connection is made, else users are going to get
tricked into getting themselves glined
*/
+ loginBox: function(callback, initialNickname, initialChannels, autoConnect, autoNick) {
+ GenericLoginBox(this.parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick);
+ /*if(autoConnect) {
+ var c = initialChannels.split(",");
+ var ctext;
+
+ if(c.length > 1) {
+ var last = c.pop();
+ ctext = c.join(", ") + " and " + last;
+ } else {
+ ctext = c[0];
+ }
+
+ var nicktext;
+ if(autoNick) {
+ nicktext = "";
+ } else {
+ nicktext = " (as '" + initialNickname + "')"
+ }
+ if(confirm("Connect to IRC and join channels " + ctext + nicktext + "?"))
+ callback({"nickname": initialNickname, "autojoin": initialChannels});
+ return;
+ }
var nick = prompt("Nickname:", initialNickname);
if(!nick) {
var chans = prompt("Channels (seperate by comma):", initialChannels);
callback({"nickname": nick, "autojoin": chans});
+ */
}
});
--- /dev/null
+function GenericLoginBox(parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick) {
+ if(autoConnect) {
+ ConfirmBox(parentElement, callback, initialNickname, initialChannels, autoNick);
+ } else {
+ LoginBox(parentElement, callback, initialNickname, initialChannels);
+ }
+}
+
+function ConfirmBox(parentElement, callback, initialNickname, initialChannels, autoNick) {
+ var box = new Element("div");
+ box.addStyle("confirmbox");
+ parentElement.appendChild(box);
+
+ var nick = new Element("b");
+ nick.set("text", initialNickname);
+
+ var c = initialChannels.split(",");
+ var ctext;
+
+ if(c.length > 1) {
+ var last = c.pop();
+ ctext = c.join(", ") + " and " + last;
+ } else {
+ ctext = c.join(", ");
+ }
+
+ 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);
+
+ var yes = new Element("input", {"type": "submit", "value": "Connect"});
+ form.appendChild(yes);
+
+ form.addEvent("submit", function(e) {
+ new Event(e).stop();
+ parentElement.removeChild(box);
+ callback({"nickname": initialNickname, "autojoin": initialChannels});
+ });
+}
+
+function LoginBox(parentElement, callback, initialNickname, initialChannels) {
+ var box = new Element("div");
+ parentElement.appendChild(box);
+ box.addStyle("loginbox");
+
+ var header = new Element("h1");
+ header.set("text", "Connect to IRC");
+ box.appendChild(header);
+
+ var form = new Element("form");
+ box.appendChild(form);
+
+ var boxtable = new Element("table");
+ form.appendChild(boxtable);
+
+ var tbody = new Element("tbody");
+ boxtable.appendChild(tbody); /* stupid IE */
+
+ function createRow(label, e2) {
+ var r = new Element("tr");
+ tbody.appendChild(r);
+
+ var d1 = new Element("td");
+ if(label)
+ d1.set("text", label);
+ r.appendChild(d1);
+
+ var d2 = new Element("td");
+ r.appendChild(d2);
+ d2.appendChild(e2);
+ return d1;
+ }
+
+ var nick = new Element("input");
+ createRow("Nickname:", nick);
+ var chan = new Element("input");
+ createRow("Channels (comma seperated):", chan);
+
+ var connbutton = new Element("input", {"type": "submit"});
+ connbutton.set("value", "Connect");
+ createRow(undefined, connbutton)
+
+ form.addEvent("submit", function(e) {
+ new Event(e).stop();
+ var nickname = nick.value;
+ var chans = chan.value;
+ if(chans == "#") /* sorry channel "#" :P */
+ chans = "";
+
+ if(!nickname) {
+ alert("You must supply a nickname.");
+ nick.focus();
+ return;
+ }
+
+ parentElement.removeChild(box);
+
+ callback({"nickname": nickname, "autojoin": chans});
+ }.bind(this));
+
+ nick.set("value", initialNickname);
+ chan.set("value", initialChannels);
+
+ nick.focus();
+}
\ No newline at end of file
form.appendChild(inputbox);
inputbox.focus();
},
- loginBox: function(callbackfn, intialNickname, initialChannels) {
+ loginBox: function(callbackfn, intialNickname, initialChannels, autoConnect, autoNick) {
this.parent(function(options) {
this.postInitialize();
callbackfn(options);
- }.bind(this), intialNickname, initialChannels);
+ }.bind(this), intialNickname, initialChannels, autoConnect);
}
});
initialize: function(parentObject, client, type, name) {
this.parent(parentObject, client, type, name);
- this.tab = new Element("span");
+ this.tab = new Element("a", {"href": "#"});
this.tab.addClass("tab");
this.tab.appendText(name);
- this.tab.addEvent("click", function() {
+ this.tab.addEvent("click", function(e) {
+ new Event(e).stop();
parentObject.selectWindow(this);
}.bind(this));
var bottompos = formdiv.getSize().y;
if(type == WINDOW_CHANNEL) {
- this.nicklist = new Element("div");
- this.nicklist.addClass("nicklist");
- this.nicklist.setStyle("bottom", (bottompos - 1) + "px");
-
- this.window.appendChild(this.nicklist);
- rightpos = this.nicklist.getSize().x;
-
this.topic = new Element("div");
this.topic.addClass("topic");
this.topic.set("html", " ");
- this.topic.setStyle("right", rightpos + "px");
+ this.topic.setStyle("right", "0px");
this.window.appendChild(this.topic);
toppos = this.topic.getSize().y;
+
+ this.nicklist = new Element("div");
+ this.nicklist.addClass("nicklist");
+ this.nicklist.setStyle("top", toppos + "px");
+ this.nicklist.setStyle("bottom", (bottompos - 1) + "px");
+
+ this.window.appendChild(this.nicklist);
+ rightpos = this.nicklist.getSize().x;
}
this.lines.setStyle("top", toppos + "px");
while(t.firstChild)
t.removeChild(t.firstChild);
- Colourise(topic, t);
+ if(topic) {
+ Colourise(topic, "[" + topic + "]");
+ } else {
+ var e = new Element("(no topic set)");
+ e.addClass("emptytopic");
+ topic.appendChild(e);
+ }
},
select: function() {
this.window.removeClass("tab-invisible");
this.container.addClass("container");
this.outerContainer.appendChild(this.container);
},
- loginBox: function(callbackfn, intialNickname, initialChannels) {
+ loginBox: function(callbackfn, intialNickname, initialChannels, autoConnect, autoNick) {
this.parent(function(options) {
this.postInitialize();
callbackfn(options);
- }.bind(this), intialNickname, initialChannels);
+ }.bind(this), intialNickname, initialChannels, autoConnect, autoNick);
}
});
resize: function() {
window.fireEvent("resize");
},
- loginBox: function(callback, initialNickname, initialChannels) {
- var box = new Element("div");
- this.parentElement.appendChild(box);
-
- var header = new Element("h1");
- header.set("text", "qwebirc");
- box.appendChild(header);
-
- var form = new Element("form");
- box.appendChild(form);
-
- var boxtable = new Element("table");
- form.appendChild(boxtable);
-
- var tbody = new Element("tbody");
- boxtable.appendChild(tbody); /* stupid IE */
-
- function createRow(label, e2) {
- var r = new Element("tr");
- tbody.appendChild(r);
-
- var d1 = new Element("td");
- if(label)
- d1.set("text", label);
- r.appendChild(d1);
-
- var d2 = new Element("td");
- r.appendChild(d2);
- d2.appendChild(e2);
- return d1;
- }
-
- var nick = new Element("input");
- createRow("Nickname:", nick);
- var chan = new Element("input");
- createRow("Channels (comma seperated):", chan);
-
- var connbutton = new Element("input", {"type": "submit"});
- connbutton.set("value", "Connect");
- createRow(undefined, connbutton)
-
- form.addEvent("submit", function(e) {
- new Event(e).stop();
- var nickname = nick.value;
- var chans = chan.value;
- if(chans == "#") /* sorry channel "#" :P */
- chans = "";
-
- if(!nickname) {
- alert("You must supply a nickname.");
- nick.focus();
- return;
- }
-
- this.parentElement.removeChild(box);
+ loginBox: function(callback, initialNickname, initialChannels, autoConnect) {
+ this.parent(function(options) {
this.postInitialize();
- callback({"nickname": nickname, "autojoin": chans});
- }.bind(this));
-
- nick.set("value", initialNickname);
- chan.set("value", initialChannels);
-
- nick.focus();
+ callbackfn(options);
+ }.bind(this), intialNickname, initialChannels, autoConnect);
}
});
form.appendChild(inputbox);
inputbox.focus();
},
- loginBox: function(callbackfn, intialNickname, initialChannels) {
+ loginBox: function(callbackfn, intialNickname, initialChannels, autoConnect, autoNick) {
this.parent(function(options) {
this.postInitialize();
callbackfn(options);
- }.bind(this), intialNickname, initialChannels);
+ }.bind(this), intialNickname, initialChannels, autoConnect, autoNick);
}
});
.qwebirc-qui .tabbar {
- border: 1px solid black;
+ border: 1px solid #c3cee0;
padding: 4px;
+ background: #e2ecf9;
font-size: 0.8em;
font-family: Verdana, sans-serif;
+ color: #000000;
}
.qwebirc-qui .tab {
- border: 1px black solid;
+ border: 1px solid #e2ecf9;
padding: 2px;
cursor: default;
margin-right: 2px;
- background: #eee;
clear: both;
}
+.qwebirc-qui a.tab {
+ text-decoration: none;
+ color: #000000;
+}
+
+.qwebirc-qui a.tab:visited {
+ color: #000000;
+}
+
+.qwebirc-qui .tab:hover {
+ background: #ffffff;
+ border: 1px solid #c8d2dc;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+}
+
+.qwebirc-qui .tab-selected {
+ background: #ffffff;
+ border: 1px solid #c8d2dc;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ color: #333333;
+}
+
.qwebirc-qui .input input {
- border: 0px solid black;
+ border: 0px;
margin: 2px 0px 0px 0px;
width: 100%;
font-family: Verdana, sans-serif;
right: 0px;
bottom: 0px;
position: absolute;
- border-top: 1px solid black;
+ border-top: 1px solid #c8d2dc;
+ padding-left: 2px;
+ padding-right: 2px;
}
.qwebirc-qui .tabclose {
- border: 1px black solid;
margin-left: 5px;
padding: 2px;
- font-size: 0.5em;
+ font-size: 0.7em;
+ vertical-align: top;
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
}
.qwebirc-qui .nicklist {
- border-left: 1px solid black;
+ border-left: 1px solid #c8d2dc;
position: absolute;
top: 0px;
right: 0px;
width: 125px;
overflow: auto;
- background: white;
+ background: #f2f0ff;
+ color: black;
font-family: Verdana, sans-serif;
font-size: 0.7em;
}
display: none;
}
-.qwebirc-qui .tab-selected {
- background: #eeffff;
-}
-
-.qwebirc-qui .linestyle1 {
+/*.qwebirc-qui .linestyle1 {
background: #efefef;
}
.qwebirc-qui .linestyle2 {
background: #eeffff;
-}
+}*/
.qwebirc-qui .tab-hilighted {
color: red;
position: absolute;
left: 0px;
top: 0px;
+ background-color: #F2F0FF;
+ border-bottom: 1px dashed #c8d2dc;
+}
+
+.qwebirc-qui .topic .emptytopic {
+ color: grey;
}
.qwebirc-qui .lines {
overflow: auto;
position: absolute;
left: 0px;
- font-family: Consolas, "Lucida Console", monospace, sans-serif;
+ font-family: Verdana;
+ font-size: 0.8em;
+ background: #f2f0ff;
}
.qwebirc-qui .lines div {
<script type="text/javascript" src="js/debug/ui/colour.js"></script>
<script type="text/javascript" src="js/debug/ui/url.js"></script>
<script type="text/javascript" src="js/debug/ui/theme.js"></script>
+ <script type="text/javascript" src="js/debug/ui/genericlogin.js"></script>
<script type="text/javascript" src="js/debug/ui/mochaui.js"></script>
<script type="text/javascript" src="js/debug/qwebircinterface.js"></script>
<script type="text/javascript">
<script type="text/javascript" src="js/debug/ui/colour.js"></script>
<script type="text/javascript" src="js/debug/ui/url.js"></script>
<script type="text/javascript" src="js/debug/ui/theme.js"></script>
+ <script type="text/javascript" src="js/debug/ui/genericlogin.js"></script>
<script type="text/javascript" src="js/debug/ui/qui.js"></script>
<script type="text/javascript" src="js/debug/qwebircinterface.js"></script>
<script type="text/javascript">
<script type="text/javascript" src="js/debug/ui/colour.js"></script>
<script type="text/javascript" src="js/debug/ui/url.js"></script>
<script type="text/javascript" src="js/debug/ui/theme.js"></script>
+ <script type="text/javascript" src="js/debug/ui/genericlogin.js"></script>
<script type="text/javascript" src="js/debug/ui/swmlayout.js"></script>
<script type="text/javascript" src="js/debug/ui/swmui.js"></script>
<script type="text/javascript" src="js/debug/qwebircinterface.js"></script>
<script type="text/javascript" src="js/debug/ui/colour.js"></script>
<script type="text/javascript" src="js/debug/ui/url.js"></script>
<script type="text/javascript" src="js/debug/ui/theme.js"></script>
+ <script type="text/javascript" src="js/debug/ui/genericlogin.js"></script>
<script type="text/javascript" src="js/debug/ui/uglyui.js"></script>
<script type="text/javascript" src="js/debug/qwebircinterface.js"></script>
<script type="text/javascript">