13/07/2018
(async function(endYear) {
"use strict";
function doc(url) {
return new Promise(function(resolve, reject) {
var req = new XMLHttpRequest;
req.onload = () => setTimeout(resolve, 500, req.response);
req.onerror = () => reject(req.statusText);
req.responseType = "document";
req.open("GET", url);
req.send();
});
}
const url = "https://www.lfs.net/forum/thread/91876";
let sticky = document.createElement("div");
sticky.style.cssText = "position: fixed; width: 700px; height: 200px; top: 50%; left: 50%;"
+ "margin-top: -100px; margin-left: -350px; background-color: white; padding: 20px; text-align: center; font-size: x-large;"
sticky.onclick = function() { this.remove(); };
document.body.appendChild(sticky);
let docs = [document];
let m = document.querySelector(".PageSelectorDiv");
if (m) {
let count = parseInt(m.lastElementChild.textContent),
curr = parseInt(m.querySelector("div").textContent);
sticky.textContent = `fetching page 2/${count}`;
if (curr != 1)
docs.push(await doc(url));
for (let i = 2; i <= count; ++i)
if (i != curr) {
sticky.textContent = `fetching page ${docs.length+1}/${count}`;
docs.push(await doc(url + "/page/" + i));
}
}
let dates = [];
const re = (/(\d\d?)(\.|\/)(\d\d?)\2(\d\d\d\d)/);
let e = endYear && new Date(Date.UTC(endYear));
for (let doc of docs) {
for (let post of doc.querySelectorAll(".FPostText")) {
if (post.closest("#Post1933583")) continue;
let m = re.exec(post.textContent);
if (m) {
let d = new Date(Date.UTC(m[4]|0, (m[3]|0)-1, m[1]|0));
if (!e || e - d > 0)
dates.push(d);
}
}
}
dates.sort((a, b) => a - b);
let mm = document.createElement("div");
mm.style.cssText = "position: absolute; top: 50%; min-width: 1px; min-height: 5px;"
+ "background: linear-gradient(to bottom, black, black) 50% 0 / 1px 5px no-repeat;"
+ "transform: translate(-50%, -2px);";
let ym = mm.cloneNode(false);
ym.style.cssText += "background-size: 1px 9px; padding-top: 8px; font-size: small; transform: translate(-50%, -4px);";
let start = 2018;
let end = dates[dates.length - 1].getUTCFullYear() + 1;
let g = document.createElement("div");
g.style.cssText = "position: relative; width: 100%; height: 100%; background: linear-gradient(to left, black, black) 0 50% / 100% 1px no-repeat;";
sticky.textContent = "";
sticky.appendChild(g);
const st = Date.UTC(start),
et = Date.UTC(end);
const step = 100 / (end - start) / 12;
let offset = 0;
for (let year = start; year < end; ++year) {
let y = ym.cloneNode(false);
y.textContent = year;
y.style.left = offset + "%";
offset += step;
g.appendChild(y);
for (let i = 1; i < 12; ++i) {
let m = mm.cloneNode(false);
m.style.left = offset + "%";
offset += step;
g.appendChild(m);
}
}
let fy = ym.cloneNode(false);
fy.textContent = end;
fy.style.left = "100%";
g.appendChild(fy);
let em = document.createElement("div");
em.style.cssText = "position: absolute; top: 50%;"
+ "width: 16px; height: 16px; background: radial-gradient(circle, rgba(255, 0, 0, 0.7), transparent 67%);"
+ "border-radius: 50%; transform: translate(-50%, -50%);";
for (let date of dates) {
let e = em.cloneNode(false);
e.style.left = 100 * (date - st) / (et - st) + "%";
e.title = date.toUTCString().substr(0, 16);
g.appendChild(e);
}
}(2021));