Skip to content

Commit 9f88bf8

Browse files
committed
working on improvements
1 parent c576e0c commit 9f88bf8

File tree

2 files changed

+144
-71
lines changed

2 files changed

+144
-71
lines changed

site/layouts/_default/home.html

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,35 @@ <h1 class="masthead-brand display-1">Infinite Pixels</h1>
55

66
{{ define "main" }}
77

8-
<div id="engine-content" class="ratio " style="--bs-aspect-ratio: 80%;" ></div>
8+
<div id="engine-content" class="ratio " style="--bs-aspect-ratio: 80%;"></div>
99
{{ end }}
1010

1111
{{ define "footer" }}
12-
<p>
13-
<a href="" id="min1mil">-1,000,000</a>
14-
<a href="" id="min100k">-100,000</a>
15-
<a href="" id="min10k" >-10,000</a>
16-
<a href="" id="min1k">-1,000</a>
17-
<a href="" id="min100">-100</a>
18-
<a href="" id="min10">-10</a>
19-
<a href="" id="min1">-1</a>
20-
<a href="" id="minRand">Random</a>
21-
<a href="" id="add1" >+1</a>
22-
<a href="" id="add10">+10</a>
23-
<a href="" id="add100">+100</a>
24-
<a href="" id="add1k">+1,000</a>
25-
<a href="" id="add10k">+10,000</a>
26-
<a href="" id="add100k">+100,000</a>
27-
<a href="" id="add1mil">+1,000,000</a>
28-
</p>
12+
<div class="d-flex flex-column justify-content-evenly " style="height: 200px;">
13+
<a href="" id="btnRand" class="btn btn-primary btn-sm">Random</a>
14+
15+
<div class="d-flex">
16+
<button id="btnMinus" class="btn btn-primary btn-sm px-4">-</button>
17+
<div class="input-group mx-4">
18+
<span class="input-group-text" id="adjust-label">Navigate by</span>
19+
<input type="text" id="numAdjust" class="form-control" value="1" aria-describedby="adjust-label">
20+
</div>
21+
<button id="btnPlus" class="btn btn-primary btn-sm px-4">+</button>
22+
</div>
23+
<div class="d-flex justify-content-evenly ">
24+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e1" onclick="setValue(10);">1e1</button>
25+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e2" onclick="setValue(100);">1e2</button>
26+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e3" onclick="setValue(1000);">1e3</button>
27+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e4" onclick="setValue(10000);">1e4</button>
28+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e5" onclick="setValue(100000);">1e5</button>
29+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e6" onclick="setValue(1000000);">1e6</button>
30+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e7" onclick="setValue(10000000);">1e7</button>
31+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e8" onclick="setValue(100000000);">1e8</button>
32+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e9" onclick="setValue(1000000000);">1e9</button>
33+
<button class="btn btn-dark btn-seondary btn-sm" id="btnV1e10" onclick="setValue(10000000000);">1e10</button>
34+
35+
</div>
36+
</div>
2937

3038

3139
{{ end }}

site/layouts/partials/scripts.html

Lines changed: 118 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,139 @@
1-
21
<script type="text/javascript">
3-
lime.embed ("InfiniteEngine", "engine-content", 548, 448, { parameters: {} });
2+
lime.embed("InfiniteEngine", "engine-content", 548, 448, { parameters: {} });
43
</script>
54

65

76
<script type="text/javascript">
8-
7+
8+
function lzw64_encode(s) {
9+
if (!s) return s;
10+
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
11+
var d = new Map();
12+
var s = unescape(encodeURIComponent(s)).split("");
13+
var word = s[0];
14+
var num = 256;
15+
var key;
16+
var o = [];
17+
function out(word, num) {
18+
key = word.length > 1 ? d.get(word) : word.charCodeAt(0);
19+
o.push(b64[key & 0x3f]);
20+
o.push(b64[(key >> 6) & 0x3f]);
21+
o.push(b64[(key >> 12) & 0x3f]);
22+
}
23+
for (var i = 1; i < s.length; i++) {
24+
var c = s[i];
25+
if (d.has(word + c)) {
26+
word += c;
27+
} else {
28+
d.set(word + c, num++);
29+
out(word, num);
30+
word = c;
31+
if (num == (1 << 18) - 1) {
32+
d.clear();
33+
num = 256;
34+
}
35+
}
36+
}
37+
out(word);
38+
return o.join("");
39+
}
40+
41+
function lzw64_decode(s) {
42+
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
43+
var b64d = {};
44+
for (var i = 0; i < 64; i++) {
45+
b64d[b64.charAt(i)] = i;
46+
}
47+
var d = new Map();
48+
var num = 256;
49+
var word = String.fromCharCode(b64d[s[0]] + (b64d[s[1]] << 6) + (b64d[s[2]] << 12));
50+
var prev = word;
51+
var o = [word];
52+
for (var i = 3; i < s.length; i += 3) {
53+
var key = b64d[s[i]] + (b64d[s[i + 1]] << 6) + (b64d[s[i + 2]] << 12);
54+
word = key < 256 ? String.fromCharCode(key) : d.has(key) ? d.get(key) : word + word.charAt(0);
55+
o.push(word);
56+
d.set(num++, prev + word.charAt(0));
57+
prev = word;
58+
if (num == (1 << 18) - 1) {
59+
d.clear();
60+
num = 256;
61+
}
62+
}
63+
return decodeURIComponent(escape(o.join("")));
64+
}
65+
66+
967
// get key from search params
1068
var urlParams = new URLSearchParams(window.location.search);
1169
var key = urlParams.get('key');
12-
if (key == null)
13-
{
14-
key = "0";
70+
var minKey = '';
71+
var maxKey = '';
72+
for (var i = 0; i < 128; i++) {
73+
minKey += "0";
74+
maxKey += "f";
1575
}
16-
else
17-
{
76+
if (key == null) {
77+
key = minKey;
78+
}
79+
else {
1880
key = key.replace(/[^a-f0-9]/gi, '');
81+
82+
key = key.padStart(128, '0');
1983
}
2084

21-
22-
function getRandom()
23-
{
24-
// make a random 128-digit hex number
85+
86+
function getRandom() {
87+
// make a random 128-digit hex number
2588
var r = "";
26-
for (var i = 0; i < 128; i++)
27-
{
89+
for (var i = 0; i < 128; i++) {
2890
r += Math.floor(Math.random() * 16).toString(16);
2991
}
30-
return r;
92+
return r;
3193
}
3294

95+
console.log(key);
96+
console.log(BigInt('0x' + key).toString(16));
97+
console.log(BigInt('0x' + key).toString(36));
98+
99+
console.log(lzw64_encode(BigInt('0x' + key).toString(36)));
100+
101+
function setValue(Value) {
102+
document.getElementById("numAdjust").value = Value;
103+
}
104+
105+
106+
107+
108+
document.getElementById("btnRand").setAttribute("href", "?key=" + getRandom());
109+
document.getElementById("btnMinus").onclick = function () {
110+
111+
var numAdjust = parseInt(document.getElementById("numAdjust").value);
112+
var numKey = BigInt("0x" + key);
113+
numKey -= BigInt(numAdjust);
114+
if (numKey < BigInt("0x" + minKey)) {
115+
numKey += maxKey;
116+
}
117+
key = numKey.toString(16);
118+
console.log(key);
119+
window.location.href = "?key=" + key.padStart(128, '0');
120+
}
121+
document.getElementById("btnPlus").onclick = function () {
122+
123+
var numAdjust = parseInt(document.getElementById("numAdjust").value);
124+
var numKey = BigInt("0x" + key);
125+
numKey += BigInt(numAdjust);
126+
if (numKey > BigInt("0x" + maxKey)) {
127+
numKey -= maxKey;
128+
}
129+
key = numKey.toString(16);
130+
console.log(key);
131+
window.location.href = "?key=" + key.padStart(128, '0');
132+
}
133+
134+
135+
33136

34-
var keys = [];
35-
keys.push((BigInt('0x'+key) - 1000000n).toString(16));
36-
keys.push((BigInt('0x'+key) - 100000n).toString(16));
37-
keys.push((BigInt('0x'+key) - 10000n).toString(16));
38-
keys.push((BigInt('0x'+key) - 1000n).toString(16));
39-
keys.push((BigInt('0x'+key) - 100n).toString(16));
40-
keys.push((BigInt('0x'+key) - 10n).toString(16));
41-
keys.push((BigInt('0x'+key) - 1n).toString(16));
42-
keys.push(getRandom());
43-
keys.push((BigInt('0x'+key) + 1n).toString(16));
44-
keys.push((BigInt('0x'+key) + 10n).toString(16));
45-
keys.push((BigInt('0x'+key) + 100n).toString(16));
46-
keys.push((BigInt('0x'+key) + 1000n).toString(16));
47-
keys.push((BigInt('0x'+key) + 10000n).toString(16));
48-
keys.push((BigInt('0x'+key) + 100000n).toString(16));
49-
keys.push((BigInt('0x'+key) + 1000000n).toString(16));
50-
51-
52-
console.log(keys);
53-
54-
document.getElementById("min1mil").setAttribute("href", "?key=" + keys[0]);
55-
document.getElementById("min100k").setAttribute("href", "?key=" + keys[1]);
56-
document.getElementById("min10k").setAttribute("href", "?key=" + keys[2]);
57-
document.getElementById("min1k").setAttribute("href", "?key=" + keys[3]);
58-
document.getElementById("min100").setAttribute("href", "?key=" + keys[4]);
59-
document.getElementById("min10").setAttribute("href", "?key=" + keys[5]);
60-
document.getElementById("min1").setAttribute("href", "?key=" + keys[6]);
61-
document.getElementById("minRand").setAttribute("href", "?key=" + keys[7]);
62-
document.getElementById("add1").setAttribute("href", "?key=" + keys[8]);
63-
document.getElementById("add10").setAttribute("href", "?key=" + keys[9]);
64-
document.getElementById("add100").setAttribute("href","?key=" + keys[10]);
65-
document.getElementById("add1k").setAttribute("href", "?key=" + keys[11]);
66-
document.getElementById("add10k").setAttribute("href", "?key=" + keys[12]);
67-
document.getElementById("add100k").setAttribute("href", "?key=" + keys[13]);
68-
document.getElementById("add1mil").setAttribute("href", "?key=" + keys[14]);
69-
70-
71-
72137

73138

74139
</script>

0 commit comments

Comments
 (0)