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>
|
<i class="grade3" id="connmsg">Think of a nickname</i>
|
||||||
<form action="" id="IRCConnector">
|
<form action="" id="IRCConnector">
|
||||||
<label for="nickname">Nickname</label>
|
<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>
|
<label for="channel">Channel</label>
|
||||||
<input type="text" name="channel" id="channel" value="#diamond">
|
<input type="text" name="channel" id="channel" value="#diamond">
|
||||||
<label for="server">Server</label>
|
<label for="server">Server</label>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="coverwindow" id="chat">
|
<div class="coverwindow" id="chat" style="display: none;">
|
||||||
<div class="ircwrapper">
|
<div class="ircwrapper">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<span class="logo"></span>
|
<span class="logo"></span>
|
||||||
|
@ -25,6 +25,8 @@ window.colorizer = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let urlParams = {};
|
||||||
|
|
||||||
/*********************\
|
/*********************\
|
||||||
|** **|
|
|** **|
|
||||||
|** UTILITIES **|
|
|** 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) {
|
validateForm(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
@ -897,11 +936,15 @@ class IRCChatWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroyAllBuffers() {
|
destroyAllBuffers() {
|
||||||
for(let b in this.buffers) {
|
// Wipe all server data
|
||||||
this.buffers[b].tab.element.remove();
|
|
||||||
this.buffers.splice(b, 1);
|
|
||||||
}
|
|
||||||
irc.serverData = {};
|
irc.serverData = {};
|
||||||
|
irc.serverChatQueue = {};
|
||||||
|
this.buffers = [];
|
||||||
|
|
||||||
|
// Clear tabs
|
||||||
|
clientdom.tabby.innerHTML = "";
|
||||||
|
|
||||||
|
// Reset to the defaults
|
||||||
irc.auther.authMessage("Disconnected", true);
|
irc.auther.authMessage("Disconnected", true);
|
||||||
clientdom.frame.style.display = "none";
|
clientdom.frame.style.display = "none";
|
||||||
this.firstServer = true;
|
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() {
|
window.onload = function() {
|
||||||
irc.primaryFrame = document.querySelector('.ircclient');
|
irc.primaryFrame = document.querySelector('.ircclient');
|
||||||
|
|
||||||
@ -1267,6 +1326,8 @@ window.onload = function() {
|
|||||||
irc.auther = new IRCConnector();
|
irc.auther = new IRCConnector();
|
||||||
irc.chat = new IRCChatWindow();
|
irc.chat = new IRCChatWindow();
|
||||||
|
|
||||||
|
parseURL();
|
||||||
|
|
||||||
irc.socket.on('connect', function (data) {
|
irc.socket.on('connect', function (data) {
|
||||||
irc.socketUp = true;
|
irc.socketUp = true;
|
||||||
});
|
});
|
||||||
@ -1364,4 +1425,4 @@ window.onload = function() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
@ -449,7 +449,7 @@ class IRCConnection extends EventEmitter {
|
|||||||
let serverpass = webirc.get_password(this.config.address);
|
let serverpass = webirc.get_password(this.config.address);
|
||||||
|
|
||||||
if(serverpass)
|
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('USER {0} 8 * :{1}\r\n'.format(this.config.username, this.config.realname));
|
||||||
this.socket.write('NICK {0}\r\n'.format(this.config.nickname));
|
this.socket.write('NICK {0}\r\n'.format(this.config.nickname));
|
||||||
|
13
teemant.js
13
teemant.js
@ -5,6 +5,7 @@ let path = require("path");
|
|||||||
let sockio = require("socket.io");
|
let sockio = require("socket.io");
|
||||||
let dns = require("dns");
|
let dns = require("dns");
|
||||||
let app = express();
|
let app = express();
|
||||||
|
let router = express.Router();
|
||||||
|
|
||||||
let pubdir = path.join(__dirname, "public");
|
let pubdir = path.join(__dirname, "public");
|
||||||
let config = require(__dirname+'/server/config');
|
let config = require(__dirname+'/server/config');
|
||||||
@ -16,11 +17,17 @@ let connections = {};
|
|||||||
|
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
|
|
||||||
app.get("/", function(req, res){
|
router.get("/", function(req, res){
|
||||||
res.sendFile(pubdir+"/index.html");
|
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() {
|
let io = sockio.listen(app.listen(port, function() {
|
||||||
console.log("*** Listening on http://localhost:" + port + "/");
|
console.log("*** Listening on http://localhost:" + port + "/");
|
||||||
@ -53,7 +60,7 @@ io.sockets.on('connection', function (socket) {
|
|||||||
|
|
||||||
// Get the hostname of the connecting user
|
// Get the hostname of the connecting user
|
||||||
let hostQuery = resolveHostname(userip);
|
let hostQuery = resolveHostname(userip);
|
||||||
hostQuery.then((arr) => {
|
hostQuery.then((arr) => {
|
||||||
if(arr.length > 0)
|
if(arr.length > 0)
|
||||||
connections[socket.id].host.hostname = arr[0];
|
connections[socket.id].host.hostname = arr[0];
|
||||||
if(config.server.debug)
|
if(config.server.debug)
|
||||||
|
Reference in New Issue
Block a user