Sign My Guestbook!

Welcome to my homepage! Thanks for stopping by!  ★  Welcome to my homepage! Thanks for stopping by!  ★  Welcome to my homepage! Thanks for stopping by!
You are visitor number
counter is per-browser
Best viewed in Netscape Navigator
Made with Notepad
Under Construction
Y2K Compliant

Leave a message

Mood
0 / 500

Messages (0)

Really delete all guestbook entries? This cannot be undone.

", mood:":-)", timestamp:new Date().toISOString() }; var el = renderEntry(hostile, Date.now()); check("xss: no child in rendered entry", el.querySelectorAll("img").length === 0); check("xss: name textContent equals original string", el.querySelector(".entry-name").textContent === ""); check("xss: message textContent equals original string", el.querySelector(".entry-msg").textContent === ""); // 4. Storage parsing check("storage: valid JSON parses", parseStored(JSON.stringify({ v:1, entries:[{ id:"a", name:"n", message:"m", timestamp:"1999-01-01T00:00:00.000Z" }] })).entries.length === 1); check("storage: invalid JSON returns usable state", parseStored("{not json").entries.length === 0); check("storage: wrong shape returns usable state", parseStored(JSON.stringify({ v:1, entries:"nope" })).entries.length === 0); check("storage: null returns usable state", parseStored(null).entries.length === 0); // 5. Pagination function countPages(n){ return paginate(new Array(n), 1, PER_PAGE).totalPages; } check("pagination: 0 entries -> 1 page, 0 items", countPages(0) === 1 && paginate([], 1, PER_PAGE).items.length === 0); check("pagination: 1 entry -> 1 page, 1 item", countPages(1) === 1 && paginate(new Array(1), 1, PER_PAGE).items.length === 1); check("pagination: 10 entries -> 1 page, 10 items", countPages(10) === 1 && paginate(new Array(10), 1, PER_PAGE).items.length === 10); check("pagination: 11 entries -> 2 pages, 10+1", countPages(11) === 2 && paginate(new Array(11), 1, PER_PAGE).items.length === 10 && paginate(new Array(11), 2, PER_PAGE).items.length === 1); check("pagination: 25 entries -> 3 pages, 10+10+5", countPages(25) === 3 && paginate(new Array(25), 3, PER_PAGE).items.length === 5); // 6. Honeypot + cooldown check("honeypot: filled -> dropped", shouldDrop("http://spam.example") === true); check("honeypot: empty -> kept", shouldDrop("") === false && shouldDrop(" ") === false); check("cooldown: active -> rejected with seconds remaining", cooldownRemaining(1000000, 1000000 + 5000, COOLDOWN_MS) > 0 && cooldownRemaining(1000000, 1000000 + 5000, COOLDOWN_MS) <= 10); check("cooldown: expired -> 0", cooldownRemaining(1000000, 1000000 + 11000, COOLDOWN_MS) === 0); // 7. Hit counter (time passed in as parameter) var t0 = 1000000000000; var first = applyHit(null, t0, HIT_INTERVAL_MS); var second = applyHit({ count: first.count, last: first.last }, t0 + 10 * 60 * 1000, HIT_INTERVAL_MS); var third = applyHit({ count: second.count, last: second.last }, t0 + 31 * 60 * 1000, HIT_INTERVAL_MS); check("hits: first load counts once (1337)", first.count === 1337 && first.counted === true); check("hits: second load within 30 min does not count", second.count === first.count && second.counted === false); check("hits: load after 31 min counts again", third.count === first.count + 1 && third.counted === true); // summary box var pass = results.filter(function(r){ return r.pass; }).length; var fail = results.length - pass; var box = document.getElementById("test-summary"); box.innerHTML = ""; var title = document.createElement("div"); title.textContent = "SELF-TESTS: " + pass + "/" + results.length + " passed" + (fail ? " — " + fail + " FAILED" : ""); title.style.fontWeight = "bold"; box.appendChild(title); results.forEach(function(r){ var line = document.createElement("div"); line.textContent = (r.pass ? "✓ " : "✗ ") + r.name; line.style.color = r.pass ? "#b6ff5e" : "#ff8080"; box.appendChild(line); }); box.classList.add("show"); } /* ================= INIT ================= */ initCounter(); render(); if(cooldownRemaining(getLastPost(), Date.now(), COOLDOWN_MS) > 0){ showCooldown(); } if(/[?&]test(=|&|$)/.test(location.search)){ runGuestbookTests(); } /* expose for console */ window.runGuestbookTests = runGuestbookTests; window.gb = { validateEntry: validateEntry, cleanUrl: cleanUrl, parseStored: parseStored, paginate: paginate, shouldDrop: shouldDrop, cooldownRemaining: cooldownRemaining, applyHit: applyHit }; })();