-
Notifications
You must be signed in to change notification settings - Fork 18
/
mirror.html
216 lines (191 loc) · 10.3 KB
/
mirror.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
<link rel="stylesheet" href="https://nodebe4.github.io/hero/assets/css/font-awesome-color-brand.css" type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
<style>
.fa-m:before {
font-family: Arial; /* your font family here! */
font-weight: bold;
content: 'M';
}
.thumb-post img {
object-fit: cover;
object-position: top;
width: 40px;
overflow: hidden;
height: 40px;
display: inline;
}
</style>
<div id="news">
<ul id="results-container" class="searched" style="color: #2980B9;"></ul>
</div>
<div id="noscript-content" class="text-center">
<h4 class="text-center">HeroBot说</h4>
<p class="text-center">什么都不必说,我知道我明了</p>
<p class="text-center">他们说Javascript是万恶之源</p>
<p class="text-center"><b>但是</b>,真正的安全只有靠Tor, 去装个<a href="https://www.torproject.org/download/">Tor Browser</a>或<a href="https://www.privacytools.io/operating-systems/#tor_os">双虚拟机</a>吧</p>
<p class="text-center">因为<a href="https://github.com/diymysite/analytics/blob/master/pages/analytics.md">除了恶意网页插件,还有一万种方法监视你</a>.</p>
<p class="text-center">缺少javascript的世界是残缺的,就像没有英雄的世界</p>
<p class="text-center"><b>当然</b>,你可以直接阅读<a href="https://raw.githubusercontent.com/NodeBE4/hero/master/index.json">原始数据</a>或者网页代码</p>
<p class="text-center"><i>Javascript is the most beautiful language.</i></p>
<p class="text-center"><i>BITE ME</i></p>
</div>
<table id="add-hero-form" class="table table-striped table-bordered table-sm" style="width:100%;">
</table>
<div style="font-size: 12px">
<span style="color: #3498DB;"><i>"赞不会立即生效,每小时或創建新人物時更新一次"</i></span>;
<span style="color: #3498DB;"><b>收录说明</b>:<i>"必须为 GitHub/GitLab 项目,project 链接为 GitHub/GitLab 链接"</i></span>;
</div>
<hr>
<div class="row">
<div class="col-12 col-md-6">
<h4>请在此处键入你喜歡的影響力項目</h4>
<span style="color: #3498DB;width:100%; font-size:14px"><b><a href="https://github.com/Terminus2049/">小二</a>:</b>"不要问自己能否改变世界,世界从来都是这样被改变的。找到你关心的议题,参与进来;如果还没有,那就创建一个!"</span>
<p style="color: #566573;font-size: 12px;">提示:提交或投票成功或需approve批准no script弹出的警告。</p>
<form id="add-hero-form" action="https://impact-form.vercel.app/api/submit" method="post" target="_blank">
<div class="form-group">
<input name="url" type="url" placeholder="開源repo链接 https://github.com/..." style="display:table-cell; width:100%; max-width: 600px;"><br>
<textarea name="message" style="width: 100%; max-width: 600px; height: 100px;" placeholder="項目描述..."></textarea>
<div><input type="submit" value="提交"/></div>
</div>
</form>
</div>
<div class="col-12 col-md-6">
<h4>關於</h4>
<div id="about-hero">
<p><b>說明:</b>本榜來自端點星的<a href="https://github.com/Terminus2049/Awesome-Social-Impact">Awesome-Social-Impact</a>,提供原始<a href="https://nodebe4.github.io/impact/index.json">數據</a>及<a href="https://github.com/NodeBE4/impact/">代碼</a>。</p>
<p><b>參與:</b>歡迎有才華的您貢獻您的想法、代碼、或藝術設計,相關討論見<a href="https://github.com/NodeBE4/impact/issues/1">issue</a>。<i style="color: #FF445D">歡迎友站host本頁鏡像(見:<a href="https://github.com/NodeBE4/impact">方法</a>與<a href="https://impact-form.vercel.app/">示例</a>).</i></p>
<p style="color: #803030;"><b>隱私:</b>人物<i>提交</i>或<i>点赞</i><i class="fa fa-thumbs-o-up"></i>无需注册或登录,本榜无法獲知您的IP地址或浏览器指纹等隐私。</p>
<p style="font-size: 12px;"><b>開源:</b>英雄榜的API开放<a href="https://github.com/NodeBE4/impact-form">源代码</a>且实际部署經第三方API託管平台<a href="https://vercel.com">vercel</a>所<a href="https://github.com/NodeBE4/impact-form/commits/master">验证</a>.</p>
<div style="font-size:12px">License: GPL-3.0-or-later</div>
</div>
</div>
</div>
<div style="display:none">
<iframe id="iframe-vote" src="https://impact-form.vercel.app/vote"></iframe>
</div>
<script type="text/javascript" >
document.addEventListener("DOMContentLoaded", function(event){
var url = "https://nodebe4.github.io/impact/index.json";
var id = "add-hero-form";
var table = document.getElementById(id);
var noscript = document.getElementById("noscript-content");
noscript.parentNode.removeChild(noscript)
const thead_format = {
'vote': '<i style="color:#2980B9" class="fa fa-thumbs-up"></i>',
'repo': '<span><b>仓库</b></span>',
'author': '<span><b>作者</b></span>',
'desc': '<span><b>描述</b></span>',
'update': '<i class="fa fa-history" title="last commit time"></i>',
'star': '<i class="fa fa-star github" title="stars on github"></i>',
'fork': '<i class="fa fa-code-fork github" title="forks on github"></i>',
'contributors': '<i class="fa fa-users github" title="contributors on github"></i>',
}
$.getJSON(url, function(json) {
herolist = json;
var thead = document.createElement('thead');
var tbody = document.createElement('tbody');
var tfoot = document.createElement('tfoot');
table.appendChild(thead)
table.appendChild(tbody)
table.appendChild(tfoot)
var tr0 = document.createElement('tr');
thead.appendChild(tr0);
var thead_vals = Object.values(thead_format)
var thead_keys = Object.keys(thead_format)
thead_vals.map(item => {
var th = document.createElement('th')
th.innerHTML = item
tr0.appendChild(th)
});
var lis = herolist.map(item => {
let texts = item['repo'].split('/')
let origin = texts[2]
let author = texts[3]
let reponame = texts[4]
let authorlink = texts.slice(0,4).join('/')
let host = origin.split('.')[0]
let tr = document.createElement('tr');
tbody.appendChild(tr)
thead_keys.map(key => {
let td1 = document.createElement('td');
if (key == 'repo'){
if (origin=='github.com'){
td1.innerHTML += `<a class="thumb-post" href="${item['repo']}"><i class="fa fa-github github"></i></a>`
}else if (origin=='gitlab.com'){
td1.innerHTML += `<a class="thumb-post" href="${item['repo']}"><i class="fa fa-gitlab gitlab"></i></a>`
}
td1.innerHTML += `<a href="${item['repo']}"><b style="font-size: 12px;">${reponame}</b></a>`;
}else if(key=='vote'){
let val = item[key] || 0
td1.innerHTML += val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
td1.innerHTML += `<a id="vote-${item.hash}" onclick="vote_hero('${item.hash}')" style="color:#2980B9"> <i class="fa fa-thumbs-o-up"></i></a>`
td1.id = "vote-cnt-"+item.hash
}else if (key == 'author'){
td1.innerHTML += `<a href="${authorlink}" style="font-size: 12px;">${author}</a>`
}else if (key=='update'){
let imglink = `https://img.shields.io/${host}/last-commit/${author}/${reponame}?label=%20`
td1.innerHTML += `<a href="${item['repo']}"><img src="${imglink}"></img></a>`
}else if (key=='star'){
let imglink = `https://img.shields.io/${host}/stars/${author}/${reponame}?label=%20`
td1.innerHTML += `<a href="${item['repo']}/stargazers"><img src="${imglink}"></img></a>`
}else if (key=='fork'){
let imglink = `https://img.shields.io/${host}/forks/${author}/${reponame}?label=%20`
td1.innerHTML += `<a href="${item['repo']}/network/members"><img src="${imglink}"></img></a>`
}else if (key=='contributors'){
let imglink = `https://img.shields.io/${host}/contributors/${author}/${reponame}?label=%20`
td1.innerHTML += `<a href="${item['repo']}/graphs/contributors"><img src="${imglink}"></img></a>`
}else{
let val = item[key] || 0
td1.innerHTML = `<i style="font-size: 12px;">${val}</i>`
}
tr.appendChild(td1);
});
});
var tr2 = document.createElement('tr');
tfoot.appendChild(tr2);
thead_vals.map(item => {
var th = document.createElement('th')
th.setAttribute("data-field", item)
th.innerHTML = item
tr2.appendChild(th)
});
$('#add-hero-form').DataTable( {
"order": [[ 0, "desc" ]],
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.21/i18n/Chinese.json"
},
"pageLength": 50
});
console.log(table)
})
});
var iframe = document.getElementById("iframe-vote");
iframe.contentWindow.document.addEventListener("DOMContentLoaded", function(event){
var voteform = iframe.contentWindow.document.getElementById("vote-form");
voteform.addEventListener('submit', function(event){
event.preventDefault();
});
})
function vote_hero(hash){
console.log(hash)
var btn = document.getElementById("vote-"+hash)
var cell = document.getElementById("vote-cnt-"+hash)
var count = parseInt(cell.innerText) + 1
btn.parentNode.removeChild(btn)
console.log(count)
cell.innerText = count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
// var form = document.getElementById("vote-form")
var form = iframe.contentWindow.document.getElementById("vote-form");
var inputhash = iframe.contentWindow.document.getElementById("input-hash")
inputhash.value=hash
form.submit()
// sendData(form)
setTimeout(function(){ iframe.contentWindow.location.reload(); }, 3000)
return false
}
</script>