if (rango == 3 && /(\w{12,})|(https?\:\/\/)/g.test(text.replace(/\s+/g, ''))) return; |
Спасибо, все работает :thanks:
|
Появилась необходимость так же удалять сообщения от определенных сессий, сессия выглядит примерно так: b57d72832e49247ea643c4bc8eaab8d1
Попробовал дописать таким образом: document.querySelectorAll(".KIDE_msg_top").forEach(msg => { for (let { textContent } of msg.querySelectorAll("span")) if (sesion == cd112ab6890ac4fc25030e2bbcbd7e08 && /\w{11,}/g.test(textContent.replace(/\s+/g, ''))) { msg.remove(); break; } }) Но не хочет работать :help: |
Дополню, при формировании сообщения это условие срабатывает, сделал так:
if (sesion == cd112ab6890ac4fc25030e2bbcbd7e08 && rango == 3 && /(\w{12,})|(https?\:\/\/)/g.test(text.replace(/\s+/g, ''))) return; И все прекрасно фильтруется, но при обновлении страницы сообщения опять появляются. |
Ubivectel,
а кавычки? == "cd112ab6890ac4fc25030e2bbcbd7e08" |
Да да, без них встает код
|
Цитата:
Цитата:
условно типа var sesion = "<?php echo $_SESSION['username'] ?>" |
Это так понимаю не то?
foreach ($this->msgs as $r) { $tiempo = gmdate($this->fecha, $r->time + $this ->user->gmt * 3600); echo '<div id="KIDE_id_' . $r->id . '" class="KIDE_msg_top">'; if ($this->show_hour) echo '<span class="KIDE_msg_hour"> ' . gmdate($this->formato_hora, $r->time + $this->user->gmt * 3600) . '</span> '; echo '<span title="' . $tiempo . '" oncontextmenu="event.preventDefault();kide.mensaje(\'' . addslashes($r->name) . '\',' . $r->userid . ',' . $r->id . ',\'' . $r->url . '\',\'' . $tiempo . '\',\'' . $r->sesion . '\',' . $r->rango . ',\'' . $r->img . '\')" class="' . KideHelper::getRango($r->rango, 'KIDE_') . '">'; echo '<span style="cursor: pointer" title="' . $tiempo . '" onclick="kide.insertSmile(\'' . addslashes($r->name) , ', ' . '\')" class="' . KideHelper::getRango($r->rango, 'KIDE_') . '">'; echo $r->name; echo "</span>"; $c = $r->color === '' ? 'class="' . KideHelper::getRango($r->rango, 'KIDE_dc_') . ' KIDE_msg"' : 'style="color:#' . $r->color . '"'; echo ': <span ' . $c . '>' . $r->text . ' </span> <i class="fa fa-reply qutes" title="Цитировать" aria-hidden="true"></i> <span class="hig K_copy"><i class="fa fa-clipboard" title="Копировать" aria-hidden="true"></i></span> <span class="editors"><i class="fa fa-pencil" aria-hidden="true"></i></span></br> </div>'; } |
Цитата:
|
И тут никак?
kide.insertNewContent = function ( uid, name, text, url, ti, color, rango, id, sesion, yo, hora, img ) { console.log(hora, name, rango, sesion, text); if (rango == 3 && /(\w{12,})|(https?\:\/\/)/g.test(text.replace(/\s+/g, ''))) return; // if (rango == 3 && /\w{12,}/g.test(text.replace(/\s+/g, ''))) return; if (text.replace(/ /g, "") != "") { let c = color.length > 0 ? 'style="color:#' + color + '" class="KIDE_msg"' : 'class="KIDE_dc_' + this.rangos[rango] + ' KIDE_msg"'; let div = this.$("KIDE_msgs"); let nodo = document.createElement("div"); let insertO = this.$("KIDE_output"); let s_hora; let bquote = document.querySelector("#insertmsg"); nodo.setAttribute("id", "KIDE_id_" + id); nodo.setAttribute("class", "KIDE_msg_top"); if (this.show_hour) s_hora = '<span title="' + ti + '" class="KIDE_msg_hour">' + hora + "</span> "; else s_hora = ""; let tmp = ""; if (img && kide.show_avatar) { let style = kide.avatar_maxheight ? 'style="max-height:' + kide.avatar_maxheight + '" ' : ""; tmp = "<img " + style + 'src="' + img + '" class="KIDE_icono" alt="" /> '; } nodo.innerHTML = s_hora + tmp + '<span style="cursor: pointer" class="KIDE_' + this.rangos[rango] + '" onclick="kide.insertSmile(\'' + //mod name + ", ')\" oncontextmenu=\"event.preventDefault();document.querySelector(\'.overlayo\').style.display = \'block\';kide.mensaje('" + name + "', " + uid + ", " + id + ", '" + url + "', '" + ti + "', '" + sesion + "', " + rango + ", '" + img + "')\">" + name + "</span>: <span " + c + ">" + this.filter_smilies(text) + "</span>" + "<i class='fa fa-reply qutes' title='Цитировать' aria-hidden='true'></i>" + "<i class='fa fa-clipboard K_copy' title='Копировать' aria-hidden='true'></i>"; + //mod "<span class='editors'><i class='fa fa-pencil' title='Редактировать' aria-hidden='true'></i></span>"; //mod if (this.order == "bottom") { this.insertAfter(nodo, insertO.lastChild); } else insertO.insertBefore(nodo, insertO.firstChild); if (!yo && this.sound == 1) this.play_msg_sound(); this.ajustar_scroll(); } }; |
Часовой пояс GMT +3, время: 10:16. |