-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
231 lines (211 loc) · 4.78 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<html>
<head>
<title>punkbase</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: sans-serif;
margin: 0;
background: rgba(0,0,255,0.04);
}
nav {
text-align: center;
padding: 40px 0 20px 0;
color: black;
opacity: 0.9;
}
.sub {
font-size: 14px;
}
input[type=text] {
width: 100%;
padding: 5px;
box-sizing: border-box;
background: white;
border: 1px solid rgba(0,0,0,0.1);
}
textarea {
width: 100%;
height: 50px;
background: white;
border: 1px solid rgba(0,0,0,0.1);
padding: 5px;
box-sizing: border-box;
}
nav a {
font-family: sans-serif;
/*
letter-spacing: -3px;
*/
text-decoration: none;
font-size: 40px;
font-weight: bold;
display: inline-block;
margin: 10px;
color: black;
}
nav td:nth-child(1) {
width: 100px;
font-weight: bold;
text-align: right;
vertical-align: middle;
}
nav table {
max-width: 800px;
margin: 0 auto;
width: 90%;
}
nav td {
background: none;
color: black;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 20px 0;
}
.item {
width: 200px;
padding: 5px;
box-sizing: border-box;
}
.item img {
width: 100%;
image-rendering: pixelated;
/* to phunk or not phunk? */
transform: scale(-1,1);
}
table {
table-layout: fixed;
width: 100%;
border-spacing: 0;
}
td {
background: white;
vertical-align: top;
word-wrap:break-word;
padding: 7px;
box-sizing: border-box;
font-size: 13px;
cursor: pointer;
}
.container td:nth-child(1) {
font-weight: bold;
}
.container td {
border-bottom: 2px solid rgba(0,0,255,0.04);
}
.container tr:hover td {
background: lavender;
}
#query {
margin-top: 5px;
background: royalblue;
cursor: pointer;
padding: 10px;
max-width: 800px;
width: 90%;
box-sizing: border-box;
color: white;
border-radius: 4px;
border:none;
font-size: 20px;
font-family: sans-serif;
}
.btn {
font-family: sans-serif;
font-size: 14px;
font-style: normal;
letter-spacing: 0;
background: rgba(0,0,0,0.9);
color: white;
padding: 5px 10px;
margin: 20px 0;
border-radius: 2px;
}
.loader {
padding: 100px;
font-size: 14px;
opacity: 0.9;
font-weight: bold;
text-transform: uppercase;
}
</style>
<script src="https://pixelartexchange.github.io/artbase.js/artbase.js"></script>
</head>
<body>
<nav>
<a href="/">punkbase</a>
<div class='sub'>The entire punks universe (10 000 pixel heads)
in a single sqlite database (file)
with a "serverless" web page for queries
and all in a git repository ready to clone / fork. No rights reserved.</div>
<div>
<a class='btn' href="https://github.com/cryptopunksnotdead/punkbase">Download</a>
<a class='btn' href="https://old.reddit.com/r/DIYPunkArt/">Questions? Comments?</a>
</div>
<table>
<tr>
<td>SELECT</td>
<td><input id='select' type='text' placeholder='select columns' value='*'></td>
</tr>
<tr>
<td>FROM</td>
<td>metadata</td>
</tr>
<tr>
<td>WHERE</td>
<td><textarea id='where' placeholder='where condition'></textarea></td>
</tr>
<tr>
<td>LIMIT</td>
<td><input id='limit' type='text' placeholder='limmit' value=200></td>
</tr>
</table>
<button id='query'>Query</button>
</nav>
<div class='container'>
<div class='loader'>
<div class='loading dots'></div>
<br>
<div>Loading ...</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", async () => {
const artbase = new Artbase()
await artbase.init( { database: "punkbase.db",
imageUrl: "https://cryptopunksnotdead.github.io/pixelart.js/yeoldepunks/"
})
artbase.next()
document.querySelector("#query").addEventListener("click", () => {
artbase.next()
})
document.querySelector(".container").addEventListener("click", (e) => {
let target = (e.target.className === "row" ? e.target : (e.target.closest(".row") ? e.target.closest(".row") : null))
if (target) {
let key = target.getAttribute('data-key')
let val = target.getAttribute('data-val')
let where_cond = ''
// note: simply heuristic for now - if 0-9 (single-digit) number assume number type
if (val.match( /^[0-9]$/ )) {
// unquoted; assume number
where_cond = `${key} = ${val}`
} else {
// quoted; assume string (default)
where_cond = `${key} = '${val}'`
}
let where = document.querySelector("#where").value
if (where.trim().length > 0) {
document.querySelector("#where").value = `${where} AND\n${where_cond}`
} else {
document.querySelector("#where").value = `${where_cond}`
}
artbase.next()
}
})
})
</script>
</body>
</html>