Skip to content

Commit

Permalink
Merge pull request #131 from DeForce/develop
Browse files Browse the repository at this point in the history
Release 0.3.0
  • Loading branch information
DeForce authored Oct 30, 2016
2 parents ee522b2 + 3234895 commit 811e54b
Show file tree
Hide file tree
Showing 108 changed files with 1,930 additions and 875 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ levels.db*
/conf
*.spec
*.log
govno_rutony.py
747 changes: 445 additions & 302 deletions gui.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion http/czt/css/czt.css → http/czt/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body{
.msg{
background-color: rgba( 35, 35, 37, 0.627451 );
font-family: 'Consolas', serif;
font-size: 13pt;
font-size: {{ font_size }}pt;
text-shadow: 0 1px 1px black;
padding-top: 2px;
word-wrap: break-word;
Expand Down
2 changes: 1 addition & 1 deletion http/czt/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

<script src="js/socket.js"></script>
<link rel="stylesheet" type="text/css" href="css/czt.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>

<body>
Expand Down
98 changes: 71 additions & 27 deletions http/czt/js/socket.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
var MAX_MESSAGES = 70;
var find_location = window.location.href;
var RegExp = /:(\d+)/;
var find_list = RegExp.exec(find_location.toString());
var find_port = find_list[1];
var ws_url = "ws://127.0.0.1:".concat(find_port, "/ws");

// Chat settings
var timeout = 0;
var loadHistory = true;

var socket = new WebSocket(ws_url);

var chatMessages;
socket.onopen = function() {
//console.log("Соединение установлено.");
console.log("Socket connected")
chatMessages = document.getElementById('ChatContainer');
};

socket.onclose = function(event) {
if (event.wasClean) {
//console.log('Соединение закрыто чисто');
} else {
//console.log('Обрыв соединения'); // например, "убит" процесс сервера
console.log("Socket closed cleanly")
}
else {
console.log("Socket closed not cleanly")
}
//console.log('Код: ' + event.code + ' причина: ' + event.reason);
};

socket.onmessage = function(event) {
var incomingMessage = event.data;
showMessage(incomingMessage);
var incomingMessage = JSON.parse(event.data);
if(incomingMessage.hasOwnProperty('command')) {
runCommand(incomingMessage);
}
else {
if (loadHistory) {
showMessage(incomingMessage);
}
else if (!incomingMessage.hasOwnProperty('history')) {
showMessage(incomingMessage);
}
}
};

socket.onerror = function(error) {
//console.log("Ошибка " + error.message);
};

twitch_processEmoticons = function(message, emotes) {
Expand Down Expand Up @@ -92,18 +109,37 @@ escapeHtml = (function () {
};
}());

function removeMessage(element) {
var elm = element || chatMessages.lastChild;
chatMessages.removeChild(elm);
}

function updateMessages() {
if(chatMessages.children.length < MAX_MESSAGES) return;
var element = chatMessages.lastChild;
if(element.hasAttribute('timer-id')) {
var timerId = element.getAttribute('timer-id');
window.clearTimeout(timerId);
}
removeMessage(element);
}


function showMessage(message) {
var badge_colors = 1;

var elements = {};
elements['message'] = document.createElement('div');
elements.message.setAttribute('class', 'msg');

var messageJSON = JSON.parse(message);

if(timeout > 0) {
elements.message.setAttribute('timer-id', setTimeout(removeMessage, timeout * 1000, elements.message));
}

var messageJSON = message;

if(messageJSON.hasOwnProperty('source')) {
//console.log("message has source " + messageJSON.source);

elements.message['source'] = document.createElement('div');
elements.message.source.setAttribute('class', 'msgSource');

Expand All @@ -119,44 +155,44 @@ function showMessage(message) {
elements.message.source.appendChild(elements.message.source.img);
elements.message.appendChild(elements.message.source);
}

if(messageJSON.hasOwnProperty('levels')) {
elements.message['level'] = document.createElement('div');
elements.message.level.setAttribute('class', 'msgLevel');

elements.message.level['img'] = document.createElement('img');
elements.message.level.img.setAttribute('class', 'imgLevel');
elements.message.level.img.setAttribute('src', messageJSON.levels.url);

elements.message.level.appendChild(elements.message.level.img);
elements.message.appendChild(elements.message.level);
}

if(messageJSON.hasOwnProperty('s_levels')) {

for (i = 0; i < messageJSON.s_levels.length; i++) {
elements.message['s_level'] = document.createElement('div');
elements.message.s_level.setAttribute('class', 'msgSLevel');

elements.message.s_level['img'] = document.createElement('img');
elements.message.s_level.img.setAttribute('class', 'imgSLevel');
elements.message.s_level.img.setAttribute('src', messageJSON.s_levels[i].url);

elements.message.s_level.appendChild(elements.message.s_level.img);
elements.message.appendChild(elements.message.s_level);
}
}

if(messageJSON.hasOwnProperty('badges')) {

for (i = 0; i < messageJSON.badges.length; i++) {
elements.message['badge'] = document.createElement('div');
elements.message.badge.setAttribute('class', 'msgBadge');

elements.message.badge['img'] = document.createElement('img');
elements.message.badge.img.setAttribute('class', 'imgBadge');
elements.message.badge.img.setAttribute('src', messageJSON.badges[i].url);

if(badge_colors) {
if(messageJSON.badges[i].badge == 'broadcaster') {
elements.message.badge.img.setAttribute('style', 'background-color: #e71818');
Expand All @@ -172,7 +208,7 @@ function showMessage(message) {
elements.message.appendChild(elements.message.badge);
}
}

if(messageJSON.hasOwnProperty('user')) {
// console.log("message has user " + messageJSON.user);
elements.message['user'] = document.createElement('div');
Expand All @@ -189,10 +225,10 @@ function showMessage(message) {
}

elements.message.user.appendChild(document.createTextNode(addString));

elements.message.appendChild(elements.message.user);
}

if(messageJSON.hasOwnProperty('text')) {
// console.log("message has text " + messageJSON.text);
elements.message['text'] = document.createElement('div');
Expand All @@ -208,7 +244,7 @@ function showMessage(message) {
else {
elements.message.text.setAttribute('class', 'msgText');
}

if(messageJSON.source == 'tw') {
messageJSON.text = htmlifyTwitchEmoticons(escapeHtml(twitch_processEmoticons(messageJSON.text, messageJSON.emotes)));
if(messageJSON.hasOwnProperty('bttv_emotes')) {
Expand All @@ -221,11 +257,19 @@ function showMessage(message) {
else if(messageJSON.source == 'fs') {
messageJSON.text = htmlifyGGEmoticons(escapeHtml(messageJSON.text), messageJSON.emotes)
}

// elements.message.text.appendChild(document.createTextNode(messageJSON.text));
elements.message.text.innerHTML = messageJSON.text;

elements.message.appendChild(elements.message.text);

}
document.getElementById('ChatContainer').appendChild(elements.message);
updateMessages();
}

function runCommand(message) {
if(message.command == 'reload'){
window.location.reload();
}
}
77 changes: 77 additions & 0 deletions http/czt_timed/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
::-webkit-scrollbar {
visibility: hidden;
}
body{
margin: 0;
}
#ChatContainer{
position: absolute;
bottom: 0;
width: 100%;
}
.msg{
background-color: rgba( 35, 35, 37, 0.627451 );
font-family: 'Consolas', serif;
font-size: {{ font_size }}pt;
text-shadow: 0 1px 1px black;
padding-top: 2px;
word-wrap: break-word;
color: #FFFFFF;
}
.msgSource,
.msgBadge,
.msgLevel,
.msgSLevel{
width: 16px;
height: 16px;
background-color: rgba(0,0,0,0.6);
border-radius: 3px;
margin: 0 3px 0 0;
position: relative;
top: 3px;
left: 3px;
display: inline-block;
}
.msgUser{
display: inline-block;
position: relative;
padding-left: 5px;
}
.msgText{
display: inline;
height: auto;
padding-left: 5px;
}
.msgTextPriv{
display: inline;
height: auto;
padding-left: 5px;
color: #e57017;
}
.msgTextMention{
display: inline;
height: auto;
padding-left: 5px;
color: #c0ffc0;
}
.msgTextSystem{
display: inline;
height: auto;
padding-left: 5px;
color: #ff68fb;
}
.imgSmile{
margin-top: -4px;
height: 20px;
width: auto;
top: 2px;
position: relative;
}
.imgBadge,
.imgSource,
.imgLevel,
.imgSLevel{
width: 16px;
height: 16px;
border-radius: 3px;
}
Binary file added http/czt_timed/img/levels/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added http/czt_timed/img/levels/31.png
Binary file added http/czt_timed/img/levels/32.png
Binary file added http/czt_timed/img/levels/33.png
Binary file added http/czt_timed/img/levels/34.png
Binary file added http/czt_timed/img/levels/35.png
Binary file added http/czt_timed/img/levels/36.png
Binary file added http/czt_timed/img/levels/37.png
Binary file added http/czt_timed/img/levels/38.png
Binary file added http/czt_timed/img/levels/39.png
Binary file added http/czt_timed/img/levels/4.png
Binary file added http/czt_timed/img/levels/40.png
Binary file added http/czt_timed/img/levels/41.png
Binary file added http/czt_timed/img/levels/42.png
Binary file added http/czt_timed/img/levels/43.png
Binary file added http/czt_timed/img/levels/5.png
Binary file added http/czt_timed/img/levels/6.png
Binary file added http/czt_timed/img/levels/7.png
Binary file added http/czt_timed/img/levels/8.png
Binary file added http/czt_timed/img/levels/9.png
Binary file added http/czt_timed/img/levels/cube.png
Binary file added http/czt_timed/img/sources/cybergame.png
Binary file added http/czt_timed/img/sources/empire.png
Binary file added http/czt_timed/img/sources/fs.png
Binary file added http/czt_timed/img/sources/gamerstv.png
Binary file added http/czt_timed/img/sources/gg.png
Binary file added http/czt_timed/img/sources/gipsyteam.png
Binary file added http/czt_timed/img/sources/gohatv.png
Binary file added http/czt_timed/img/sources/hitboxtv.png
Binary file added http/czt_timed/img/sources/lalka_cup.png
Binary file added http/czt_timed/img/sources/midlane.png
Binary file added http/czt_timed/img/sources/streamcube.png
Binary file added http/czt_timed/img/sources/tw.png
Binary file added http/czt_timed/img/sources/youtube.png
12 changes: 12 additions & 0 deletions http/czt_timed/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<head>
<title>LalkaChat</title>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/socket.js"></script>
</head>

<body>
<div id='ChatContainer'></div>
</body>
Loading

0 comments on commit 811e54b

Please sign in to comment.