2020-03-08 17:13:14 +00:00
|
|
|
---
|
|
|
|
title: Infipage
|
|
|
|
description: Outdoing all other websites with <b>INFINITE PAGES!</b>
|
2020-03-15 18:28:44 +00:00
|
|
|
url: /infipage/p
|
2020-03-08 17:13:14 +00:00
|
|
|
---
|
|
|
|
<style>
|
|
|
|
#prev, #next {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
#main {
|
|
|
|
padding-top: 10vh;
|
|
|
|
font-size: 2em;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-around;
|
|
|
|
}
|
|
|
|
|
|
|
|
#main.mobile {
|
|
|
|
display: block;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pagecount {
|
|
|
|
max-width: 70vw;
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
}
|
|
|
|
|
|
|
|
#error {
|
|
|
|
padding-top: 0.5em;
|
|
|
|
color: red;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<div id="main">
|
|
|
|
<a id="prev">Previous Page</a>
|
|
|
|
<div id="pagecount"></div>
|
|
|
|
<a id="next">Next Page</a>
|
|
|
|
</div>
|
|
|
|
<div id="error"></div>
|
2021-02-24 10:31:51 +00:00
|
|
|
<script src="/assets/js/big.js"></script>
|
2020-03-08 17:13:14 +00:00
|
|
|
<script>
|
|
|
|
Big.PE = Infinity
|
|
|
|
Big.DP = 0
|
2020-03-15 18:28:44 +00:00
|
|
|
Big.RM = 0
|
2020-03-08 17:13:14 +00:00
|
|
|
|
|
|
|
// From MDN somewhere
|
|
|
|
if (!String.prototype.startsWith) {
|
|
|
|
String.prototype.startsWith = function(search, pos) {
|
|
|
|
return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-03-15 18:28:44 +00:00
|
|
|
// not quite base64 alphabet
|
|
|
|
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstvuwxyz0123456789-_~.:@"
|
|
|
|
var alphabetMapping = {}
|
|
|
|
for (var i = 0; i < alphabet.length; i++) { alphabetMapping[alphabet[i]] = i }
|
|
|
|
console.log("alphabet is", alphabet, "chars")
|
|
|
|
var base = Big(alphabet.length)
|
2020-03-08 17:13:14 +00:00
|
|
|
|
|
|
|
function encodeBignum(b) {
|
|
|
|
var out = ""
|
|
|
|
var curr = b
|
|
|
|
// Pretend it's a positive int until the end
|
|
|
|
if (b.s === -1) { curr = b.times(-1) }
|
|
|
|
var byte = 0
|
|
|
|
while (!curr.eq(0)) {
|
|
|
|
var now = curr.mod(base)
|
2020-03-15 18:28:44 +00:00
|
|
|
out += alphabet[+now]
|
2020-03-08 17:13:14 +00:00
|
|
|
curr = curr.div(base)
|
|
|
|
}
|
|
|
|
var start = b.s === -1 ? "n" : "p"
|
2020-03-15 18:28:44 +00:00
|
|
|
return start + out
|
2020-03-08 17:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function decodeBignum(str) {
|
|
|
|
// If string is not tagged with its sign, it's just a regular number
|
2020-03-15 18:28:44 +00:00
|
|
|
// backward compatibility only
|
2020-03-08 17:13:14 +00:00
|
|
|
if (!str.startsWith("n") && !str.startsWith("p")) {
|
|
|
|
return Big(str)
|
|
|
|
}
|
|
|
|
|
|
|
|
var start = str.substring(0, 1)
|
|
|
|
|
2020-03-15 18:28:44 +00:00
|
|
|
var main = str.substring(1)
|
2020-03-08 17:13:14 +00:00
|
|
|
var out = Big(0)
|
2020-03-15 18:28:44 +00:00
|
|
|
var bvals = main.split("").map(function(x) { return alphabetMapping[x] })
|
|
|
|
// Add each char's value to string, multiplied by the base to the power of its position in string
|
|
|
|
bvals.forEach(function(val, position) {
|
|
|
|
var thisByte = Big(val).times(base.pow(position))
|
2020-03-08 17:13:14 +00:00
|
|
|
out = out.plus(thisByte)
|
|
|
|
})
|
|
|
|
if (start === "n") { out = out.times(-1) }
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
var page
|
|
|
|
var pageString
|
|
|
|
var prev = document.querySelector("#prev"), next = document.querySelector("#next"), count = document.querySelector("#pagecount"), main = document.querySelector("#main"), error = document.querySelector("#error")
|
|
|
|
function loadPage() {
|
|
|
|
try {
|
2020-03-15 18:36:22 +00:00
|
|
|
var afterSlash = /infipage\/([A-Za-z0-9_~.:@-]*)/.exec(window.location.pathname)[1]
|
2020-03-08 17:13:14 +00:00
|
|
|
page = decodeBignum(afterSlash)
|
|
|
|
} catch(e) {
|
|
|
|
console.warn("Page Number Decode Failure")
|
|
|
|
console.warn(e)
|
|
|
|
error.innerText = "Page number invalid - " + e + ". Defaulting to 0."
|
|
|
|
page = Big(0)
|
|
|
|
}
|
|
|
|
pageString = page.toString()
|
|
|
|
console.log("Page", pageString)
|
|
|
|
var canonical = encodeBignum(page)
|
|
|
|
if (canonical !== afterSlash) {
|
|
|
|
console.log(canonical, afterSlash, "Mismatch!")
|
2020-03-15 18:37:33 +00:00
|
|
|
window.location.href = "/infipage/" + canonical
|
2020-03-08 17:13:14 +00:00
|
|
|
}
|
2020-03-15 18:37:33 +00:00
|
|
|
prev.href = "/infipage/" + encodeBignum(page.minus(1))
|
|
|
|
next.href = "/infipage/" + encodeBignum(page.plus(1))
|
2020-03-15 18:28:44 +00:00
|
|
|
pagecount.innerText = "Page " + pageString
|
2020-03-08 17:13:14 +00:00
|
|
|
}
|
|
|
|
loadPage()
|
|
|
|
if ("ontouchstart" in window) { main.classList.add("mobile") }
|
|
|
|
</script>
|
|
|
|
<script>
|
2020-03-15 18:28:44 +00:00
|
|
|
// interface with arbitrary points
|
2020-03-08 17:13:14 +00:00
|
|
|
window.addEventListener("load", function() {
|
|
|
|
if ("points" in window) {
|
|
|
|
console.log("running update")
|
2022-03-07 20:07:16 +00:00
|
|
|
points.then(points => points.updateMetric("greatestInfipage", function(current) {
|
2020-03-08 17:13:14 +00:00
|
|
|
console.log("updated", current, pageString)
|
|
|
|
if (!current || page.abs().gt(Big(current))) { return pageString }
|
|
|
|
else { return current }
|
2022-03-07 20:07:16 +00:00
|
|
|
}))
|
2020-03-08 17:13:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|