{{item.title}}
{{item.caption}}
{{chat_short_name()}}
{{chat.action}}
Как-то пустовато здесь
Найдем ближайший активный чат?
Сообщений нет
{{item.user.name}}
{{ item.time }}
Введите ваше сообщение...
') code = `
`; if(code == '<--symp-->') code = `
`; if(code.indexOf('<--Audio') > -1){ let link = code.split('[')[1]; link = link.split(']')[0]; code = `
`; } if(msg && msg.parse_mode == 'Markdown'){ code = app.markdownToHtml(code); } if(code.indexOf('https://') > -1){ function replaceHttpsLinks(string) { if(string.indexOf('') > -1 || string.indexOf('') > -1) return string; // Регулярное выражение для поиска HTTPS ссылок var regex = /https:\/\/[^<>\s]+/g; // Заменяем все HTTPS ссылки на ссылки с классом "mc_link" var replacedString = string.replace(regex, function(match) { return "
" + match + "
"; }); return replacedString; } code = replaceHttpsLinks(code); } // console.log(code); return code; }, input_action(action){ let holder = input.innerHTML; // if(holder.replace(/<[^>]*>/g, '').trim().length > 0) app.chat.message.holder = holder; handleSaveInput(); if(action == false) { // if(input.innerHTML.replaceAll('
', '').replaceAll(' ', '').replaceAll(' ', '').trim() == '') input.innerHTML = message_holder; // app.chat.message.holder = true; // app.ui.m_holder = ''; } else { // if(input.innerHTML == message_holder) input.innerText = ''; // delete app.chat.message.holder; if(action == 'type'){ // app.chat.message.text = input.innerHTML; } else { input.focus(); setTimeout(()=>{input.focus()}, 25); setTimeout(()=>{input.focus()}, 125); setTimeout(()=>{input.focus()}, 1125); } } }, setAction(new_action){ // Notiflix.Loading.Pulse('Подключение'); this.chat.action = new_action; }, animate_advice_border() { document.querySelector('.advice_box .bg').setAttribute('class', 'bg animate__animated animate__flash'); }, nearSwitch() { console.log('Start switching...'); this.advice_show = false; socket.emit('switch_local_chat', {room: room, uid: uID}); }, getNameColor(str) { if(str == 'bell') { if(this.chat.anon == true || webkey == null) return null; return this.user.notifications ? `` : `bds`; } var hash = 0; for (var i = 0; i < str.length; i++) { hash = str.charCodeAt(i) + ((hash << 5) - hash); } var colour = '#'; for (var i = 0; i < 3; i++) { var value = (hash >> (i * 8)) & 0xFF; colour += ('00' + value.toString(16)).substr(-2); } return `color: ${colour};filter: contrast(0.5);`; }, flowProcess(flow){ if(flow[0] == null) flow = [flow]; let new_flow = [], day_start_date = 0, ic = 0; flow.sort(function(a, b) { var keyA = new Date(a.time), keyB = new Date(b.time); // Compare the 2 dates if (keyA < keyB) return -1; if (keyA > keyB) return 1; return 0; }); for (let i of flow){ if (i.user && i.user.uid == app.user.id) i.reverse = true; let next_same = flow[ic-1] && flow[ic-1].user ? flow[ic-1].user.uid == i.user.uid : false; let rd = getRoundedDate(1440, new Date(i.time)).getTime(); if (day_start_date < rd){ let t_s = moment(new Date(i.time)).format(`LL`); t_s = t_s.split(` ${new Date().getFullYear()}`); if(t_s.length > 1){ t_s = t_s[0].trim().replace(',', ''); } else t_s = moment(new Date(i.time)).format(`LL`); new_flow.unshift( { text: t_s.replaceAll('\n', '
'), system: true } ); day_start_date = rd; next_same = false; } if(i.image && i.system){ new_flow.unshift({ image: i.image, text: '', system: true }) } if(i.text) new_flow.unshift( { id: i.id, text: i.text.replaceAll('\n', '
'), time: moment(i.time).format(`HH:mm`), user: { avatar: next_same ? '' : i.user.avatar, name: next_same ? '' : i.user.name, id: i.user.uid, url: (i.user.uid ? `https://facetoplace.app/${i.user.uid}` : null) }, parse_mode: i.parse_mode, classes: { m: i.reverse ? 'chat__conversation-board__message-container reversed'+(next_same ? ' unflow' : '') : 'chat__conversation-board__message-container'+(next_same ? ' unflow' : ''), a: i.reverse ? 'chat__conversation-board__message__person reversed' : 'chat__conversation-board__message__person', s: i.reverse ? 'chat__conversation-board__message__service reversed' : 'chat__conversation-board__message__service', c: i.reverse ? 'chat_message_bubble' : 'chat_message_bubble covert_timer' } } ); // let igetRoundedDate(1440) ic++; } return new_flow; }, openLink() { // window.location.href = "https://facetoplace.app/devstorm"; }, openChat(id) { socket.emit('chat', {action: 'switch_chat', id: id}); }, async switch_chat(to){ console.log('switch_to_room:', to); await socket.emit('disconnect_to_room', {room: room, key: webkey}); room = to.room; app.chat.room = to.room; app.flow = {}; app.chat.flow = []; await socket.emit('connect_to_room', {room: room, uid: uID, key: webkey}); app.updateChat(); setTimeout(() => { app.getChat(); }, 100); setTimeout(() => { app.getChat(); }, 4000); }, save() { app.last_save = new Date().getTime(); if(app_cache == null || app_cache.last_save < app.last_save){ app_cache = app._data; setCookie(`chat_cache`, encodeURIComponent(JSON.stringify(app_cache))); } }, switch_anon() { if(app.profiles[1] == null) return false; else { if(anon_key){ this.user = anon_key; setTimeout(()=>{ this.user.notifications = notifications; }, 1200); webkey = app.user.key; anon_key = null; app.chat.anon = null; app.updateUser(); } else { if(app.user.key){ anon_key = app.user; notifications = app.user.notifications; app.user = {profile: app.profiles[1]}; webkey = null; app.chat.anon = true; app.updateUser(); } } setTimeout(()=> { document.getElementsByClassName('actions_box')[0].classList.remove('hidden_o'); app.updateChat(); }, 2000) } }, send_message(){ let t = ''; t += `\ncustom_top: ${getComputedStyle(document.documentElement).getPropertyValue("--safe-top")}`; t += `\nsystem_top: ${getComputedStyle(document.documentElement).getPropertyValue("--safe-area-inset-top")}`; let text = input.innerText; app.chat.message.text = (text && text != '' ? text : null) || app.chat.message.text; socket.emit("message_send", {room: room, text: app.chat.message.text.trim(), message: app.chat.message, uid: uID, key: webkey}); app.chat.message.text = ''; // app.chat.message.holder = ''; setTimeout(()=>{ app.chat.message.holder = ''; }, 400); setCookie('chat_holder', null); gotoBottom(`chat_board`); input.innerHTML = ''; input.focus(); setTimeout(() => { app.ChatScroll(true); }, 1600); }, isVisible(elem) { if(typeof elem == "string") elem = document.querySelector(elem); if (!(elem instanceof Element)) throw Error('DomUtil: elem is not an element.'); const style = getComputedStyle(elem); if (style.display === 'none') return false; if (style.visibility !== 'visible') return false; if (style.opacity < 0.1) return false; if (elem.offsetWidth + elem.offsetHeight + elem.getBoundingClientRect().height + elem.getBoundingClientRect().width === 0) { return false; } const elemCenter = { x: elem.getBoundingClientRect().left + elem.offsetWidth / 2, y: elem.getBoundingClientRect().top + elem.offsetHeight / 2 }; if (elemCenter.x < 0) return false; if (elemCenter.x > (document.documentElement.clientWidth || window.innerWidth)) return false; if (elemCenter.y < 0) return false; if (elemCenter.y > (document.documentElement.clientHeight || window.innerHeight)) return false; let pointContainer = document.elementFromPoint(elemCenter.x, elemCenter.y); do { if (pointContainer === elem) return true; } while (pointContainer = pointContainer.parentNode); return false; }, loadHistory(from_id, time){ socket.emit('chat', {action: 'get_history', room: room, from: from_id, key: app.key, time: time}); }, ChatScroll(scroll_action) { let chat_el = document.getElementById('chat_board'); if(scroll_action){ chat_el.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" }); } else { let pos = chat_el.scrollTop; let up_l_stripe = document.querySelector('.up-load-stripe') let up_load = this.isVisible(up_l_stripe); console.log('up_load:', up_load); if(up_load){ let m_id = up_l_stripe.getAttribute('m_id'); this.loadHistory(m_id, 'past'); } if(pos < -60) app.chat.bottom_state = false; else app.chat.bottom_state = true; if(pos < -20) document.getElementsByClassName('shadow')[0].classList.remove('hidden_o'); else document.getElementsByClassName('shadow')[0].classList.add('hidden_o'); } } } }); // Пример привязки обработчика события on-input к элементу ввода данных const inputElement = document.getElementById('input'); inputElement.addEventListener('input', handleInput); function ec_ch(){ if(window.location.href.indexOf('https://facetoplace.app') == 0){ if(app.chat.title == 'Пустынный чат') app.nearSwitch(); } } setTimeout(()=>{ ec_ch() }, 800); setTimeout(()=>{ ec_ch() }, 1200); setTimeout(()=>{ ec_ch() }, 2800); setTimeout(()=>{ ec_ch() }, 5000); function keyboard_exist(index){ if(index){ let btm_m = getComputedStyle(document.documentElement).getPropertyValue('--safe-bottom') || '0px'; btm_m = btm_m.replace('px', ''); document.getElementById('chat_board').setAttribute('style', `transform: translateY(-${(index-btm_m)}px);`); document.getElementsByClassName('input-form')[0].setAttribute('style', `transform: translateY(-${(index-btm_m)}px);`); //Только для iOS document.getElementsByClassName('shadow')[0].setAttribute('style', `transform: translateY(-35px);`); } else { document.getElementById('chat_board').setAttribute('style', ``); document.getElementsByClassName('input-form')[0].setAttribute('style', ``); } // setTimeout(()=>{alert(`${index}`);}, 500); } //POST if(1 == 0){ setTimeout(() => { window.postMessage('Listener test string', '*'); console.log(`Sent: iosListener test string`); }, 1500); setTimeout(() => { window.postMessage(JSON.stringify({action: 'close_window'}), '*'); console.log(`Sent:`, {action: 'close_window'}); }, 9000); function inAppHandler(message){ window.postMessage(`Получено сообщение: ${message}`, '*'); alert(message); } } -->