game/js/onlineList.js

1254 lines
42 KiB
JavaScript
Raw Normal View History

2022-06-06 21:30:34 +00:00
var sml_img = { };
2023-01-10 16:29:32 +00:00
// Переменные голосовух
2022-06-06 21:30:34 +00:00
var mediaRecorder
var setIntervalSound
var timerSecMessage = 0
var flagVoice = false
var chunksVoice = []
Element.prototype.remove = function() {
2022-12-19 18:26:14 +00:00
this.parentElement.removeChild(this);
2022-06-06 21:30:34 +00:00
}
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
2022-12-19 18:26:14 +00:00
for(var i = 0, len = this.length; i < len; i++) {
if(this[i] && this[i].parentElement) {
this[i].parentElement.removeChild(this[i]);
}
}
2022-06-06 21:30:34 +00:00
}
var chat = {
key:'',
room:'',
count:0,
time:0,
t:null, //timer
t2:null, //timer 2
t_all:{}, //time molch
r:0,
g:0,
rtime:37,
ct:{ '-1':0, '1':15, '2':30, '3':60, '4':300},
saveData:null,
msg_id:0,
nrg:0,
nozpros:0,
newmsg:0,
sound:0,
translit:0,
filter:0,
globalMsg:0,
ignoreList:{x:0,nms:[]},
citySys:0,
inObj:null,
userSendMessage: false,
efftxt:function(id,txt) {
var r = txt;
return r;
},
ignore: function (login) {
if (this.ignoreList[login] != undefined) {
if ($('#ignr_alu').attr('id') != undefined) {
$(`#ignr_u_${this.ignoreList[login]}`).remove();
}
delete this.ignoreList.nms[this.ignoreList[login]];
delete this.ignoreList[login];
return
//msg
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
this.ignoreList.x++;
this.ignoreList[login] = this.ignoreList.x;
this.ignoreList.nms[this.ignoreList.x] = login;
if ($('#ignr_alu').attr('id') != undefined) {
$('#ignr_alu').html(`${$('#ignr_alu').html()}<div id="ignr_u_${this.ignoreList.x}"> <b>${login}</b> <a target="_blank" href="/info/${login}"><img src="https://${c.img}/i/inf_capitalcity.gif" onMouseOver="top.hi(this,\'<b>Инф. о ${login}</b>\',event,5,-2,2,2,\'\');" onMouseOut="top.hic();" onMouseDown="top.hic();"></a> <small><a href="javascript:void(0)" onclick="chat.ignorUn(${this.ignoreList.x})">Clear</a></small> </div>`);
2022-06-06 21:30:34 +00:00
}
return
},
getRandom: function (a, b) {
return a + ((b - a) * Math.random());
},
feerverk_id:0,
feerverk:function(name) {
if( name == 'fw04' ) {
var frc = {
'name':'fw04',
'x':19,
'top':this.getRandom(1,35),
'left':this.getRandom(0,365),
'width':135,
'sound':this.getRandom(8,10),
'height':99,
2022-12-19 18:26:14 +00:00
'zad':3
2022-06-06 21:30:34 +00:00
};
frc.left -= 35;
}
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if( frc.name != undefined ) {
this.sendSound( frc.sound );
var obj = top.frames.main.document.getElementById('frvrks');
if( obj != undefined ) {
var newhtml = '';
var i = 1;
while( i <= frc.x ) {
newhtml += `<img style="display:none" id="frvanim_${this.feerverk_id}_img${i}" width="${frc.width}" height="${frc.height}" src="//img.new-combats.tech/fw/${frc.name}/${i}.gif">`;
2022-12-19 18:26:14 +00:00
i++;
2022-06-06 21:30:34 +00:00
}
newhtml = `<div id="frvanim_${this.feerverk_id}" style="z-index:5000;position:absolute;width:${frc.width}px;height:${frc.height}px;left:${frc.left}px;top:${frc.top}px;">${newhtml}</div>`;
$(obj).append(newhtml);
this.feerverk_go( this.feerverk_id , frc.x-1 , frc.name , frc.x , frc.zad );
this.feerverk_id++;
}
}
},
feerverk_go: function (id, time_back, img, x, zad) {
if (zad > 0) {
setTimeout(`chat.feerverk_go(${id},${time_back},"${img}",${x},0);`, 500 * zad);
} else {
time_back--;
var obj = top.frames.main.document.getElementById(`frvanim_${id}`);
if (time_back > 0) {
2023-01-10 16:29:32 +00:00
var img1 = top.frames.main.document.getElementById(`frvanim_${id}_img${(x-time_back+1)}`); //текущая
2022-06-06 21:30:34 +00:00
if (img1 != undefined) img1.style.display = 'none';
2023-01-10 16:29:32 +00:00
var img1 = top.frames.main.document.getElementById(`frvanim_${id}_img${(x-time_back+2)}`); //текущая
2022-06-06 21:30:34 +00:00
if (img2 != undefined) img2.style.display = '';
setTimeout(`chat.feerverk_go(${id},${time_back},"${img}",${x},0);`, 50);
} else top.frames.main.document.getElementById(`frvanim_${id}`).remove();
}
},
ignorUn: function (x) {
$(`#ignr_u_${x}`).remove();
this.ignore(this.ignoreList.nms[x]);
},
ignorListOpen: function () {
var date = '', i = 0;
var j = 1;
while (j <= this.ignoreList.x) {
if (this.ignoreList[this.ignoreList.nms[j]] != undefined) {
date += `<div id="ignr_u_${j}"> <b>${this.ignoreList.nms[j]}</b> <a target="_blank" href="/info/${this.ignoreList.nms[j]}"><img src="https://${c.img}/i/inf_capitalcity.gif" onMouseOver="top.hi(this,\'<b>Инф. о ${this.ignoreList.nms[j]}</b>\',event,5,-2,2,2,\'\');" onMouseOut="top.hic();" onMouseDown="top.hic();"></a> <small><a href="javascript:void(0)" onclick="chat.ignorUn(${j})">Clear</a></small> </div>`;
2022-06-06 21:30:34 +00:00
}
j++;
}
2023-01-10 16:29:32 +00:00
win.add('ignorListWin', 'Список игнорируемых', `<div id="ignr_alu">${date}</div>`, {}, 0, 1, 'min-width:200px;');
2022-06-06 21:30:34 +00:00
delete date;
},
2023-01-10 16:29:32 +00:00
// смайлы
2022-06-06 21:30:34 +00:00
addSmile: function (id) {
$('#textmsg').val(`${$('#textmsg').val()} :${id}: `);
$('#textmsg').focus();
},
lookSmiles: function () {
if ($('#chbtn8').attr('class') == 'db cp chatBtn8_1') {
return this.lookSmilesWork('', 'chatBtn8_2')
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
return this.lookSmilesWork('none', 'chatBtn8_1')
},
lookSmilesWork: function (display, className) {
$('#ttSmiles').css('display', display);
$('#chbtn8').attr('class', `db cp ${className}`);
},
2023-01-10 16:29:32 +00:00
// оптимизация всех кнопок
2022-06-06 21:30:34 +00:00
greyButton_work: function (elemId, className, method, count ) {
$(elemId).attr('class', `db cp ${className}`);
this[method] = count;
},
2022-12-19 18:26:14 +00:00
2023-01-10 16:29:32 +00:00
// кнопка лейки
2022-06-06 21:30:34 +00:00
// 1
filterMsg: function () {
if ($('#chbtn1').attr('class') == 'db cp chatBtn1_1') {
return this.greyButton_work('#chbtn1', 'chatBtn1_2', "filter", 1)
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
return this.greyButton_work('#chbtn1', 'chatBtn1_1', "filter", 0)
},
2023-01-10 16:29:32 +00:00
// кнопка системных сообщений
2022-06-06 21:30:34 +00:00
// 2
systemMsg: function () {
if ($('#chbtn4').attr('class') == 'db cp chatBtn4_1') {
this.greyButton_work('#chbtn4', 'chatBtn4_2', "citySys", 1)
$.cookie('citySys', 1);
return
}
this.greyButton_work('#chbtn4', 'chatBtn4_1', "citySys", 0)
$.cookie('citySys', 0);
return
},
2022-12-19 18:26:14 +00:00
2023-01-10 16:29:32 +00:00
// кнопка аудиосообщений
2022-06-06 21:30:34 +00:00
// 3
soundChat: function () {
if ($('#chbtn7').attr('class') == 'db cp chatBtn7_1') {
return this.greyButton_work('#chbtn7', 'chatBtn7_2', "sound", 1)
} else if ($('#chbtn7').attr('class') == 'db cp chatBtn7_2') {
return this.greyButton_work('#chbtn7', 'chatBtn7_3', "sound", 2)
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
return this.greyButton_work('#chbtn7', 'chatBtn7_1', "sound", 0)
},
2023-01-10 16:29:32 +00:00
// кнопка транслита
2022-06-06 21:30:34 +00:00
// 4
translitChat: function () {
if ($('#chbtn6').attr('class') == 'db cp chatBtn6_1') {
return this.greyButton_work('#chbtn6', 'chatBtn6_2', "translit", 1)
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
return this.greyButton_work('#chbtn6', 'chatBtn6_1', "translit", 0)
2022-12-19 18:26:14 +00:00
},
2022-06-06 21:30:34 +00:00
subValSend: '',
2022-12-19 18:26:14 +00:00
subSend: async function () {
if ($('#textmsg').val() != '') {
if ($('#textmsg').val() != this.subValSend) {
if (this.nozpros == 0) {
2022-06-06 21:30:34 +00:00
this.trmb();
var textmsg = $('#textmsg').val();
2022-12-19 18:26:14 +00:00
if (cb_date[cb_select] == 7 && (textmsg.match(/to *\[(.*?)\].*/i) || textmsg.match(/private *\[(.*?)\].*/i))) {
for (var cb in cb_date) {
if (cb_date[cb] == 5) {
2022-06-06 21:30:34 +00:00
open_cb(cb, null);
2022-12-19 18:26:14 +00:00
}
}
}
if (typeof window.online_send_jqxhr == "undefined" || window.online_jqxhr.readyState === 4) {
window.online_send_jqxhr = $.post('online.php?r' + c.rnd + '&cas' + ((new Date().getTime()) + Math.random()), {
msg: textmsg,
key: this.key,
mid: this.msg_id,
rndo: c.rnd,
cb: cb_date[cb_select]
}, function (data) {
chat.clearText();
chat.fc();
2022-06-06 21:30:34 +00:00
chat.genchatData(data, 1);
chat.scrollNow(true)
document.getElementById("textmsg").value = ''
2022-12-19 18:26:14 +00:00
});
}
}
}
}
},
2022-06-06 21:30:34 +00:00
addto:function(login, type2) {
var loginaddT = login;
var s = '';
2022-12-19 18:26:14 +00:00
if($('#'+$(this.inObj).attr('id')).attr('id') == undefined) {
2022-06-06 21:30:34 +00:00
$('#textmsg').focus();
s = $('#textmsg').val();
} else $(this.inObj).focus();
var reg555 = new RegExp("private\\s*\\[(.*?)\\]","");
var reg551 = new RegExp("to\\s*\\[(.*?)\\]","");
var test1 = s.match(reg555);
if(s.match(reg555) == null) {
type = "to";
} else if(s.match(reg551) == null) {
type = "private";
}
2022-12-19 18:26:14 +00:00
var type3 = 'to';
2022-06-06 21:30:34 +00:00
var reg2 = new RegExp(""+type+"(\\s*)\\[(.*?)\\]","");
var cs = s.replace(reg2,""+type+"$1[,$2,]");
var slogin = login.replace(/([\^.*{}$%?\[\]+|\/\(\)])/g,"\\$1");
var reg = new RegExp(""+type+"\\s*\\[.*,\\s*"+slogin+"\\s*,.*\\]","");
var result = '';
2022-12-19 18:26:14 +00:00
var reg3 = new RegExp(""+type+"\\s*\\[(.*?)\\]","");
2022-06-06 21:30:34 +00:00
while(res = s.match(reg3)) {
result += `${res[1]},`;
s = s.replace(reg3,'');
}
result = result.replace(/,$/,'');
var prar = result.split(',');
for(i = 0; i < prar.length; i++) {
prar[i] = prar[i].replace(/^\s+/,'');
prar[i] = prar[i].replace(/\s+$/,'');
}
var str = prar.join(', ');
if(str) login += ', ';
space = '';
if (!s.match(/^\s+/)) space = ' ';
var prob = '';
if($('#'+$(this.inObj).attr('id')).attr('id') == undefined && (this.inObj == null || $('#main').contents().find('#'+this.inObj.id).attr('id') == undefined))
{
if (!cs.match(reg))
{
if (type2 == 'to') {
if (test1 != null) type2 = 'private';
}
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if (loginaddT == 'klan' && type2 == 'private') {
if (login == 'klan, ') {
s = type2 + ' [klan] to [' + prob + '' + str + '' + prob + ']' + space + s;
} else {
s = type2 + ' [klan]' + space + s;
}
}
else {s = type2+' ['+prob+''+login+str+''+prob+']'+space+s;}
2022-12-19 18:26:14 +00:00
} else {
2022-06-06 21:30:34 +00:00
if(type3 == 'to') type3 = "private";
s = type3+' ['+prob+''+str+''+prob+']'+space+s;
}
} else s = login+str;
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if (this.inObj != null && $('#main').contents().find(`#${this.inObj.id}`).attr('id') != undefined) {
$('#main').contents().find(`#${this.inObj.id}`).val(s);
} else if ($('#' + $(this.inObj).attr('id')).attr('id') == undefined) {
$('#textmsg').val(s);
} else $(this.inObj).val(s);
},
clearText: function () {
$('#textmsg').val('');
},
reflesh: function () {
this.time = 0;
this.testTimer(true);
},
reMoney: function () {
2023-01-18 19:27:27 +00:00
$('#moneyGM').html(`${c.money} кр.`);
2022-06-06 21:30:34 +00:00
},
2022-12-19 18:26:14 +00:00
testTimer: function (n) {
clearTimeout(this.t);
if ($.cookie('btl') != this.btl) {
if ($.cookie('btl') > 0) {
this.sendSound(2);
if (top.frames['main'].smnpty == undefined) {
2022-06-06 21:30:34 +00:00
top.frames['main'].location.href = "main.php";
2022-12-19 18:26:14 +00:00
}
}
this.btl = $.cookie('btl');
}
if (this.rtime != this.ct[$.cookie('chatCfg0')] && this.ct[$.cookie('chatCfg0')] != undefined) {
this.rtime = this.ct[$.cookie('chatCfg0')];
if (this.time > this.rtime) this.time = this.rtime;
}
if (this.rtime >= 5 || this.r == 0) //was >- 30 lakris fix
{
if (this.time < 1) {
var aot = {
0: 0,
1: 1,
2: 0
};
if ($('#chcf10').attr('checked') == true) aot[2] = 1;
if ($('#autoRefOnline').attr('checked') == true || this.r == 0 || n != false) {
aot[0] = 1;
}
if (this.nozpros == 0) {
if (typeof window.online_jqxhr == "undefined" || window.online_jqxhr.readyState === 4) {
window.online_jqxhr = $.getJSON(`online.php?r${c.rnd}&cas${((new Date().getTime()) + Math.random())}`, {key: this.key, mid: this.msg_id, r1: aot[0], r2: aot[1], r3: aot[2], rndo: c.rnd}, function (data) {
if (data.rnd != null) {
chat.genchatData(data);
if (data.key != undefined) chat.saveData = data;
this.g++;
c.rnd = data.rnd;
}
});
}
}
this.time = 5;
this.r++;
} else this.time--;
this.t = setTimeout('chat.testTimer(false);clearTimeout(this.t);', 1000);
}
},
2022-06-06 21:30:34 +00:00
gUser:function(data,ol) {
var rt = '';
function data_work (count) {
data[count] = this.replaceAll(data[count], "\\", '\\\\');
data[count] = this.replaceAll(data[count], "[s1;]", '"');
data[count] = this.replaceAll(data[count], "[s2;]", '`');
data[count] = this.replaceAll(data[count], "[s3;]", '');
data[count] = this.replaceAll(data[count], "[s4;]", '');
data[count] = this.replaceAll(data[count], "<", '');
data[count] = this.replaceAll(data[count], ">", '');
}
if(data[1]!=undefined) {
rt = data[1];
2023-01-10 16:29:32 +00:00
if( rt == 'Администратор' ) rt = this.efftxt('fire',rt);
2022-06-06 21:30:34 +00:00
if (ol == true) {
rt = `<a href="javascript:void(0)" onClick="chat.addto(\'${data[1]}\',\'to\')">${rt}</a>`;
}
else rt = `<b>${rt}</b>`;
if(data[13]!=0) rt = `<span class="uCss${data[13]}">${rt}</span>`;
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if (data[10] > 0) {
2023-01-10 16:29:32 +00:00
rt = `<s onmouseout="top.hic()" onmousedown="top.hic()" onmouseover="top.hi(this,\'Персонаж был заблокирован\',event,3,1,1,2,\'\')">${rt}</s>`;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if (data[8] != 0) data_work(8)
else if (data[9] != 0) data_work(9)
2023-01-10 16:29:32 +00:00
// тут
2022-06-06 21:30:34 +00:00
function rtData (count) {
2023-01-18 19:27:27 +00:00
return rt = `<img height="15" src="https://${c.img}/i/align/align${data[count]}.gif">${rt}`;
2022-06-06 21:30:34 +00:00
}
if(data[4]!=0)
{
rt = `<a href="/clan/${data[4]}" title="${data[4]}" target="_blank"><img width="24" height="15" src="https://${c.img}/i/clan/${data[4]}.gif"></a>${rt}`;
}
2022-12-19 18:26:14 +00:00
if( data[16] > 0 ) rtData(16)
2022-06-06 21:30:34 +00:00
rtData(3)
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if(c.lvl>-1)
{
if(c.city==data[6])
{
if (data[12] > 0) {
2023-01-10 16:29:32 +00:00
rt = `<a href="javascript:void(0)" onClick="chat.addto(\'${data[1]}\',\'private\')"><img title="Персонаж сражается" src="https://${c.img}/i/lock1.gif" width="20" height="15"></a>${rt}`;
2022-06-06 21:30:34 +00:00
} else {
rt = `<a href="javascript:void(0)" onClick="chat.addto(\'${data[1]}\',\'private\')"><img src="https://${c.img}/i/lock.gif" width="20" height="15"></a>${rt}`;
}
}else{
2023-01-10 16:29:32 +00:00
rt = `<img style="padding-right:3px;" onmouseout="top.hic()" onmousedown="top.hic()" onmouseover="top.hi(this,\'Персонаж сейчас в ${data[6]}\',event,3,1,1,2,\'\')" src="https://${c.img}/i/city_ico/${data[6]}.gif" width="17" height="15">${rt}`;
2022-06-06 21:30:34 +00:00
}
}
2023-01-18 19:27:27 +00:00
rt += `[${data[2]}]<a href="https://${c.url}/info/${data[0]}" target="_blank"><img style="vertical-align:baseline" width="12" height="11" src="https://${c.img}/i/inf_${data[5]}.gif" title="Инф. о ${data[1]}" /></a>`;
2022-06-06 21:30:34 +00:00
2023-01-18 19:27:27 +00:00
if (data[11] > c.time) {
2023-01-10 16:29:32 +00:00
rt += ` <img id="img_molch${data[1]}" width="24" height="15" style="cursor:help" src="https://${c.img}/i/sleep2.gif" onmouseout="top.hic()" onmousedown="top.hic()" onmouseover="top.hi(this,\'На персонажа наложено заклятие молчания.<br>Будет молчать еще <span id=\\\'molch${data[0]}\\\'>${this.timeOut(data[11])}</span>\',event,3,1,1,2,\'\');chat.justRefMolch(${data[0]})">`;
2022-06-06 21:30:34 +00:00
this.addRefMolch(data[0], data[11]);
}
if (data[14] != "") {
2023-01-10 16:29:32 +00:00
rt += ` <img width="24" height="15" style="cursor:help" src="https://${c.img}/i/travma2.gif" onmouseout="top.hic()" onmousedown="top.hic()" onmouseover="top.hi(this,\'У персонажа ${data[14]}\',event,3,1,1,2,\'\');">`;
2022-06-06 21:30:34 +00:00
}
if (data[13] > 0) {
if (data[13] == 2) {
2023-01-10 16:29:32 +00:00
rt += ` <a target="main" href="/main.php?atak_user=${data[0]}" title="Кровавое нападение на ${data[1]}"><img width="13" height="13" src="https://${c.img}/i/clear.gif"></a>`;
2022-06-06 21:30:34 +00:00
} else {
2023-01-10 16:29:32 +00:00
rt += ` <a target="main" href="/main.php?atak_user=${data[0]}" title="Напасть на ${data[1]}"><img width="13" height="13" src="https://${c.img}/i/curse_attack.gif"></a>`;
2022-06-06 21:30:34 +00:00
}
}
if( data[15] == 1 ) rt = `<span class=woman >${rt}</span>`
2023-01-10 16:29:32 +00:00
} else rt = '<i>невидимка</i>[??]'
2022-06-06 21:30:34 +00:00
return rt;
},mlch:{},
justRefMolch: function (id) {
$(`#molch${id}`).html(this.timeOut(this.mlch[id]));
},
addRefMolch: function (id, tm) {
this.t_all[id] = setTimeout(`chat.refMolch(${id})`, 1000);
this.mlch[id] = tm;
},
refMolch: function (id) {
clearTimeout(this.t_all[id]);
if (this.mlch[id] > 0) {
$(`#molch${id}`).html(this.timeOut(this.mlch[id]));
this.t_all[id] = setTimeout(`chat.refMolch(${id})`, 1000);
return
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
$(`#img_molch${id}`).remove();
return delete this.mlch[id], this.t_all;
},
fc: function () {
$('#textmsg').focus();
},
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
timeOut: function (v) {
msPerDay = '';
dt = new Date();
dt.setTime((v - c.time) * 1000);
m1 = dt.getUTCMonth();
d1 = dt.getUTCDay();
h1 = dt.getUTCHours();
min1 = dt.getUTCMinutes();
sec = dt.getUTCSeconds();
2023-01-10 16:29:32 +00:00
if (m1 > 0) msPerDay = `${m1} мес. `;
if (d1 > 0 && Math.floor((v - c.time) / (60 * 60 * 24)) == d1) msPerDay = `${d1} д. `;
if (h1 > 0) msPerDay += `${h1} ч. `;
if (min1 > 0) msPerDay += `${min1} мин. `;
if (sec > 0 && msPerDay != '') msPerDay += `${sec} сек. `;
if (msPerDay == '') msPerDay = 'меньше минуты.';
2022-06-06 21:30:34 +00:00
delete m1, d1, h1, min1, sec;
return msPerDay;
},
deleteMessage: async function (id, fc) {
if (fc == 1) top.msgdeleted(id)
else {
$(`#msg_${id}`).remove();
$(`#msg_${id}_sys`).remove();
2023-01-18 19:27:27 +00:00
if (c.admin > 0) {
2022-06-06 21:30:34 +00:00
await fetch(`online.php?jack=${c.rnd}&cas${((new Date().getTime()) + Math.random())}`, {
method: "POST",
delMsg: id
})
}
}
},
clear: function () {
if ($('#textmsg').val() == '') {
2023-01-10 16:29:32 +00:00
if (confirm('Очистить окно чата?')) {
2022-06-06 21:30:34 +00:00
if (top.des == 1) {
2023-01-18 19:27:27 +00:00
$(`#canal${cb_date[cb_select]}`).html('');
2022-06-06 21:30:34 +00:00
$('#textmsg').focus();
return
}
$('#canal5').html('');
$('#textmsg').focus();
return
}
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
return $('#textmsg').val('');
},
scrollNow: function (userTrue) {
var $chat_list = document.getElementById("chat_list")
var $countChatList = $chat_list.scrollHeight - $chat_list.scrollTop
if ($countChatList < $chat_list.offsetHeight + 100) {
return $chat_list.scrollBy(0, $chat_list.scrollHeight)
}
if (userTrue) return $chat_list.scrollBy(0, $chat_list.scrollHeight)
},
msgcount:0,
2022-12-19 18:26:14 +00:00
sendMsg: function(data) {
2022-06-06 21:30:34 +00:00
2023-01-10 16:29:32 +00:00
// Если системное сообщение от моба - длина массива === 10
// Иначе - длина массива === 17
2022-06-06 21:30:34 +00:00
2023-01-10 16:29:32 +00:00
// data[0] - какое-то число
// data[1] - видимо номер сообщения в чате за всё время
// data[2] - число от 1 до 6 как увидел
// data[3] - ник, если покрашенный
// data[4] - ник, если не покрашенный
// data[5] - само сообщение в чате из инпута
// data[6] - цвет покраски ника. Если цвета нет - пустая строка
2022-06-06 21:30:34 +00:00
// data[7] - 0
// data[8] - 0
// data[9] - 0
// data[10] - 0
// data[11] - 0
// data[12] - 0
2023-01-10 16:29:32 +00:00
// data[13] - время
// data[14] - полная дата
// data[15] - пустая строка
2022-06-06 21:30:34 +00:00
// data[16] - 0
var msg_see = 1;
var global_type = 0;
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if( data[5] != undefined ) {
if( data[5].substring(0,7) == 'global:' ) {
global_type = 1;
data[5] = data[5].substring(7);
}
}
if (data[0] == 'new') {
2022-12-19 18:26:14 +00:00
data[0] = `new_msg_ ${this.newmsg++}`;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
if (data[2] == 'delete') this.deleteMessage(data[0]);
else if (data['d'] > 0) this.deleteMessage(data['d']);
2022-06-06 21:30:34 +00:00
else if (data['s'] > 0) this.deleteMessage(data['s']);
else if (data[0] != undefined && top.document.getElementById(`msg_${data[0]}`) == undefined) {
var msg = '';
2022-12-19 18:26:14 +00:00
if (data[0] != 0) {
2023-01-18 19:27:27 +00:00
if (c.admin > 0) {
2022-12-19 18:26:14 +00:00
if (data[12] == 1) {
msg += '<small style="color:red;text-decoration:blink"> <b>un</b>active </small>';
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
}
if (data[3] != '') {
if (data[16] > 0) {
2023-01-10 16:29:32 +00:00
msg += `[<a href="javascript:void(0)" oncontextmenu="top.infoMenu(\'Невидимка\',event,\'chat\'); return false;" onClick="chat.addto(\'Невидимка\',\'to\')">${data[3]}</a>]`;
2022-12-19 18:26:14 +00:00
} else {
msg += `[<a href="javascript:void(0)" oncontextmenu="top.infoMenu(\'${data[3]}\',event,\'chat\'); return false;" onClick="chat.addto(\'${data[3]}\',\'to\')">${data[3]}</a>]`;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
if (chat.ignoreList[data[3]] != undefined) msg_see = 0;
}
if (data[4] != '') {
var forYou = 0;
2023-01-10 16:29:32 +00:00
//тот кто писал
2022-12-19 18:26:14 +00:00
2023-01-10 16:29:32 +00:00
//кому написали, разбор массива
2022-06-06 21:30:34 +00:00
if (data[4] != '') {
2022-12-19 18:26:14 +00:00
var to = '',to2 = '',arr = data[4].split(','),i = 0,vl = '';
2023-01-10 16:29:32 +00:00
//тем кому писали
2022-12-19 18:26:14 +00:00
while (i != -1) {
if (arr[i] != undefined) {
vl = this.trim(arr[i]);
2023-01-18 19:27:27 +00:00
if (vl.toLowerCase() == c.login.toLowerCase()) {
2022-12-19 18:26:14 +00:00
forYou++;
}
2023-01-18 19:27:27 +00:00
if (vl.toLowerCase() == c.login.toLowerCase()) {
2022-12-19 18:26:14 +00:00
vl = this.trim(data[3]);
}
if (i > 0) {
to += ', ';
to2 += ', ';
}
if (data[3] != '') {
to += `<span style="cursor:pointer" onclick="chat.addto(\'${vl}\',\'private\');" oncontextmenu="top.infoMenu(\'${this.trim(arr[i])}\',event,\'chat\'); return false;">${this.trim(arr[i])}</span>`;
2023-01-18 19:27:27 +00:00
if (this.trim(arr[i].toLowerCase()) != c.login.toLowerCase()) {
2022-12-19 18:26:14 +00:00
to2 += this.trim(arr[i]);
} else {
if (data[2] == 2) to2 += this.trim(arr[i]);
else to2 += this.trim(vl);
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
}
} else i = -2;
i++;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
}
if(data[2] == 6 || data[2] == 8) {
var zmlogin = new RegExp("\\[login:(.*?)\\]","");
var reflcd = new RegExp("\\[reflesh_main_zv_priem:(.*?)\\]","");
if (data[5].match(zmlogin) != null) {
zmlogin = data[5].match(zmlogin)[1];
data[5] = data[5].replace(`[login:${zmlogin}]`, `<a onMouseDown="top.loginGo(\'${zmlogin}\',event);" oncontextmenu="top.infoMenu(\'${zmlogin}\',event,\'chat\'); return false;" title="${zmlogin}" style="cursor:pointer;" onClick="chat.multiAddto(\'${zmlogin}\',\'to\');">${zmlogin}</a>`);
}
if (data[5].match(reflcd) != null) {
reflcd = data[5].match(reflcd)[1];
data[5] = data[5].replace(`[reflesh_main_zv_priem:${reflcd}]`, '');
}
}
2023-01-10 16:29:32 +00:00
//Собираем массив кому адресовано сообщение
2022-12-19 18:26:14 +00:00
if (data[2] == 6) {
2023-01-10 16:29:32 +00:00
//личная системка, внимание
msg += ' <span style="color:red">Внимание!</span> ';
2022-12-19 18:26:14 +00:00
} else if (data[2] == 2) {
if (forYou > 0) {
msg += ` <span style="color:${data[6]}"><b>to [${to2}]</b></span>`;
} else {
msg += ` <span style="color:${data[6]}">to [${to2}]</span>`;
}
} else if (data[2] == 3) {
2023-01-18 19:27:27 +00:00
if (this.trim(data[3].toLowerCase()) == c.login.toLowerCase()) {
2022-12-19 18:26:14 +00:00
forYou++;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
if (data[3] != '') {
if (data[4] == 'klan' && data[2] == 3) {
msg += ' <span class="klan"><span style="cursor:pointer" onclick="chat.multiaddto(\'klan\',\'private\');">private [klan]</span></span>';
} else if (data[4] == 'paladins' && data[2] == 3) {
msg += ' <span class="klan"><span style="cursor:pointer" onclick="chat.multiaddto(\'paladins\',\'private\');">private [paladins]</span></span>';
} else if (data[4] == 'tarmans' && data[2] == 3) {
msg += ' <span class="klan"><span style="cursor:pointer" onclick="chat.multiaddto(\'tarmans\',\'private\');">private [tarmans]</span></span>';
2022-06-06 21:30:34 +00:00
} else {
2022-12-19 18:26:14 +00:00
msg += ` <span class="private"><span style="cursor:pointer" onclick="chat.multiaddto(\'${to2}\',\'private\');">private [ </span>${to}<span style="cursor:pointer" onclick="chat.multiAddto(\'${to2}\',\'private\');"> ]</span></span>`;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
}
}
2022-12-19 18:26:14 +00:00
msg += ' ';
}
data[5] = this.replaceAll(data[5],"[s1;]",'"');
data[5] = this.replaceAll(data[5],"[s2;]",'\'');
data[5] = this.replaceAll(data[5],"[s3;]",'<');
data[5] = this.replaceAll(data[5],"[s4;]",'>');
2022-06-06 21:30:34 +00:00
2022-12-19 18:26:14 +00:00
if ($.cookie('chatCfg2') != 0) {
data[5] = chat.testSmile(data[5]);
}
if (data[6] != 'Black' && data[6] != '') {
var voiceMessageReg = data[5].match(/audio_[0-9]{10}[.]mp3/g)
if (voiceMessageReg !== null) {
msg += `<font color="${data[6]}">
2022-06-06 21:30:34 +00:00
<audio id="audioPlayerChat" controls style="width:300px;max-width:400px;" height="20px";>
<source src="/audio/${voiceMessageReg[0]}" type="audio/mp3">
</audio>
</font>`;
2022-12-19 18:26:14 +00:00
voiceMessageReg = ""
}
else {
if (data.length === 10) {
msg += `<font color="${data[6]}">${data[5]}</font>`;
}
2022-06-06 21:30:34 +00:00
else {
2022-12-19 18:26:14 +00:00
msg += `<font color="${data[6]}">${chat.regexpURL_true(data[5])}</font>`
}
}
} else {
2022-06-06 21:30:34 +00:00
2022-12-19 18:26:14 +00:00
var voiceMessageReg = data[5].match(/audio_[0-9]{10}[.]mp3/g)
if (voiceMessageReg !== null) {
msg += `<audio id="audioPlayerChat" controls style="width:300px;max-width:400px;" height="20px";>
2022-06-06 21:30:34 +00:00
<source src="/audio/${voiceMessageReg[0]}" type="audio/mp3">
</audio>`
2022-12-19 18:26:14 +00:00
voiceMessageReg = ""
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
else {
msg += chat.regexpURL_true(data[5])
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
}
if(data[2] == 21) {
//e text
var text = `[loginfrom] ${data[5]}`;
var ftps = `<i><a href="javascript:void(0)" oncontextmenu="top.infoMenu(\'${data[3]}\',event,\'chat\'); return false;" onClick="chat.addto(\'${data[3]}\',\'to\')">${data[3]}</a></i>`;
var mblogin = new RegExp("\\[login:(.*?)\\]","");
text = text.replace('[loginfrom]',ftps);
if(text.match(mblogin)!=null)
2022-06-06 21:30:34 +00:00
{
2022-12-19 18:26:14 +00:00
mblogin = text.match(mblogin)[1];
text = text.replace(`[login:${mblogin}]`,`<i><a href="javascript:void(0)" oncontextmenu="top.infoMenu(\'${mblogin}\',event,\'chat\'); return false;" onClick="chat.addto(\'${mblogin}\',\'to\')">${mblogin}</a></i>`);
}
msg = `<i>${text}</i>`;
}
if(data[1]>0)
{
var td = new Date((parseInt(data[1]))*1000);
td = [td,null,null,null];
td[1] = td[0].getHours();
td[2] = td[0].getMinutes();
td[3] = td[0].getSeconds();
td[4] = td[0].getDay();
td[5] = td[0].getMonth();
td[6] = td[0].getYear();
var j = 1;
while (j < 6) {
if (td[j] < 10) td[j] = `0${td[j]}`;
j++;
}
var cls = forYou > 0 ? 'date2' : 'date'
if (data[11] > 0) {
2023-01-10 16:29:32 +00:00
msg = `<font style="cursor:help" color="red" onmouseout="top.hic()" onmousedown="top.hic()" onmouseover="top.hi(this,\'Отправитель наказан за нарушение правил общения<br>Отключить отображение подобных сообщений можно в настройках чата.\',event,3,1,1,3,\'\')"> <b>!</b> </font>${msg}`;
2022-12-19 18:26:14 +00:00
}
if (data[10] > 0) {
2023-01-10 16:29:32 +00:00
msg = `<font style="cursor:help" color="green" onmouseout="top.hic()" onmousedown="top.hic()" onmouseover="top.hi(this,\'Это глобальное сообщение, оно может быть отправлено из любой локации<br>Отключить отображение подобных сообщений можно в настройках чата.\',event,3,1,1,3,\'\')"> <b>G</b> </font>${msg}`;
2022-12-19 18:26:14 +00:00
}
var msg22 = '<span ';
2023-01-18 19:27:27 +00:00
if(c.admin > 0) {
2022-12-19 18:26:14 +00:00
msg22 += `oncontextmenu="chat.deleteMessage(${data[0]});
return false;" `;
}
2023-01-10 16:29:32 +00:00
// ОПТИМИЗАЦИЯ!!!
2022-12-19 18:26:14 +00:00
if (data[8] == 2) {
if (data[14] == undefined) {
data[14] = '--:--';
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
if (data[14] == '--:--' && data[1] > 0) {
data[14] = data[1];
var date14 = new Date(data[14] * 1000);
data[14] = `${date14.getHours()}:${date14.getMinutes()}`;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
msg22 += `class="${cls}">${data[14]}</span> `;
} else {
if (data[13] == undefined) {
data[13] = '--:--';
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
if (data[13] == '--:--' && data[1] > 0) {
data[13] = data[1];
var date13 = new Date(data[13] * 1000);
data[13] = `${date13.getHours()}:${date13.getMinutes()}`;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
msg22 += `class="${cls}">${data[13]}</span> `;
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
msg = msg22+msg;
}
this.msgcount++;
2022-06-06 21:30:34 +00:00
msg = `<span class="m0c1" id="msg_${data[0]}">${msg}<br></span>`;
2022-12-19 18:26:14 +00:00
2023-01-18 19:27:27 +00:00
if (forYou > 0 && this.sound > 0 && this.trim(data[3].toLowerCase()) != c.login.toLowerCase()) {
2022-06-06 21:30:34 +00:00
this.sendSound(1);
}
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if(msg_see == 1)
{
2023-01-18 19:27:27 +00:00
if(this.trim(data[3].toLowerCase()) == c.login.toLowerCase() || forYou == 1 || this.filter == 0)
2022-06-06 21:30:34 +00:00
{
if( data[9] > 0 ) this.sendSound(data[9]);
if( data[15] != undefined && data[15] != 0 ) {
this.feerverk( data[15] );
this.feerverk( data[15] );
}
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if( top.des == 1 ) {
if( data[2] < 4 || global_type == 1 ) {
2023-01-10 16:29:32 +00:00
//Обычный чат
2022-06-06 21:30:34 +00:00
chat.textColor_Work('#canal5', msg, 5)
if( global_type == 1 ) {
2023-01-10 16:29:32 +00:00
//Системный чат
2022-06-06 21:30:34 +00:00
chat.textColor_Work('#canal4', msg, 4)
}
}else{
2023-01-10 16:29:32 +00:00
//Системный чат
2022-06-06 21:30:34 +00:00
chat.textColor_Work('#canal4', msg, 4)
chat.textColor_Work('#canal5', msg, 5)
}
}
else {
// var $htmlElementsMessage = new DOMParser().parseFromString(messg, "text/html").getElementsByTagName("span")[0]
// document.getElementById('canal5').append($htmlElementsMessage)
2022-12-19 18:26:14 +00:00
$('#canal5').html(`${$('#canal5').html()}${msg}`);
2022-06-06 21:30:34 +00:00
}
}
}
this.scrollNow(false);
return delete forYou, cls, msg_see, msg, arr;
}
},
textColor_Work: function (canal ,messg, count) {
var $htmlElementsMessage = new DOMParser().parseFromString(messg, "text/html").getElementsByTagName("span")[0]
var $idCanal = canal.match(/canal[0-9]/)
var $idCanal0 = document.getElementById($idCanal[0])
if (!$idCanal0) $(canal).html(`${$(canal).html()}${messg}`)
else $idCanal0.append($htmlElementsMessage)
// console.log(messg)
// document.getElementById($idCanal[0]).append($htmlElementsMessage)
top.blueTextSee(count);
},
testKey: function (m, v) {
var i = 0, r = v;
v = false;
while (i != -1) {
if (m[i] != undefined) {
if (m[i] == r) {
v = i;
i = -2;
}
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
else i = -2;
i++;
}
delete r, m;
return v;
},
isNumber: function (s) {
return s = !isNaN(s) ? true : false
},
testSmile: function (txt) {
txr = txt.split(':');
var i = 1,
j = 0,
smid = 0;
while (i <= txr.length) {
if (txr[i] != undefined) {
smid = this.testKey(top.sml, txr[i]);
imsml = txr[i].split('-');
if (((smid != false || smid == 0) && this.isNumber(txr[i]) != true) || (imsml != undefined && imsml[0] == '%usersmile%')) {
if (j < 3 && this.isNumber(top.sml[smid]) != true && (top.sml[smid] != undefined || imsml[0] == '%usersmile%')) {
2023-01-10 16:29:32 +00:00
// тут
2022-06-06 21:30:34 +00:00
if (imsml[0] == '%usersmile%') {
2023-01-18 19:27:27 +00:00
txt = txt.replace(`\:%usersmile%-${imsml[1]}\:`, `<img src="https://${c.img}/i/smile/${(imsml[1].toLowerCase())}.gif" title="Именной смайлик">`);
2022-06-06 21:30:34 +00:00
} else {
2023-01-18 19:27:27 +00:00
txt = txt.replace(`\:${txr[i]}\:`, `<img src="https://${c.img}/i/smile/${(txr[i].toLowerCase())}.gif" style="cursor:pointer" width="${top.sml[smid+1]}" height="${top.sml[smid+2]}" onclick="chat.addSmile(\'${(txr[i].toLowerCase())}\')">`);
2022-06-06 21:30:34 +00:00
}
j++;
}
}
}
i++;
}
return txt;
},
trmb: function () {
if (this.translit == 1) {
$('#textmsg').val(this.convert2($('#textmsg').val()));
}
},
replaceAll: function (t, v, s) {
return t.split(v).join(s);
},
regexpURL_true (str) {
var finallyStr = str
2023-01-10 16:29:32 +00:00
var arrURL = str.match(/[-a-zA-Z0-9а-яА-я@:;%_\+.~#?&\/=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:;%_\+.~#?&\/=]*)?/gi)
var domainsRUS = str.match(/[a-zA-Z0-9а-яА-Я-]+[.,:;\/?!@#$%^&*()_+-`'"|]+(ком|ру|юа)+/gi)
var domainsEN = str.match(/[a-zA-Z0-9а-яА-Я-]+[ .,:;\/?!@#$%^&*()_+-`'"|]+\b(c[o]+m|ua|r[u]{1,}|net|cc)+\b/gi)
var regexpForbiddenWords = /\b(old|rebk|combatz|sbkru|urlidru|real|obk2com|bitly|owly|cruelbk|likebk|isgd|fightbk|my-|my-combatc|mbk|anti|ws|s3s|bakubk|idealbk|bespridel|perbk|online|cf|artovik|probk|twar|oyy|krbk|habk|timebk|sbi|eea|sokbk|inbk|refbk|s3s|bk20|analogbk|monstrbk|legendabk|awOev|cruelcity|tlgr|vntr|supbk|cu|tn|af|svel|kwn|krati|ohh|gHjq|ogw|lur|lmy|idz|hop|eee|bestbk|pixl|ssylka|f34r|exelendbk|9tl|qil|2t9|NjQ0|net|bishky|getl|ixz|nvm|prok|5char|tdl|pick|jj|FORM|zik|biz|sns|snsh|pnut|pb8|short|legendabk|prnt|utf|coombats|tiny|orDеNВК|nbk|orden|club|utf|ubit|clc|wocmaet|wiecej|ourl|3le|NikY|fia|iop|ordenbk|s3s|sW|sw|so|xcombat|world|death|legendbattles|plu|dbe|kombatz|over|dek|ci8|goldbk|Zeus|nxt|is|Ndpx|pw|kutt|JovdeT|cort|rexno|bly|tFXUQ|fyi|yf0ck|lst|numl|yx5ru|vhGyJ|GEROY|MOYEP|fuck|lnnk|dhaF|oko|x8b4q|3le|Ru2q|psce|yx5|bg9xH|Rich|Lands|yx|bgH|qil|huxoqM|bgxH|Nextbk|idea|PLAYBK|dance|coronabk|hitbk|ttpham|prnt|RСомbаts|dedmoroz|wmj9bz|king|ZEBK|urlgo|ZniD)+\b/g
2022-06-06 21:30:34 +00:00
finallyStr = str.replace(regexpForbiddenWords, () => "")
var allURL = new Set()
if (domainsEN) for (var key of domainsEN) {
2023-01-10 16:29:32 +00:00
if (!key.match(/^[a-zA-zа-яА-я0-9]+$/i)) allURL.add(key)
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if (domainsRUS) for (var key of domainsRUS) {
2023-01-10 16:29:32 +00:00
if (!key.match(/^[a-zA-zа-яА-я0-9]+$/i)) allURL.add(key)
2022-06-06 21:30:34 +00:00
}
if (arrURL) for (var key of arrURL) allURL.add(key)
if (!allURL.size) return finallyStr
var trueURL = []
var falseURL = false
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
for (var key of allURL) {
if (key.match(/vk\.com/i)) trueURL.push(key)
else if (key.match(/youtube\.com/i)) trueURL.push(key)
else if (key.match(/youtu\.be/i)) trueURL.push(key)
else if (key.match(/twitch\.tv/i)) trueURL.push(key)
else if (key.match(/new-combats\.com/i)) trueURL.push(key)
2022-12-19 18:26:14 +00:00
else if (key.match(/https:\/\/rpgtop\.su\/vote\/26677/i)) trueURL.push(key)
2022-06-06 21:30:34 +00:00
else if (key.match(/inf\.php/i)) trueURL.push(key)
else falseURL = true
}
2023-01-10 16:29:32 +00:00
if (falseURL) return "В сообщении присутствуют запрещенные ссылки."
2022-06-06 21:30:34 +00:00
finallyStr = finallyStr.replace(
/(<img src=")?(https?:\/\/)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z()]{1,6}\b([-a-zA-Z0-9()@:%_;\+.~#?&\/\/=]*)/gi,
(match) => {
2022-12-19 18:26:14 +00:00
if (/^(<img src=")/.test(match)) {
return match
}
else if (match.match(/new-combats\.com/i)) return match
else if (match.match(/inf\.php/i)) return match
else if (/^(https?:\/\/)/.test(match)) {
return `<a class="URL-a" href="${match}" target="_blank">${match}</a>`
}
else {
return `<a class="URL-a" href="https://${match}" target="_blank">${match}</a>`
}
2022-06-06 21:30:34 +00:00
}
2022-12-19 18:26:14 +00:00
)
finallyStr = finallyStr.replace(regexpForbiddenWords, () => "")
2022-06-06 21:30:34 +00:00
return finallyStr
},
convert2:function(txt)
{
var trn = new Array();
trn = txt.split(' ');
for(var i=0;i<trn.length;i++) {
if(trn[i].indexOf("https://") < 0 && trn[i].indexOf('@') < 0 && trn[i].indexOf("www.") < 0 && !(trn[i].charAt(0)==":" && trn[i].charAt(trn[i].length-1)==":")) {
if ((i<trn.length-1)&&(trn[i]=="to" || trn[i]=="private")&&(trn[i+1].charAt(0)=="[")) {
while ( (i<trn.length-1) && (trn[i].charAt(trn[i].length-1)!="]") ) i++;
} else { trn[i] = this.convert(trn[i]); }
}
}
return trn.join(' ');
},
2023-01-10 16:29:32 +00:00
map_en:Array('s`h','S`h','S`H','s`Х','sh`','Sh`','SH`',"'o",'yo',"'O",'Yo','YO','zh','w','Zh','ZH','W','ch','Ch','CH','sh','Sh','SH','e`','E`',"'u",'yu',"'U",'Yu',"YU","'a",'ya',"'A",'Ya','YA','a','A','b','B','v','V','g','G','d','D','e','E','z','Z','i','I','j','J','k','K','l','L','m','M','n','N','o','O','p','P','r','R','s','S','t','T','u','U','f','F','h','H','c','C','`','y','Y',"'"),
map_ru:Array('сх','Сх','СХ','сХ','щ','Щ','Щ','ё','ё','Ё','Ё','Ё','ж','ж','Ж','Ж','Ж','ч','Ч','Ч','ш','Ш','Ш','э','Э','ю','ю','Ю','Ю','Ю','я','я','Я','Я','Я','а','А','б','Б','в','В','г','Г','д','Д','е','Е','з','З','и','И','й','Й','к','К','л','Л','м','М','н','Н','о','О','п','П','р','Р','с','С','т','Т','у','У','ф','Ф','х','Х','ц','Ц','ъ','ы','Ы','ь'),
2022-06-06 21:30:34 +00:00
addSm: function (i) {
$('#textmsg').focus();
top.document.textmsg.value += ` :${i}: `;
},
convert_work: function (id) {
newstr = str.match(id)[0];
str = str.replace(str.match(id)[0], '');
},
convert: function (str) {
var p1 = new RegExp("private\\s*\\[(.*?)\\]", "");
var t1 = new RegExp("to\\s*\\[(.*?)\\]", "");
var newstr = '';
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if (str.match(p1) != null) this.convert_work(p1)
else if (str.match(t1) != null) this.convert_work(t1)
for (var i = 0; i < this.map_en.length; ++i)
while (str.indexOf(this.map_en[i]) >= 0) str = str.replace(this.map_en[i], this.map_ru[i]);
newstr += str;
return newstr;
},
2022-12-19 18:26:14 +00:00
sendSound: function (s) {
2022-06-06 21:30:34 +00:00
var svolm = 100;
if (this.sound == 0) svolm = 0
else if (this.sound == 1) svolm = 25;
2022-12-19 18:26:14 +00:00
else if (this.sound == 2) svolm = 100;
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
if (isInternetExplorer && window.document["Sound"] && typeof window.document["Sound"].SetVariable !== "undefined") {
window.document["Sound"].SetVariable("Volume", svolm);
window.document["Sound"].SetVariable("Sndplay", s);
}
2022-06-06 21:30:34 +00:00
else if(document.getElementById('Sound2') && typeof document.getElementById('Sound2').SetVariable !== "undefined") {
2022-12-19 18:26:14 +00:00
document.getElementById('Sound2').SetVariable("Volume", svolm);
document.getElementById('Sound2').SetVariable("Sndplay", s);
}
},
2022-06-06 21:30:34 +00:00
getSwf:function(val) {
var M$ = navigator.appName.indexOf("Microsoft")!=-1
return (M$ ? window : document)[val]
},
trim: function (s) {
return this.rtrim(this.ltrim(s));
},
ltrim: function (s) {
return s.replace(/^\s+/, '');
},
rtrim: function (s) {
return s.replace(/\s+$/, '');
},
multiaddto: function (users, tp) {
var arr = users.split(',');
var i = arr.length;
while (i >= 0) {
if (arr[i] != undefined) {
this.addto(arr[i], tp);
}
i--;
}
},
osize:function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
},
2023-01-10 16:29:32 +00:00
//Генерируем данные
2022-06-06 21:30:34 +00:00
genchatData:function(data,prs) {
if (prs == 1) {
2023-01-10 16:29:32 +00:00
// console.log("тут")
2022-06-06 21:30:34 +00:00
data = $.parseJSON(data);
}
if (data == null && this.saveData != null) {
data = this.saveData;
data.js = '';
data.rn = undefined;
data.key = undefined;
}
2023-01-10 16:29:32 +00:00
//Получаем сообщение
2022-06-06 21:30:34 +00:00
if (data.msg != undefined) {
var ms = $.parseJSON(data.msg);
// console.log(ms)
if (ms['ld'] > this.msg_id) this.msg_id = ms['ld'];
var i = 0;
while (i <= ms['id']) {
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if (ms[`m${i}`] != undefined) {
// console.group(ms[`m${i}`])
this.sendMsg(ms[`m${i}`]);
}
i++;
}
}
2023-01-10 16:29:32 +00:00
//Если есть JS
2022-06-06 21:30:34 +00:00
if (data.js != '') eval(data.js);
2022-12-19 18:26:14 +00:00
if(data.rnd!=undefined) c.rnd = data.rnd;
2022-06-06 21:30:34 +00:00
if (data.rn != undefined) {
if ($('#chcf10').attr('checked') == true) {
2023-01-10 16:29:32 +00:00
$('#roomName').html(`${data.rn}<br><small>Общий онлайн: ${data.xu}</small>`);
2022-12-19 18:26:14 +00:00
}
2022-06-06 21:30:34 +00:00
else $('#roomName').html(`${data.rn} (${data.xu})`);
}
if(data.key!=undefined) this.key = data.key;
if(data.list!=undefined)
{
2023-01-10 16:29:32 +00:00
var i = 0, ji = $.parseJSON(data.list), onll = '', fSort = {}, flSort = {},flSortSee = '"Служба Поддержки"';
//сортируем данные
2022-06-06 21:30:34 +00:00
while (i <= data.xu) {
if (ji[i] != undefined) {
2023-01-10 16:29:32 +00:00
jj = ji[i][1].toLowerCase(); //по логину
2022-06-06 21:30:34 +00:00
fSort[jj] = i;
flSort[i] = jj;
flSortSee += `,"${flSort[i]}"`;
}
i++;
}
flSortSee = eval(`[${flSortSee}]`);
if ($.cookie('chatCfg9') == 1) flSortSee.sort(game.sort2);
else flSortSee.sort(game.sort1);
2023-01-10 16:29:32 +00:00
//Выводим данные
2022-06-06 21:30:34 +00:00
i = 0;
var onll_alh = '';
while (i <= data.xu) {
if (fSort[flSortSee[i]] != undefined) {
if (ji[fSort[flSortSee[i]]][3] == 50) {
onll_alh += `<span class="m0c1">${this.gUser(ji[fSort[flSortSee[i]]],true)}</span>`;
} else {
onll += `<span class="m0c2">${this.gUser(ji[fSort[flSortSee[i]]],true)}</span>`;
}
}
i++;
}
$('#onlist').html(`${onll_alh}${onll}`);
}
},
voiceMessage: function () {
2022-12-19 18:26:14 +00:00
flagVoice = !flagVoice
2022-06-06 21:30:34 +00:00
if (flagVoice) return chat.startRecording(flagVoice)
2022-12-19 18:26:14 +00:00
return chat.startRecording(flagVoice)
2022-06-06 21:30:34 +00:00
},
startRecording: function (flag) {
if (flag) {
if (navigator.mediaDevices.getUserMedia) {
var $pVoiceMessages = document.getElementById("timerVoiceMess")
$pVoiceMessages.hidden = false
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
var constraints = {
audio: true
}
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
var onSuccess = function (stream) {
mediaRecorder = new MediaRecorder(stream);
mediaRecorder.start()
timerSecMessage = 0
var timerMlSecMessage = 1
setIntervalSound = setTimeout(function tickMlsec() {
if (timerSecMessage === 60) {
flagVoice = !flagVoice
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
chat.styleRecordButton({
2023-01-10 16:29:32 +00:00
textButt: "Запись",
2022-06-06 21:30:34 +00:00
color: "",
backgroundColor: "",
allSetting: true
})
return
}
if (timerSecMessage > 9) $pVoiceMessages.textContent =
`00:${timerSecMessage},${timerMlSecMessage}`
else $pVoiceMessages.textContent =
`00:0${timerSecMessage},${timerMlSecMessage}`
if (++timerMlSecMessage > 9) {
timerMlSecMessage = 0
2022-12-19 18:26:14 +00:00
++timerSecMessage
2022-06-06 21:30:34 +00:00
}
setIntervalSound = setTimeout(tickMlsec, 100)
}, 100)
chat.styleRecordButton({
2023-01-10 16:29:32 +00:00
textButt: "Завершить",
2022-06-06 21:30:34 +00:00
color: "rgb(165, 0, 0)",
backgroundColor: "rgba(255, 0, 0, 0.083)",
allSetting: false
})
mediaRecorder.ondataavailable = function (e) {
chunksVoice.push(e.data)
}
}
var onError = function (err) {
2023-01-10 16:29:32 +00:00
console.log(`Ошибка: ${err}`)
alert("Ошибка, проверьте подключение или работоспособность микрофона!")
2022-06-06 21:30:34 +00:00
}
navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onError)
2023-01-10 16:29:32 +00:00
} else console.log("Аудиосообщения не поддерживаются вашим браузером!")
2022-06-06 21:30:34 +00:00
return
}
chat.styleRecordButton({
2023-01-10 16:29:32 +00:00
textButt: "Запись",
2022-06-06 21:30:34 +00:00
color: "",
backgroundColor: "",
allSetting: true
})
return
},
styleRecordButton: function (objArgs) {
var {
textButt,
color,
backgroundColor,
allSetting
} = objArgs
var $buttonVoiceMess = document.getElementById("record")
var $pVoiceMessages = document.getElementById("timerVoiceMess")
if (allSetting) {
clearInterval(setIntervalSound)
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
$pVoiceMessages.textContent = "00:00,0"
$buttonVoiceMess.textContent = textButt
$buttonVoiceMess.style.color = color
$buttonVoiceMess.style.backgroundColor = backgroundColor
$pVoiceMessages.hidden = allSetting
2023-01-10 16:29:32 +00:00
if (!mediaRecorder) return alert("Ошибка, проверьте подключение или работоспособность микрофона! Если Вы подключили микрофон и всё работает - перезагрузите страницу <F5> и попробуйте снова!")
2022-06-06 21:30:34 +00:00
mediaRecorder.stop()
mediaRecorder.onstop = function (e) {
chat.mediaRecorderStop()
}
mediaRecorder.stream.getAudioTracks().forEach(function (track) {
track.stop()
})
return
}
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
var $footerTop = document.getElementsByClassName("allChat")[1].offsetTop
var $tdLeft = $buttonVoiceMess.parentElement.offsetLeft
var $VoiceWidth = $buttonVoiceMess.clientWidth
2022-12-19 18:26:14 +00:00
var $pVoiceWidth = $pVoiceMessages.clientWidth
2022-06-06 21:30:34 +00:00
$pVoiceMessages.style.top = `${$footerTop - 30}px`
$pVoiceMessages.style.left = `${($tdLeft + 9) + (($VoiceWidth - $pVoiceWidth) / 2)}px`
$buttonVoiceMess.textContent = textButt
$buttonVoiceMess.style.color = color
$buttonVoiceMess.style.backgroundColor = backgroundColor
$pVoiceMessages.hidden = allSetting
return
},
mediaRecorderStop: function () {
2022-12-19 18:26:14 +00:00
2022-06-06 21:30:34 +00:00
if (timerSecMessage < 2) {
chunksVoice.pop()
return
}
var blob = new Blob(chunksVoice, {
'type': 'audio/mp3; codecs=opus'
})
chunksVoice.pop()
var fileReader = new FileReader()
fileReader.readAsArrayBuffer(blob)
fileReader.onload = async function (event) {
var $inputWindow = document.getElementById("textmsg")
var arrayBuffer = fileReader.result
var response = await fetch("/audio.php", {
2022-06-06 21:30:34 +00:00
method: "POST",
body: arrayBuffer
})
var timeStampFile = await response.text()
$inputWindow.value =
`${$inputWindow.value} audio_${timeStampFile}.mp3`
chat.subSend()
}
}
}