Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. (function(window, document, options, undefined) {
  2. var shout = document.getElementById(options.shout_id),
  3. chats = shout.children[0],
  4. form = shout.children[1];
  5. appendMessage = function(epoch, user_id, username, group_id, raw_content, autoscroll) {
  6. var must_scroll = autoscroll && chats.scrollTop == (chats.scrollHeight - chats.offsetHeight);
  7. if(must_scroll) {
  8. chats.scrollTop = chats.scrollHeight;
  9. }
  10. var local_date = new Date(0);
  11. local_date.setUTCSeconds(epoch);
  12.  
  13. var count = chats.childElementCount,
  14. p = document.createElement('p'),
  15. a = document.createElement('a'),
  16. name = document.createTextNode(username),
  17. d = document.createElement('span');
  18.  
  19. // Format the username
  20. a.setAttribute('href', 'profile.php?id=' + parseInt(user_id));
  21. a.setAttribute('target', '_blank');
  22. a.className = usergroup_id_to_class_name(group_id);
  23. a.appendChild(name);
  24.  
  25. // Format date
  26. d.textContent = '[' + local_date.toLocaleTimeString() + '] ';
  27. d.className = 'dateTime';
  28.  
  29. // Format the message
  30. p.textContent = ': ' + decodeHtml(raw_content);
  31.  
  32. // Create links
  33. p.innerHTML = anchorme(p.innerHTML, {
  34. attributes:[
  35. {
  36. name: "target",
  37. value: "_blank"
  38. }
  39. ]});
  40.  
  41. p.insertBefore(a, p.firstChild);
  42. p.insertBefore(d, p.firstChild);
  43.  
  44. if ((count % 2) == 0) {
  45. p.className = 'rowEven';
  46. } else {
  47. p.className = 'rowOdd';
  48. }
  49.  
  50. chats.appendChild(p);
  51. };
  52. var chat_input = document.getElementById('shouttext');
  53. })(
  54. this,
  55. this.document,
  56. {
  57. lang_code: 'en',
  58. shout_id: 'shout',
  59. }
  60. );
  61.  
  62. var seconds = Math.round((new Date()).getTime() / 1000);
  63. appendMessage(seconds, 2, 'admin', 1, encodeHtml('apolo gay'), true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement