message.js 863 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. Common Message app Tools
  3. */
  4. //Current watching channel, leave empty for all
  5. var channelID = "";
  6. var userstate = "standby"; //standby / typing / uploading
  7. //Current status return data from last rpc
  8. var statusData = {};
  9. var rpcCallback = undefined;
  10. //Setup timer to update the above two paramters
  11. setInterval(function(){
  12. updateStatus();
  13. }, 5000);
  14. //Call this function on start
  15. function updateStatus(){
  16. var messageInputValue = $("#msgInput").val();
  17. if (messageInputValue.trim() != ""){
  18. userstate = "typing";
  19. }else{
  20. userstate = "standby";
  21. }
  22. ao_module_agirun("Message/backend/rpc.js", {
  23. channel: channelID,
  24. userstate: userstate
  25. }, function(data){
  26. statusData = data;
  27. if (rpcCallback != undefined){
  28. rpcCallback(data);
  29. }
  30. });
  31. }