mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-02-11 08:03:02 +08:00
chat fixes
This commit is contained in:
parent
9de6d18a69
commit
393fe88297
@ -40,7 +40,7 @@ input.fake
|
|||||||
#chatInputHas strong
|
#chatInputHas strong
|
||||||
{
|
{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: bottom;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
height: 29px;
|
height: 29px;
|
||||||
line-height: 26px;
|
line-height: 26px;
|
||||||
@ -66,7 +66,7 @@ input.fake
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#chatInput > div:first-child
|
#chatInput * > div:first-child
|
||||||
{
|
{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -1,46 +1,7 @@
|
|||||||
function colorize(string)
|
function colorize(str)
|
||||||
{
|
{
|
||||||
var newString = '';
|
const s = "<span>" + (str.replace(/\^([0-9])/g, (str, color) => `</span><span class="color-${color}">`)) + "</span>";
|
||||||
var inSpan = false;
|
return s.replace(/<span[^>]*><\/span[^>]*>/g, '');
|
||||||
|
|
||||||
for (i = 0; i < string.length; i++)
|
|
||||||
{
|
|
||||||
if (string[i] == '^')
|
|
||||||
{
|
|
||||||
if (string[i + 1] == '7' || string[i + 1] == '0')
|
|
||||||
{
|
|
||||||
if (inSpan)
|
|
||||||
{
|
|
||||||
newString += '</span>';
|
|
||||||
|
|
||||||
inSpan = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
else if (string[i + 1] >= '0' && string[i + 1] <= '9')
|
|
||||||
{
|
|
||||||
if (inSpan)
|
|
||||||
{
|
|
||||||
newString += '</span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
i += 2;
|
|
||||||
newString += '<span class="color-' + string[i - 1] + '">';
|
|
||||||
|
|
||||||
inSpan = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newString += string[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inSpan)
|
|
||||||
{
|
|
||||||
newString += '</span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return newString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function()
|
$(function()
|
||||||
@ -112,13 +73,23 @@ $(function()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).keypress(function(e)
|
$(document).keydown(function(e)
|
||||||
{
|
{
|
||||||
if (e.keyCode == 9)
|
if (e.keyCode == 9)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (e.keyCode == 33)
|
||||||
|
{
|
||||||
|
let buf = $('#chatBuffer');
|
||||||
|
buf.scrollTop(buf.scrollTop() - 50);
|
||||||
|
}
|
||||||
|
else if (e.keyCode == 34)
|
||||||
|
{
|
||||||
|
let buf = $('#chatBuffer');
|
||||||
|
buf.scrollTop(buf.scrollTop() + 50);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('message', function(event)
|
window.addEventListener('message', function(event)
|
||||||
@ -129,7 +100,7 @@ $(function()
|
|||||||
{
|
{
|
||||||
inputShown = true;
|
inputShown = true;
|
||||||
|
|
||||||
$('#chat').css('opacity', '1');
|
$('#chat').stop().css('opacity', '1');
|
||||||
|
|
||||||
$('#chatInputHas').show();
|
$('#chatInputHas').show();
|
||||||
$('#chatInput')[0].doFocus();
|
$('#chatInput')[0].doFocus();
|
||||||
@ -145,6 +116,7 @@ $(function()
|
|||||||
var name = item.name.replace('<', '<');
|
var name = item.name.replace('<', '<');
|
||||||
var message = item.message.replace('<', '<');
|
var message = item.message.replace('<', '<');
|
||||||
|
|
||||||
|
name = colorize(name);
|
||||||
message = colorize(message);
|
message = colorize(message);
|
||||||
|
|
||||||
var buf = $('#chatBuffer');
|
var buf = $('#chatBuffer');
|
||||||
@ -159,7 +131,7 @@ $(function()
|
|||||||
buf.find('ul').append('<li>' + nameStr + message + '</li>');
|
buf.find('ul').append('<li>' + nameStr + message + '</li>');
|
||||||
buf.scrollTop(buf[0].scrollHeight - buf.height());
|
buf.scrollTop(buf[0].scrollHeight - buf.height());
|
||||||
|
|
||||||
$('#chat').css('opacity', '1');
|
$('#chat').stop().css('opacity', '1');
|
||||||
|
|
||||||
startHideChat();
|
startHideChat();
|
||||||
}, false);
|
}, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user