jQuery PHP Chat用户正在输入功能

时间:2016-12-03 19:58:33

标签: php jquery chat

我使用jquery显示某人正在键入。

一切正常,但我希望每个人都能看到这一点,我无法想到任何帮助吗?

var textarea = $('#input');
var typingStatus = $('#typing_on');
var lastTypedTime = new Date(0); // it's 01/01/1970
var typingDelayMillis = 1500; // how long user can "think about his spelling" before we show "No one is typing -blank space." message

function refreshTypingStatus() {
    if (!textarea.is(':focus') || textarea.val() == '' || new Date().getTime() - lastTypedTime.getTime() > typingDelayMillis) {
        typingStatus.html('');
    } else {
        typingStatus.html('<div id="new"><div class="comment" style="display:inline;"><div class="user_name"> <b><font color="white"><?php echo $pernome?> <br> <center> <b style="font-size:9px;"> <?php echo $datenow?>  </b> </center></font></b></div></div>  <div class="comment" style="display:inline; position:relative; font-size:14px; bottom:6px; color:#ffffff; margin-bottom:2px;">מקליד...</div></div>');
    }
}
function updateLastTypedTime() {
    lastTypedTime = new Date();
}

setInterval(refreshTypingStatus, 100);
textarea.keypress(updateLastTypedTime);
textarea.blur(refreshTypingStatus);

谢谢!

0 个答案:

没有答案