merge-requests/2/merge
Nato Boram 2019-04-10 00:37:39 -04:00
parent a43044f5bf
commit d6fc309d29
3 changed files with 29 additions and 5 deletions

View File

@ -17,8 +17,15 @@
<!-- IPFS Hash --> <!-- IPFS Hash -->
<p> <p>
IPFS Hash : IPFS Hash :
<input type="text" name="hash" id="input"> <input type="text" name="ipfs_hash" id="input_ipfs">
<button onclick="start();">Submit</button> <button onclick="start_ipfs();">Submit</button>
</p>
<!-- IPNS Hash -->
<p>
IPNS Hash :
<input type="text" name="ipns_hash" id="input_ipns">
<button onclick="start_ipns();">Submit</button>
</p> </p>
<h3 id="stats"></h3> <h3 id="stats"></h3>

View File

@ -1,4 +1,5 @@
var hashToTest = ""; var hashToTest = "";
var protocol = "";
const $results = document.querySelector('#results'); const $results = document.querySelector('#results');
function returnHtmlLink(gateway) { function returnHtmlLink(gateway) {
@ -29,6 +30,7 @@ function checkGateways(gateways) {
const total = gateways.length; const total = gateways.length;
let checked = 0; let checked = 0;
gateways.forEach((gateway) => { gateways.forEach((gateway) => {
gateway = gateway.replace('/ipfs/', protocol);
const gatewayAndHash = gateway.replace(':hash', hashToTest); const gatewayAndHash = gateway.replace(':hash', hashToTest);
// opt-out from gateway redirects done by browser extension // opt-out from gateway redirects done by browser extension
const testUrl = gatewayAndHash + '#x-ipfs-companion-no-redirect'; const testUrl = gatewayAndHash + '#x-ipfs-companion-no-redirect';
@ -48,13 +50,28 @@ function checkGateways(gateways) {
}); });
} }
function start() { function start_ipfs() {
while ($results.lastChild) { while ($results.lastChild) {
$results.removeChild($results.lastChild); $results.removeChild($results.lastChild);
} }
hashToTest = document.querySelector("#input").value; hashToTest = document.querySelector("#input_ipfs").value;
protocol = "/ipfs/";
fetch('./json/gateways.json')
.then(res => res.json())
.then(gateways => checkGateways(gateways));
}
function start_ipns() {
while ($results.lastChild) {
$results.removeChild($results.lastChild);
}
hashToTest = document.querySelector("#input_ipns").value;
protocol = "/ipns/";
fetch('./json/gateways.json') fetch('./json/gateways.json')
.then(res => res.json()) .then(res => res.json())

View File

@ -1 +1 @@
QmRvQrZ5Vb3Hpqg7iQBrawmbdnyi6cpgQUVXMu1DHq8yAk QmYSBFMAo7NFcapLoW4UTAnnPnwBGNB944HrENgrXbkg5k