stuff lol

This commit is contained in:
Evert Prants 2016-12-07 14:58:20 +02:00
parent cc0df245c6
commit 4cdec52820
9 changed files with 249 additions and 62 deletions

View File

@ -222,7 +222,7 @@ body {
width: 25px; width: 25px;
display: inline-block; display: inline-block;
} }
.ircclient #chat .ircwrapper .chatarea .settings { .ircclient #chat .ircwrapper .chatarea .applet_default {
position: absolute; position: absolute;
top: 0; top: 0;
bottom: 0; bottom: 0;
@ -234,6 +234,11 @@ body {
margin: auto; margin: auto;
overflow: auto; overflow: auto;
} }
.ircclient #chat .ircwrapper .chatarea .applet_default .grade1,
.ircclient #chat .ircwrapper .chatarea .applet_default .grade2,
.ircclient #chat .ircwrapper .chatarea .applet_default .grade3 {
text-align: left;
}
.ircclient #chat .ircwrapper .chatarea .settings .theme_button { .ircclient #chat .ircwrapper .chatarea .settings .theme_button {
width: 120px; width: 120px;
height: 140px; height: 140px;
@ -257,11 +262,6 @@ body {
text-align: center; text-align: center;
display: block; display: block;
} }
.ircclient #chat .ircwrapper .chatarea .settings .grade1,
.ircclient #chat .ircwrapper .chatarea .settings .grade2,
.ircclient #chat .ircwrapper .chatarea .settings .grade3 {
text-align: left;
}
.ircclient #chat .ircwrapper .chatarea.vnicks .nicklist { .ircclient #chat .ircwrapper .chatarea.vnicks .nicklist {
display: block; display: block;
} }

View File

@ -460,3 +460,23 @@
.topicbar .irc-underline { .topicbar .irc-underline {
text-decoration: underline; text-decoration: underline;
} }
@-moz-keyframes hotTab {
50% {
background-color: #6eebff;
}
}
@-webkit-keyframes hotTab {
50% {
background-color: #6eebff;
}
}
@-o-keyframes hotTab {
50% {
background-color: #6eebff;
}
}
@keyframes hotTab {
50% {
background-color: #6eebff;
}
}

View File

@ -82,6 +82,9 @@ a:hover {
box-shadow: inset 4px 4px 8px #00d1ea; box-shadow: inset 4px 4px 8px #00d1ea;
color: #fff; color: #fff;
} }
.ircclient #chat .ircwrapper .toolbar .tabby .tab.hot {
animation: hotTab 1s linear infinite;
}
.ircclient #chat .ircwrapper .toolbar .tabby .tab #unread { .ircclient #chat .ircwrapper .toolbar .tabby .tab #unread {
background-color: #bf0000; background-color: #bf0000;
border: 1px solid #b00; border: 1px solid #b00;
@ -475,3 +478,23 @@ a:hover {
.topicbar .irc-underline { .topicbar .irc-underline {
text-decoration: underline; text-decoration: underline;
} }
@-moz-keyframes hotTab {
50% {
background-color: #3ee4ff;
}
}
@-webkit-keyframes hotTab {
50% {
background-color: #3ee4ff;
}
}
@-o-keyframes hotTab {
50% {
background-color: #3ee4ff;
}
}
@keyframes hotTab {
50% {
background-color: #3ee4ff;
}
}

View File

@ -58,7 +58,7 @@
<div class="topicbar"></div> <div class="topicbar"></div>
<div class="letterbox"></div> <div class="letterbox"></div>
<div class="nicklist"></div> <div class="nicklist"></div>
<div class="settings" style="display: none;"> <div class="settings applet applet_default" style="display: none;">
<h1 class="grade1">Teemant Settings</h1> <h1 class="grade1">Teemant Settings</h1>
<h1 class="grade2">Chat</h1> <h1 class="grade2">Chat</h1>
<p><label for="s_scrollOnResize">Scroll to bottom on window resize</label> <input type="checkbox" id="s_scrollOnResize" checked="checked"></p> <p><label for="s_scrollOnResize">Scroll to bottom on window resize</label> <input type="checkbox" id="s_scrollOnResize" checked="checked"></p>
@ -80,6 +80,7 @@
<p><button class="regular_btn" id="save_settings">Save Settings</button></p> <p><button class="regular_btn" id="save_settings">Save Settings</button></p>
<span class="grade3" id="settings_status"></span> <span class="grade3" id="settings_status"></span>
</div> </div>
<div class="dialog" style="display: none;"></div>
</div> </div>
<div class="input"> <div class="input">
<div class="my_nickname">Test</div> <div class="my_nickname">Test</div>

View File

@ -147,7 +147,7 @@ Date.prototype.format = function (format, utc){
return format; return format;
}; };
irc.whoisMessage = function(whoisData, buffer) { function whoisMessage(whoisData, buffer) {
let messages = []; let messages = [];
for(let key in whoisData) { for(let key in whoisData) {
switch(key) { switch(key) {
@ -250,6 +250,15 @@ function linkify(text) {
return parsed; return parsed;
} }
function serialize(obj) {
let str = [];
for(let p in obj)
if (obj.hasOwnProperty(p)) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&");
}
function removeClass(element, cl) { function removeClass(element, cl) {
let classList = element.className.split(" "); let classList = element.className.split(" ");
@ -373,6 +382,54 @@ let composer = {
btn.setAttribute('id', 'theme-'+name); btn.setAttribute('id', 'theme-'+name);
return btn; return btn;
},
embedURL: function(server, port, defaultNick, useSSL, hideServerData, channels) {
let builder = window.location.origin + "/";
let params = {};
let final_channels = [];
if(server)
builder += server + "/";
if(channels)
channels = channels.trim();
if(defaultNick)
params.nickname = defaultNick;
if(port && port != 6667)
params.port = port;
if(useSSL)
params.secure = 1;
if(hideServerData)
params.server_data = 0;
if(Object.keys(params).length > 0)
builder += "?" + serialize(params);
if(channels) {
if(channels.indexOf(",")) {
let tmp = channels.split(',');
for(let i in tmp) {
tmp[i] = tmp[i].trim();
if(tmp[i].indexOf('#') != 0)
tmp[i] = "#"+tmp[i];
final_channels.push(tmp[i]);
}
} else {
if(channels.indexOf('#') != 0)
channels = '#'+channels;
final_channels.push(channels);
}
builder += final_channels.join(',');
}
return builder;
} }
} }
@ -384,6 +441,16 @@ let composer = {
// commandName: {execute: function(buffer, handler, command, message, listargs) {}, description: ""} // commandName: {execute: function(buffer, handler, command, message, listargs) {}, description: ""}
let commands = { let commands = {
embed: {execute: function(buffer, handler, command, message, listargs) {
let data = irc.auther.getDataFromForm();
let url = "Couldn't compose URL!";
if(data)
url = composer.embedURL(data.server, data.port, data.nickname, data.secure, true, data.autojoin.join(','));
buffer.addMessage(url, null, "help");
}, description: "- Embed URL for the current connection"},
join: {execute: function(buffer, handler, command, message, listargs) { join: {execute: function(buffer, handler, command, message, listargs) {
if (!listargs[1]) { if (!listargs[1]) {
if(!buffer.alive) { if(!buffer.alive) {
@ -794,6 +861,15 @@ class Tab {
} }
} }
setHot(hot) {
if(this.element) {
if(hot)
addClass(this.element, "hot");
else
removeClass(this.element, "hot");
}
}
setUnreadCount(count) { setUnreadCount(count) {
if(this.element) { if(this.element) {
let counter = this.element.querySelector('#unread'); let counter = this.element.querySelector('#unread');
@ -834,6 +910,7 @@ class Buffer {
this.type = type; this.type = type;
this.active = false; this.active = false;
this.alive = true; this.alive = true;
this.hot = false;
if(type != "applet") { if(type != "applet") {
this.tab = new Tab(this); this.tab = new Tab(this);
@ -862,6 +939,9 @@ class Buffer {
this.nicklist.render(); this.nicklist.render();
} }
if(this.hot)
this.setHotStatus(false);
if(this.topic != null && this.topic != "") { if(this.topic != null && this.topic != "") {
addClass(clientdom.chat, 'vtopic'); addClass(clientdom.chat, 'vtopic');
if(irc.config.colors) if(irc.config.colors)
@ -899,6 +979,12 @@ class Buffer {
clientdom.letterbox.innerHTML = ""; clientdom.letterbox.innerHTML = "";
} }
setHotStatus(hot) {
this.hot = hot;
if(this.tab)
this.tab.setHot(hot);
}
appendMessage(meta) { appendMessage(meta) {
let mesgConstr = composer.message[irc.chatType](meta.time, meta.sender, meta.message, meta.type); let mesgConstr = composer.message[irc.chatType](meta.time, meta.sender, meta.message, meta.type);
@ -940,8 +1026,12 @@ class Buffer {
if(irc.serverData[this.server]) { if(irc.serverData[this.server]) {
let mynick = irc.serverData[this.server].my_nick; let mynick = irc.serverData[this.server].my_nick;
if((type == "privmsg" || type == "notice" || type == "action") && if((type == "privmsg" || type == "notice" || type == "action") &&
message.toLowerCase().indexOf(mynick.toLowerCase()) != -1 && sender != mynick) message.toLowerCase().indexOf(mynick.toLowerCase()) != -1 && sender != mynick) {
console.log("TODO: notify user of mentioned"); // TODO: notify user of mentioned
if(!this.active)
this.setHotStatus(true);
}
} }
} }
@ -1021,12 +1111,55 @@ class ThemeSelector {
} }
} }
class Settings extends Buffer { class AppletBuffer extends Buffer {
constructor() { constructor(appletName, title, frame) {
super("", "settings", "Settings", "applet"); super("", appletName, title, "applet");
this.tab = null; this.tab = null;
this.isOpen = false; this.isOpen = false;
this.timeout = null; this.timeout = null;
this.frame = frame;
}
closeBuffer() {
irc.chat.closeBuffer(this);
this.tab = null;
this.isOpen = false;
}
open() {
if(this.isOpen) {
irc.chat.render(this);
return;
}
this.tab = new Tab(this);
this.tab.renderTab();
irc.chat.buffers.push(this);
irc.chat.render(this);
this.isOpen = true;
}
addMessage(message, sender, type, time) {
// Don't send messages to any applet buffer
return;
}
switchOff() {
this.active = false;
this.tab.setActive(false);
this.frame.style.display = "none";
}
render() {
this.active = true;
this.tab.setActive(true);
this.frame.style.display = "block";
}
}
class Settings extends AppletBuffer {
constructor() {
super("settings", "Settings", clientdom.settings.frame);
this.themeSelection = ""; this.themeSelection = "";
@ -1050,25 +1183,6 @@ class Settings extends Buffer {
} }
} }
open() {
if(this.isOpen) {
irc.chat.render(this);
return;
}
this.tab = new Tab(this);
this.tab.renderTab();
irc.chat.buffers.push(this);
irc.chat.render(this);
this.isOpen = true;
}
closeBuffer() {
irc.chat.closeBuffer(this);
this.tab = null;
this.isOpen = false;
}
saveSpecified() { saveSpecified() {
if(this.timeout) if(this.timeout)
clearTimeout(this.timeout); clearTimeout(this.timeout);
@ -1137,25 +1251,12 @@ class Settings extends Buffer {
} }
} }
addMessage(message, sender, type, time) {
// Don't send messages to the settings buffer
return;
}
switchOff() {
this.active = false;
this.tab.setActive(false);
clientdom.settings.frame.style.display = "none";
}
render() { render() {
this.active = true; super.render();
this.tab.setActive(true);
clientdom.chat.className = "chatarea"; clientdom.chat.className = "chatarea";
clientdom.nicklist.innerHTML = ""; clientdom.nicklist.innerHTML = "";
clientdom.topicbar.innerHTML = ""; clientdom.topicbar.innerHTML = "";
clientdom.letterbox.innerHTML = ""; clientdom.letterbox.innerHTML = "";
clientdom.settings.frame.style.display = "block";
irc.chat.changeTitle("TeemantIRC - Settings"); irc.chat.changeTitle("TeemantIRC - Settings");
} }
} }
@ -1213,6 +1314,13 @@ class IRCConnector {
if(window.validators.iporhost(value)) if(window.validators.iporhost(value))
clientdom.connector.server.value = value; clientdom.connector.server.value = value;
break; break;
case "server_data":
case "extra":
case "extras":
case "connection":
if(value == "false" || value == "0")
clientdom.connector.server_data.style.display = "none";
break;
case "port": case "port":
try { try {
let ppp = parseInt(value); let ppp = parseInt(value);
@ -1240,9 +1348,7 @@ class IRCConnector {
} }
} }
validateForm(event) { getDataFromForm() {
event.preventDefault();
let nickname = clientdom.connector.nickname.value; let nickname = clientdom.connector.nickname.value;
let password = clientdom.connector.password.value; let password = clientdom.connector.password.value;
let channel = clientdom.connector.channel.value; let channel = clientdom.connector.channel.value;
@ -1296,12 +1402,21 @@ class IRCConnector {
if(!clientdom.connector.pwtrigger.checked) if(!clientdom.connector.pwtrigger.checked)
password = ""; password = "";
irc.socket.emit('irc_create', {nickname: nickname, return {nickname: nickname,
autojoin: channel, autojoin: channel,
server: server, server: server,
port: port, port: port,
password: password, password: password,
secure: clientdom.connector.secure.checked }); secure: clientdom.connector.secure.checked }
}
validateForm(event) {
event.preventDefault();
let data = this.getDataFromForm();
if(!data) return;
irc.socket.emit('irc_create', data);
return true; return true;
} }
@ -1498,10 +1613,12 @@ class InputHandler {
class IRCChatWindow { class IRCChatWindow {
constructor() { constructor() {
this.buffers = []; this.buffers = [];
clientdom.frame.style.display = "none";
this.firstServer = true; this.firstServer = true;
this.currentBuffer = null; this.currentBuffer = null;
this.input_handler = new InputHandler(); this.input_handler = new InputHandler();
clientdom.frame.style.display = "none";
clientdom.smsctrig.onclick = (e) => { clientdom.smsctrig.onclick = (e) => {
toggleClass(clientdom.chat, "vopentrig"); toggleClass(clientdom.chat, "vopentrig");
} }
@ -1520,6 +1637,7 @@ class IRCChatWindow {
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;
window.onbeforeunload = null;
} }
getBufferByName(buffername) { getBufferByName(buffername) {
@ -1885,6 +2003,11 @@ function parseURL() {
irc.auther.fillFormFromURI(); irc.auther.fillFormFromURI();
} }
function stopWarnings() {
if(Object.keys(irc.serverData).length == 0)
window.onbeforeunload = null;
}
window.onpopstate = parseURL; window.onpopstate = parseURL;
window.onresize = function() { window.onresize = function() {
@ -1905,6 +2028,7 @@ window.onload = function() {
clientdom.settings['save'] = clientdom.settings.frame.querySelector('#save_settings'); clientdom.settings['save'] = clientdom.settings.frame.querySelector('#save_settings');
clientdom.settings['saveStatus'] = clientdom.settings.frame.querySelector('#settings_status'); clientdom.settings['saveStatus'] = clientdom.settings.frame.querySelector('#settings_status');
clientdom.connector['frame'] = irc.primaryFrame.querySelector('#authdialog'); clientdom.connector['frame'] = irc.primaryFrame.querySelector('#authdialog');
clientdom.connector['server_data'] = clientdom.connector.frame.querySelector('.server_data');
clientdom.connector['messenger'] = clientdom.connector.frame.querySelector('#connmsg'); clientdom.connector['messenger'] = clientdom.connector.frame.querySelector('#connmsg');
clientdom.connector['form'] = clientdom.connector.frame.querySelector('#IRCConnector'); clientdom.connector['form'] = clientdom.connector.frame.querySelector('#IRCConnector');
clientdom.connector['nickname'] = clientdom.connector.form.querySelector('#nickname'); clientdom.connector['nickname'] = clientdom.connector.form.querySelector('#nickname');
@ -1979,6 +2103,10 @@ window.onload = function() {
serv.addMessage("You are no longer talking on this server.", null, "error"); serv.addMessage("You are no longer talking on this server.", null, "error");
serv.setAliveStatus(false); serv.setAliveStatus(false);
} }
if(irc.serverData[data.server])
delete irc.serverData[data.server];
stopWarnings();
break; break;
case "message": case "message":
if(data.to == irc.serverData[data.server].my_nick) { if(data.to == irc.serverData[data.server].my_nick) {
@ -2029,7 +2157,7 @@ window.onload = function() {
irc.auther.authMessage(data.message, data.error); irc.auther.authMessage(data.message, data.error);
break; break;
case "whoisResponse": case "whoisResponse":
irc.whoisMessage(data.whois, irc.chat.getActiveBuffer()); whoisMessage(data.whois, irc.chat.getActiveBuffer());
break; break;
case "listedchan": case "listedchan":
irc.chat.messageBuffer(data.server, data.server, {message: "<span class='channel'>"+data.channel+"</span>"+ irc.chat.messageBuffer(data.server, data.server, {message: "<span class='channel'>"+data.channel+"</span>"+

View File

@ -196,7 +196,7 @@ body
.no-prefix .no-prefix
width: 25px; width: 25px;
display: inline-block; display: inline-block;
.settings .applet_default
position: absolute; position: absolute;
top: 0; top: 0;
bottom: 0; bottom: 0;
@ -207,6 +207,9 @@ body
min-width: 360px; min-width: 360px;
margin: auto; margin: auto;
overflow: auto; overflow: auto;
.grade1, .grade2, .grade3
text-align: left;
.settings
.theme_button .theme_button
width: 120px width: 120px
height: 140px height: 140px
@ -226,8 +229,6 @@ body
width: 100% width: 100%
text-align: center text-align: center
display: block display: block
.grade1, .grade2, .grade3
text-align: left;
&.vnicks &.vnicks
.nicklist .nicklist
display: block; display: block;

View File

@ -285,3 +285,7 @@ box-shadow()
font-style: italic font-style: italic
.irc-underline .irc-underline
text-decoration: underline text-decoration: underline
@keyframes hotTab
50%
background-color: #6eebff

View File

@ -68,6 +68,8 @@ a:hover
background-size: contain background-size: contain
.tabby .tabby
.tab .tab
&.hot
animation: hotTab 1s linear infinite;
background-color: #00bfde background-color: #00bfde
border: 1px solid #0092a5 border: 1px solid #0092a5
box-shadow inset 4px 4px 8px #00d1ea box-shadow inset 4px 4px 8px #00d1ea
@ -295,3 +297,7 @@ a:hover
font-style: italic font-style: italic
.irc-underline .irc-underline
text-decoration: underline text-decoration: underline
@keyframes hotTab
50%
background-color: #3ee4ff

View File

@ -257,12 +257,16 @@ class IRCConnectionHandler {
case "376": case "376":
this.conn.emit('pass_to_client', {type: "server_message", messageType: "motd", message: line.trailing, server: serverName, from: realServerName}); this.conn.emit('pass_to_client', {type: "server_message", messageType: "motd", message: line.trailing, server: serverName, from: realServerName});
break; break;
case "351": case "006":
case "007":
case "251": case "251":
case "255":
case "270":
case "290": case "290":
case "292": case "292":
case "323":
case "351":
case "381": case "381":
case "255":
this.conn.emit('pass_to_client', {type: "server_message", messageType: "regular", message: line.trailing, server: serverName, from: realServerName}); this.conn.emit('pass_to_client', {type: "server_message", messageType: "regular", message: line.trailing, server: serverName, from: realServerName});
break; break;
case "252": case "252":