Try out showing the IPFS hash
This commit is contained in:
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
Reference in New Issue
Block a user