-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpt_modfinder.html
171 lines (161 loc) · 7.9 KB
/
pt_modfinder.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
<!-- extended version of https://yhvr.me/pt/modfinder.html -->
<!-- sorting JS mostly lifted from https://www.raymondcamden.com/2018/02/08/building-table-sorting-and-pagination-in-vuejs -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Modlist Tree</title>
<link href="https://fonts.googleapis.com/css2?family=Inter&display=swap" rel="stylesheet">
<script src="https://unpkg.com/vue"></script>
<style>
* {
font-family: "Inter", sans-serif;
}
td, th {
padding-left: 5px;
max-width: 500px;
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
th {
cursor: pointer;
}
.updated {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
</style>
</head>
<body>
<h3>Prestige Tree Modfinder</h3>
<p>Note: extended version of <a href="https://yhvr.me/pt/modfinder.html">https://yhvr.me/pt/modfinder.html</a><br />
sorting JS mostly lifted from <a href="https://www.raymondcamden.com/2018/02/08/building-table-sorting-and-pagination-in-vuejs">https://www.raymondcamden.com/2018/02/08/building-table-sorting-and-pagination-in-vuejs</a></p>
<p>Because this makes HTTP requests to api.github.com and I don't want to ship this with my API key, commit messages have been removed here and replaced with the direct link to the repo's commits.</p>
<div id="app">
<p v-if="mods.length === 0">patience is a virtue</p>
<table>
<tr>
<th></th>
<th @click="sort('name')">Mod Name</th>
<th @click="sort('owner')">Mod Owner</th>
<th>Play on github.io</th>
<th>Play on raw.githack.com</th>
<th>Mod Commits</th>
<th @click="sort('updated')">Mod Last Updated</th>
</tr>
<tr v-for="mod in sortedMods">
<td><img :src="mod.owner.avatar_url" width="20" height="20"></td>
<td>{{ mod.name }}</td>
<td>{{ mod.owner.login }}</td>
<td><a :href="'https://' + mod.owner.login + '.github.io/' + mod.name + '/'" target="_blank">github.io link</a></td>
<td><a :href="'https://raw.githack.com/' + mod.owner.login + '/' + mod.name + '/' + mod.default_branch + '/index.html'" target="_blank">raw.githack.com link</a></td>
<td><a :href="mod.commits_url_trimmed">Commits link</a></td>
<td class="updated">{{ mod.updated.toISOString() }}</td>
</tr>
</table>
<br />sorted by: {{currentSort}} ({{currentSortDir}})
</div>
<script>
//"use strict";
// Init Vue app
const app = new Vue({
el:"#app",
data:{
mods:[],
currentSort:"updated",
currentSortDir:"desc"
},
created:function() {
// Helper function for date flooring
function roundMinutes(date) {
date = new Date(date);
date.setSeconds(0, 0);
return date;
}
function datesEq(a, b) {
return roundMinutes(a).toString() === roundMinutes(b).toString();
}
// Make `fetch`s to GitHub APIs
fetch("https://api.github.com/repos/Jacorb90/Prestige-Tree/forks?per_page=100")
.then(res => res.json())
.then(json => {
json.forEach(repo => {
fetch(repo.url)
.then(res => res.json())
.then(repo => {
if (!datesEq(repo.created_at, repo.updated_at)) {
repo.updated = new Date(repo.updated_at);
// repo.commit_message = '-';
repo.commits_url_trimmed = repo.commits_url
.replace('{/sha}','')
.replace('api.','')
.replace('repos/','');
console.log(repo.commits_url_trimmed);
// //console.log("Fetching: " + repo.commits_url_trimmed);
// fetch(repo.commits_url_trimmed)
// .then(res => res.json())
// .then(json => {
// repo.commit_message = json[0].commit.message;
// });
//console.log(repo);
//console.log("Commit message: " + repo.commit_message);
app.mods.push(repo);
}
})
})
});
fetch("https://api.github.com/repos/Acamaeda/The-Modding-Tree/forks?per_page=100")
.then(res => res.json())
.then(json => {
json.forEach(repo => {
fetch(repo.url)
.then(res => res.json())
.then(repo => {
if (!datesEq(repo.created_at, repo.updated_at)) {
repo.updated = new Date(repo.updated_at);
console.log(repo.commits_url.replace('{/sha}',''));
//repo.commit_message = '-';
repo.commits_url_trimmed = repo.commits_url
.replace('{/sha}','')
.replace('api.','')
.replace('repos/','');
console.log(repo.commits_url_trimmed);
//console.log("Fetching: " + repo.commits_url_trimmed);
// fetch(repo.commits_url_trimmed)
// .then(res => res.json())
// .then(json => {
// repo.commit_message = json[0].commit.message;
// });
//console.log(repo);
//console.log("Commit message: " + repo.commit_message);
app.mods.push(repo);
}
})
})
});
},
methods:{
sort:function(s) {
//if s == current sort, reverse
if(s === this.currentSort) {
this.currentSortDir = this.currentSortDir==="asc"?"desc":"asc";
}
this.currentSort = s;
}
},
computed:{
sortedMods:function() {
return this.mods.sort((a,b) => {
let modifier = 1;
if(this.currentSortDir === "desc") modifier = -1;
if(a[this.currentSort] < b[this.currentSort]) return -1 * modifier;
if(a[this.currentSort] > b[this.currentSort]) return 1 * modifier;
return 0;
});
}
}
})
</script>
</body>
</html>