-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
162 lines (137 loc) · 4.54 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Rubber Duckz</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<style>
.filters,
.header {
padding: 0.5em 1.5em;
max-width: 600px;
margin-bottom: 1em;
}
option {
font-size: 16px;
}
select {
padding: 0 0.25rem;
font-size: 16px;
height: 36px;
}
#images {
padding: 1em;
}
.image {
display: inline-block;
padding: 0.5rem;
}
.image img {
max-width: 200px;
display: block;
}
.details {
display: flex;
flex-direction: row;
min-width: 0;
width: 200px;
}
.details a:nth-child(1) {
flex-shrink: 0;
width: 45px;
}
.details a:nth-child(2) {
flex: 1;
text-align: right;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
</head>
<body>
<div id="app">
<div class="header">
<h1>Rubber Duckz</h1>
<p>
Names are sourced by the community and are in no way representative of what they are. Images were copied from the project onto this website for to avoid latency with IPFS and OpenSea. Always double check the link you are viewing before buying. I (Steven Lu) am in no way affiliated with the project or its team.
</p>
<a href="https://rubberduckz.com" target="_new">https://rubberduckz.com</a><br/>
<a href="https://opensea.io/collection/rubberduckz" target="_new">https://opensea.io/collection/rubberduckz</a><br/>
<p>If you are looking to contribute:</p>
<a href="https://github.com/sjlu/rubberduckz" target="_new">https://github.com/sjlu/rubberduckz</a><br/>
<a href="https://docs.google.com/spreadsheets/d/14P4HXx8q_hbZIPCut-qp1Yh5TwhZ-iDdNqWiaT8rTQU/edit?usp=sharing" target="_new">https://docs.google.com/spreadsheets/d/14P4HXx8q_hbZIPCut-qp1Yh5TwhZ-iDdNqWiaT8rTQU/edit?usp=sharing</a>
</div>
<div class="filters">
<select v-model="category">
<option disabled value="">Filter by category...</option>
<option v-for="c in categories" :value="c">{{ c }}</option>
</select>
</div>
<div id="images">
<div class="image" v-for="image in getData()">
<img :src="'images/' + image + '.jpg'" />
<div class="details">
<a :href="'https://opensea.io/assets/0xa5e25b44b01e09b7455851838c76cde68d13e29f/' + image" target="_new">{{ image }}</a>
<a v-if="sheetData[image]" :href="sheetData[image]['Source URL']" :title="sheetData[image].Name" target="_new">{{ sheetData[image].Name }}</a>
</div>
</div>
</div>
</div>
<script>
let keys = [...Array(2001).keys()]
keys.shift()
let images = keys.map(function (i) {
return i.toString().padStart(4, '0')
})
function isUrl (string) {
let url
try {
url = new URL(string)
} catch (_) {
return false
}
return url.protocol === "http:" || url.protocol === "https:"
}
const app = new Vue({
el: '#app',
data: {
images: images,
category: '',
categories: [],
sheetData: {}
},
methods: {
getData: function () {
let data = this.images
if (this.category) {
data = data.filter((image) => {
return this.sheetData[image]?.Category === this.category
})
}
return data
},
fetchSheet: async function () {
const data = await fetch('https://rubberduckz.herokuapp.com/', {
headers: {
'Content-Type': 'application/json'
}
})
.then(function (response) {
return response.json()
})
data.forEach((value) => {
const id = value.ID.padStart(4, '0')
value['Source URL'] = isUrl(value['Source URL']) ? value['Source URL'] : `https://www.google.com/search?q=${encodeURIComponent(value.Name)}`
this.sheetData[id] = value
if (value['Category'] && !this.categories.includes(value['Category'])) {
this.categories.push(value['Category'])
}
})
this.categories = this.categories.sort()
}
}
})
app.fetchSheet()
</script>
</body>
</html>