easily embeddable
This commit is contained in:
parent
f688465164
commit
b05b6447eb
@ -24,7 +24,7 @@
|
||||
<i class="grade3" id="connmsg">Think of a nickname</i>
|
||||
<form action="" id="IRCConnector">
|
||||
<label for="nickname">Nickname</label>
|
||||
<input type="text" name="nickname" id="nickname" value="testuser">
|
||||
<input type="text" name="nickname" id="nickname" value="">
|
||||
<label for="channel">Channel</label>
|
||||
<input type="text" name="channel" id="channel" value="#diamond">
|
||||
<label for="server">Server</label>
|
||||
@ -37,7 +37,7 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="coverwindow" id="chat">
|
||||
<div class="coverwindow" id="chat" style="display: none;">
|
||||
<div class="ircwrapper">
|
||||
<div class="toolbar">
|
||||
<span class="logo"></span>
|
||||
|
@ -25,6 +25,8 @@ window.colorizer = {
|
||||
}
|
||||
}
|
||||
|
||||
let urlParams = {};
|
||||
|
||||
/*********************\
|
||||
|** **|
|
||||
|** UTILITIES **|
|
||||
@ -693,6 +695,43 @@ class IRCConnector {
|
||||
}
|
||||
}
|
||||
|
||||
fillFormFromURI() {
|
||||
for(let param in urlParams) {
|
||||
let value = urlParams[param];
|
||||
|
||||
switch(param) {
|
||||
case "nick":
|
||||
case "nickname":
|
||||
if (window.validators.nickname(value))
|
||||
clientdom.connector.nickname.value = value.replace(/\?/g, rand(10000, 99999));
|
||||
break;
|
||||
case "secure":
|
||||
case "ssl":
|
||||
if(value == "true" || value == "1")
|
||||
clientdom.connector.secure.checked = true;
|
||||
break;
|
||||
case "server":
|
||||
case "host":
|
||||
if(window.validators.iporhost(value))
|
||||
clientdom.connector.server.value = value;
|
||||
break;
|
||||
case "port":
|
||||
try {
|
||||
let ppp = parseInt(value);
|
||||
clientdom.connector.port.value = ppp;
|
||||
} catch(e) {}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(window.location.hash)
|
||||
clientdom.connector.channel.value = window.location.hash;
|
||||
if(window.location.pathname.length > 4) {
|
||||
let proposed = window.location.pathname.replace(/\//g, '');
|
||||
if(window.validators.iporhost(proposed))
|
||||
clientdom.connector.server.value = proposed;
|
||||
}
|
||||
}
|
||||
|
||||
validateForm(event) {
|
||||
event.preventDefault();
|
||||
|
||||
@ -897,11 +936,15 @@ class IRCChatWindow {
|
||||
}
|
||||
|
||||
destroyAllBuffers() {
|
||||
for(let b in this.buffers) {
|
||||
this.buffers[b].tab.element.remove();
|
||||
this.buffers.splice(b, 1);
|
||||
}
|
||||
// Wipe all server data
|
||||
irc.serverData = {};
|
||||
irc.serverChatQueue = {};
|
||||
this.buffers = [];
|
||||
|
||||
// Clear tabs
|
||||
clientdom.tabby.innerHTML = "";
|
||||
|
||||
// Reset to the defaults
|
||||
irc.auther.authMessage("Disconnected", true);
|
||||
clientdom.frame.style.display = "none";
|
||||
this.firstServer = true;
|
||||
@ -1240,6 +1283,22 @@ class IRCChatWindow {
|
||||
|** **|
|
||||
\**************************/
|
||||
|
||||
function parseURL() {
|
||||
let match,
|
||||
pl = /\+/g, // Regex for replacing addition symbol with a space
|
||||
search = /([^&=]+)=?([^&]*)/g,
|
||||
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
|
||||
query = window.location.search.substring(1);
|
||||
|
||||
urlParams = {};
|
||||
while (match = search.exec(query))
|
||||
urlParams[decode(match[1])] = decode(match[2]);
|
||||
|
||||
irc.auther.fillFormFromURI();
|
||||
}
|
||||
|
||||
window.onpopstate = parseURL;
|
||||
|
||||
window.onload = function() {
|
||||
irc.primaryFrame = document.querySelector('.ircclient');
|
||||
|
||||
@ -1267,6 +1326,8 @@ window.onload = function() {
|
||||
irc.auther = new IRCConnector();
|
||||
irc.chat = new IRCChatWindow();
|
||||
|
||||
parseURL();
|
||||
|
||||
irc.socket.on('connect', function (data) {
|
||||
irc.socketUp = true;
|
||||
});
|
||||
@ -1364,4 +1425,4 @@ window.onload = function() {
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -449,7 +449,7 @@ class IRCConnection extends EventEmitter {
|
||||
let serverpass = webirc.get_password(this.config.address);
|
||||
|
||||
if(serverpass)
|
||||
this.socket.write('WEBIRC {0} cgiirc {1} {2}\r\n'.format(serverpass, this.userInfo.hostname, this.userInfo.ipaddr));
|
||||
this.socket.write('WEBIRC {0} {1} {2} {3}\r\n'.format(serverpass, this.config.username, this.userInfo.hostname, this.userInfo.ipaddr));
|
||||
|
||||
this.socket.write('USER {0} 8 * :{1}\r\n'.format(this.config.username, this.config.realname));
|
||||
this.socket.write('NICK {0}\r\n'.format(this.config.nickname));
|
||||
|
11
teemant.js
11
teemant.js
@ -5,6 +5,7 @@ let path = require("path");
|
||||
let sockio = require("socket.io");
|
||||
let dns = require("dns");
|
||||
let app = express();
|
||||
let router = express.Router();
|
||||
|
||||
let pubdir = path.join(__dirname, "public");
|
||||
let config = require(__dirname+'/server/config');
|
||||
@ -16,11 +17,17 @@ let connections = {};
|
||||
|
||||
process.stdin.resume();
|
||||
|
||||
app.get("/", function(req, res){
|
||||
router.get("/", function(req, res){
|
||||
res.sendFile(pubdir+"/index.html");
|
||||
});
|
||||
|
||||
app.use(express.static(__dirname + '/public'));
|
||||
router.get("/:server", function(req, res){
|
||||
res.sendFile(pubdir+"/index.html");
|
||||
});
|
||||
|
||||
app.use('/', express.static(pubdir, { maxAge: 365*24*60*60*1000 }));
|
||||
app.use('/:server', express.static(pubdir, { maxAge: 365*24*60*60*1000 }));
|
||||
app.use('/', router);
|
||||
|
||||
let io = sockio.listen(app.listen(port, function() {
|
||||
console.log("*** Listening on http://localhost:" + port + "/");
|
||||
|
Reference in New Issue
Block a user