Tuesday 15 February 2011

php - AJAX chat - Personal alerts for users (commands) -


So I have an Ajax chat that I am programming, and a command system for it.

Actually, I want the system to warn a user if he does not use any command, and is only posting slash ('/'), and it only Be seen by user as seen who posted it. > But I'm not sure how this works. This is my load message method, in chat:

  Public function loads ($ username) {$ this-> fetch = $ this- & gt; Pdo- & gt; Ready (Date, time ASC limit 30 by "SELECT * messages"); $ This- & gt; Fetch- & gt; Executed (); While receiving ($ line = $ this- & amp; fetch- & gt; (PDF :: FETCH_ASSOC)) {if ($ line [isAlert '] ==' 1 ') {echo'   

If you can see in the statement for the first time, see if the message was a global warning, if so, then paint it in red < / P>

But how can I create a message that will only be able to see the alert user?

Any thoughts?

Keep div hidden on the page, then javascript Check whether to use for example:

  & lt; Div id = "invalidChatCommand" style = "display: command is valid, if  div  none" & gt; & Lt; P & gt; The order you entered is invalid & lt; / P & gt; & Lt; Div & gt; & Lt; Script type = "text / javascript" & gt; Var chatCommand = document.getElementById ("command"). Values; If (chatCommand.length == 1and chat command. Substring (0, 1) == "/") {// Invalid input detected, div var invalidCommand = document.getElementById ("invalidChatCommand"); InvalidCommand.style.display = "block"; } And {// send commands to server} & lt; / Script & gt;    

No comments:

Post a Comment