mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-09 13:26:10 +00:00
update demo app
This commit is contained in:
parent
2690ada62d
commit
33ec36ddae
@ -11,15 +11,31 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$("#blockchain button.set").click(function() {
|
$("#blockchain button.set").click(function() {
|
||||||
var value = parseInt($("#blockchain input.text").val(), 10);
|
var value = parseInt($("#blockchain input.text").val(), 10);
|
||||||
SimpleStorage.set(value);
|
|
||||||
addToLog("#blockchain", "SimpleStorage.set(" + value + ")");
|
// If web3.js 1.0 is being used
|
||||||
|
if (EmbarkJS.isNewWeb3()) {
|
||||||
|
SimpleStorage.methods.set(value).send({from: web3.eth.defaultAccount});
|
||||||
|
addToLog("#blockchain", "SimpleStorage.methods.set(value).send({from: web3.eth.defaultAccount})");
|
||||||
|
} else {
|
||||||
|
SimpleStorage.set(value);
|
||||||
|
addToLog("#blockchain", "SimpleStorage.set(" + value + ")");
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#blockchain button.get").click(function() {
|
$("#blockchain button.get").click(function() {
|
||||||
SimpleStorage.get().then(function(value) {
|
// If web3.js 1.0 is being used
|
||||||
$("#blockchain .value").html(value.toNumber());
|
if (EmbarkJS.isNewWeb3()) {
|
||||||
});
|
SimpleStorage.methods.get().call(function(err, value) {
|
||||||
addToLog("#blockchain", "SimpleStorage.get()");
|
$("#blockchain .value").html(value);
|
||||||
|
});
|
||||||
|
addToLog("#blockchain", "SimpleStorage.methods.get(console.log)");
|
||||||
|
} else {
|
||||||
|
SimpleStorage.get().then(function(value) {
|
||||||
|
$("#blockchain .value").html(value.toNumber());
|
||||||
|
});
|
||||||
|
addToLog("#blockchain", "SimpleStorage.get()");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -32,28 +48,18 @@ $(document).ready(function() {
|
|||||||
//EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'});
|
//EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'});
|
||||||
|
|
||||||
$("#storage .error").hide();
|
$("#storage .error").hide();
|
||||||
EmbarkJS.Storage.setProvider('ipfs')
|
EmbarkJS.Storage.ipfsConnection.ping()
|
||||||
.then(function(){
|
.then(function(){
|
||||||
console.log('Provider set to IPFS');
|
$("#status-storage").addClass('status-online');
|
||||||
EmbarkJS.Storage.ipfsConnection.ping()
|
$("#storage-controls").show();
|
||||||
.then(function(){
|
|
||||||
$("#status-storage").addClass('status-online');
|
|
||||||
$("#storage-controls").show();
|
|
||||||
})
|
|
||||||
.catch(function(err) {
|
|
||||||
if(err){
|
|
||||||
console.log("IPFS Connection Error => " + err.message);
|
|
||||||
$("#storage .error").show();
|
|
||||||
$("#status-storage").addClass('status-offline');
|
|
||||||
$("#storage-controls").hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(function(err){
|
.catch(function(err) {
|
||||||
console.log('Failed to set IPFS as Provider:', err.message);
|
if(err){
|
||||||
$("#storage .error").show();
|
console.log("IPFS Connection Error => " + err.message);
|
||||||
$("#status-storage").addClass('status-offline');
|
$("#storage .error").show();
|
||||||
$("#storage-controls").hide();
|
$("#status-storage").addClass('status-offline');
|
||||||
|
$("#storage-controls").hide();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#storage button.setIpfsText").click(function() {
|
$("#storage button.setIpfsText").click(function() {
|
||||||
@ -114,20 +120,19 @@ $(document).ready(function() {
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$("#communication .error").hide();
|
$("#communication .error").hide();
|
||||||
web3.version.getWhisper(function(err, version) {
|
$("#communication .errorVersion").hide();
|
||||||
if (err) {
|
if (EmbarkJS.Messages.providerName === 'whisper') {
|
||||||
$("#communication .error").show();
|
EmbarkJS.Messages.getWhisperVersion(function(err, version) {
|
||||||
$("#communication-controls").hide();
|
if (err) {
|
||||||
$("#status-communication").addClass('status-offline');
|
$("#communication .error").show();
|
||||||
} else if (version >= 5) {
|
$("#communication-controls").hide();
|
||||||
$("#communication .errorVersion").show();
|
$("#status-communication").addClass('status-offline');
|
||||||
$("#communication-controls").hide();
|
} else {
|
||||||
$("#status-communication").addClass('status-offline');
|
EmbarkJS.Messages.setProvider('whisper');
|
||||||
} else {
|
$("#status-communication").addClass('status-online');
|
||||||
EmbarkJS.Messages.setProvider('whisper');
|
}
|
||||||
$("#status-communication").addClass('status-online');
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
$("#communication button.listenToChannel").click(function() {
|
$("#communication button.listenToChannel").click(function() {
|
||||||
var channel = $("#communication .listen input.channel").val();
|
var channel = $("#communication .listen input.channel").val();
|
||||||
|
@ -48,28 +48,18 @@ $(document).ready(function() {
|
|||||||
//EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'});
|
//EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'});
|
||||||
|
|
||||||
$("#storage .error").hide();
|
$("#storage .error").hide();
|
||||||
EmbarkJS.Storage.setProvider('ipfs')
|
EmbarkJS.Storage.ipfsConnection.ping()
|
||||||
.then(function(){
|
.then(function(){
|
||||||
console.log('Provider set to IPFS');
|
$("#status-storage").addClass('status-online');
|
||||||
EmbarkJS.Storage.ipfsConnection.ping()
|
$("#storage-controls").show();
|
||||||
.then(function(){
|
|
||||||
$("#status-storage").addClass('status-online');
|
|
||||||
$("#storage-controls").show();
|
|
||||||
})
|
|
||||||
.catch(function(err) {
|
|
||||||
if(err){
|
|
||||||
console.log("IPFS Connection Error => " + err.message);
|
|
||||||
$("#storage .error").show();
|
|
||||||
$("#status-storage").addClass('status-offline');
|
|
||||||
$("#storage-controls").hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(function(err){
|
.catch(function(err) {
|
||||||
console.log('Failed to set IPFS as Provider:', err.message);
|
if(err){
|
||||||
$("#storage .error").show();
|
console.log("IPFS Connection Error => " + err.message);
|
||||||
$("#status-storage").addClass('status-offline');
|
$("#storage .error").show();
|
||||||
$("#storage-controls").hide();
|
$("#status-storage").addClass('status-offline');
|
||||||
|
$("#storage-controls").hide();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#storage button.setIpfsText").click(function() {
|
$("#storage button.setIpfsText").click(function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user