Guest User

Chat Log Generator.js

a guest
Jun 14th, 2017
125
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 June 10, 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, isEstimation) {
  10.     var d = new Date(timestamp),
  11.         c = isEstimation ? "~" : ":";
  12.     return "[" + d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1, 2) + "-" + pad(d.getUTCDate(), 2) + " " + pad(d.getUTCHours(), 2) + c + pad(d.getUTCMinutes(), 2) + c + pad(d.getUTCSeconds(), 2) + "]";
  13. }
  14. var logs = "";
  15. var count = 0;
  16. var logModels = mainRoom.viewDiscussion.model.chats.models;
  17. logModels.map(function(a) {
  18.     var b = a.attributes,
  19.         d,
  20.         isMsg = b.name.length > 0;
  21.     if (!isMsg) {
  22.         // (dolanside)
  23.     } else {
  24.         d = datify(b.timeStamp);
  25.         new Date(b.timeStamp);
  26.         logs += (
  27.             (d + " ") +
  28.             (isMsg ? "&lt;" + b.name + "&gt; " : "-!- ") +
  29.             b.text + "\n"
  30.         );
  31.         count++;
  32.     }
  33. });
  34. copy(logs);
  35. alert(count + " logs were copied to the clipboard!");
RAW Paste Data