Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pad(n, len) {
- n = String(n);
- if (n.length < len) {
- n = new Array(len - n.length + 1).join("0") + n;
- }
- return n;
- }
- function datify(timestamp, isEstimation) {
- var d = new Date(timestamp),
- c = isEstimation ? "~" : ":";
- return "[" + d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1, 2) + "-" + pad(d.getUTCDate() + 1, 2) + " " + pad(d.getUTCHours(), 2) + c + pad(d.getUTCMinutes(), 2) + c + pad(d.getUTCSeconds(), 2) + "]";
- }
- var logModels = mainRoom.viewDiscussion.model.chats.models;
- logModels.map(function(a, i) {
- var b = a.attributes,
- d,
- isMsg = b.name.length > 0;
- if (!isMsg) {
- // since we cannot get the timestamp of an alredy-received inline alert, we can still go back to the previous message and get its timestamp (if any)
- for (var j = i - 1; j >= 0; j--) {
- if (logModels[j].attributes.name.length > 0) {
- d = datify(logModels[j].attributes.timeStamp, true);
- break;
- }
- if (j === 0) {
- // reached first message without finding any timestamp- no way of knowing the original timestamp
- d = "[????-??-?? ??:??:??]";
- }
- }
- } else {
- d = datify(b.timeStamp);
- }
- new Date(b.timeStamp);
- return (
- (d + " ") +
- (isMsg ? "<" + b.name + "> " : "-!- ") +
- b.text
- );
- }).join("\n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement