Improved demo app code to better handle the IPFS storage connection based on the new EmbarkJS refactoring. The old code is stillcompatible with the refactored EmbarkJS code

This commit is contained in:
Andy Nogueira 2017-03-17 10:10:05 -04:00
parent c1f72ae10e
commit 4245d63bbb
1 changed files with 20 additions and 10 deletions

View File

@ -32,6 +32,9 @@ $(document).ready(function() {
//EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'});
$("#storage .error").hide();
EmbarkJS.Storage.setProvider('ipfs')
.then(function(){
console.log('Provider set to IPFS');
EmbarkJS.Storage.ipfsConnection.ping()
.then(function(){
$("#status-storage").addClass('status-online');
@ -45,6 +48,13 @@ $(document).ready(function() {
$("#storage-controls").hide();
}
});
})
.catch(function(err){
console.log('Failed to set IPFS as Provider:', err.message);
$("#storage .error").show();
$("#status-storage").addClass('status-offline');
$("#storage-controls").hide();
});
$("#storage button.setIpfsText").click(function() {
var value = $("#storage input.ipfsText").val();