PHP Classes

File: web/js/chat.js

Recommend this page to a friend!
  Classes of David Girón   PHP Telegram Web Chat   web/js/chat.js   Download  
File: web/js/chat.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Telegram Web Chat
Interact with Telegram users via a Web based chat
Author: By
Last change:
Date: 3 years ago
Size: 1,184 bytes
 

Contents

Class file image Download
var Chat = { defaultPic: "https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&f=y", ajax: null, addMessage: function (text, from, userpic){ var align = (from == 1 ? "right" : "left"); var photo = this.defaultPic; if(userpic){ photo = userpic; } var code = '<div class="media">'; if(align == "left"){ code += '<div class="media-left"><a href="#"><img class="media-object" src="'+ photo +'"></a></div>'; } code += '<div class="media-body text-'+ align +'"><p>' + text + '</p></div>'; if(align == "right"){ code += '<div class="media-right"><a href="#"><img class="media-object" src="'+ photo +'"></a></div>'; } code += '</div>'; $("main").append(code); }, addMessageTemp: function (text){ var photo = this.defaultPic; var code = '<div class="media temp">' + '<div class="media-body text-'+ align +'"><p class="text-muted">' + text + '</p></div>' + '<div class="media-right"><a href="#"><img class="media-object" src="'+ photo +'"></a></div>' + '</div>'; $("main").append(code); }, sendMessage: function (txt, sess){ $.ajax({ url: this.ajax + "/send", data: {session: sess, text: txt}, method: "POST" }); } }