Guest User

Chat Log Generator.js

a guest
Dec 28th, 2017
586
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Written by Penguin-Pal (https://pastebin.com/pEhBsWB3) and modified by Hey.youcp on December 28, 2017
  2. function pad(n, len) {
  3.     n = String(n);
  4.     if (n.length < len) {
  5.         n = new Array(len - n.length + 1).join("0") + n;
  6.     }
  7.     return n;
  8. }
  9. function datify(timestamp) {
  10.     var d = new Date(timestamp);
  11.     return "[" + d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1, 2) + "-" + pad(d.getUTCDate(), 2) + " " + pad(d.getUTCHours(), 2) + ":" + pad(d.getUTCMinutes(), 2) + ":" + pad(d.getUTCSeconds(), 2) + "]";
  12. }
  13. var logs = "";
  14. var count = 0;
  15. var logModels = mainRoom.viewDiscussion.model.chats.models;
  16. logModels.map(function(a) {
  17.     var b = a.attributes;
  18.     var isMsg = b.name.length > 0;
  19.     if (isMsg) {
  20.         var d = datify(b.timeStamp);
  21.         logs += (
  22.             (d + " ") +
  23.             ("&lt;" + b.name + "&gt; ") +
  24.             b.text.replace(/\n/g, "\n" + d + " " + "&lt;" + b.name + "&gt; ") + "\n"
  25.         );
  26.         count++;
  27.     }
  28. });
  29. copy(logs);
  30. alert(count + " logs were copied to the clipboard!");
RAW Paste Data