Try out showing the IPFS hash
This commit is contained in:
parent
f355516c1d
commit
213442ac0f
22
js/api.js
Normal file
22
js/api.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
var getApiIpfsCurrent = function(onSuccess, onError) {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', '/api/ipfs/current', true);
|
||||||
|
xhr.setRequestHeader('Accept', 'application/json');
|
||||||
|
xhr.onreadystatechange = function () {
|
||||||
|
var res = null;
|
||||||
|
if (xhr.readyState === 4) {
|
||||||
|
if (xhr.status === 204 || xhr.status === 205) {
|
||||||
|
onSuccess();
|
||||||
|
} else if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
|
try { res = JSON.parse(xhr.responseText); } catch (e) { onError(e); }
|
||||||
|
if (res) onSuccess(res);
|
||||||
|
} else {
|
||||||
|
try { res = JSON.parse(xhr.responseText); } catch (e) { onError(e); }
|
||||||
|
if (res) onError(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send(null);
|
||||||
|
};
|
||||||
|
|
10
js/app.js
Normal file
10
js/app.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
$(document).ready(function() {
|
||||||
|
var success = function(x) {
|
||||||
|
$("#ipfs > em").html(x);
|
||||||
|
};
|
||||||
|
var error = function(x) {
|
||||||
|
$("#ipfs").hide();
|
||||||
|
console.log("ipfs hash not found: " + x);
|
||||||
|
};
|
||||||
|
getApiIpfsCurrent(success, error);
|
||||||
|
});
|
2
js/jquery-3.3.1.min.js
vendored
Normal file
2
js/jquery-3.3.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -30,6 +30,10 @@
|
|||||||
<footer>
|
<footer>
|
||||||
Site proudly generated by
|
Site proudly generated by
|
||||||
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
|
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
|
||||||
|
<span id="ipfs">and found on IPFS as <em></em></ipfs>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
<script type="application/javascript" src="/js/jquery-3.3.1.min.js"></script>
|
||||||
|
<script type="application/javascript" src="/js/api.js"></script>
|
||||||
|
<script type="application/javascript" src="/js/app.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user