mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-22 17:50:07 +01:00
IT IS ALIVE
This commit is contained in:
parent
b1c86a0cf8
commit
a8f9f6c913
@ -9,7 +9,7 @@ jQuery(function($) {
|
||||
Newsletter.init()
|
||||
})
|
||||
|
||||
//=include bigchaindb-driver/dist/browser/bundle.window.min.js
|
||||
//=include bigchaindb-driver/dist/browser/bigchaindb-driver.window.min.js
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function domload(event){
|
||||
window.removeEventListener('DOMContentLoaded', domload, false)
|
||||
@ -21,16 +21,28 @@ window.addEventListener('DOMContentLoaded', function domload(event){
|
||||
|
||||
const form = document.getElementById('form-transaction')
|
||||
const postButton = document.getElementById('post')
|
||||
const messageInput = document.getElementById('message')
|
||||
|
||||
// quick form validation
|
||||
postButton.classList.add('disabled')
|
||||
|
||||
messageInput.addEventListener('input', function() {
|
||||
if (messageInput.value === '') {
|
||||
postButton.classList.add('disabled')
|
||||
} else {
|
||||
postButton.classList.remove('disabled')
|
||||
}
|
||||
})
|
||||
|
||||
postButton.addEventListener('click', function(e) {
|
||||
e.preventDefault()
|
||||
|
||||
const message = document.getElementById('message').value
|
||||
const message = messageInput.value
|
||||
|
||||
const alice = new driver.Ed25519Keypair()
|
||||
const tx = driver.Transaction.makeCreateTransaction(
|
||||
{ assetMessage: message },
|
||||
{ metaDataMessage: 'hello' },
|
||||
{ metaDataMessage: message },
|
||||
[ driver.Transaction.makeOutput(
|
||||
driver.Transaction.makeEd25519Condition(alice.publicKey))
|
||||
],
|
||||
@ -44,23 +56,27 @@ window.addEventListener('DOMContentLoaded', function domload(event){
|
||||
})
|
||||
|
||||
const waiting = document.getElementsByClassName('waiting')[0]
|
||||
const response = document.getElementsByClassName('response')[0]
|
||||
const responseArea = document.getElementsByClassName('response')[0]
|
||||
const output = document.getElementsByClassName('output')[0]
|
||||
const messageSuccess = document.getElementsByClassName('message--success')[0]
|
||||
const messageFail = document.getElementsByClassName('message--fail')[0]
|
||||
|
||||
conn.postTransaction(txSigned)
|
||||
.then(() => {
|
||||
.then((response) => {
|
||||
waiting.classList.add('hide')
|
||||
response.classList.remove('hide')
|
||||
responseArea.classList.remove('hide')
|
||||
messageSuccess.classList.remove('hide')
|
||||
|
||||
const outputContent = conn.getStatus(txSigned.id)
|
||||
console.log(response)
|
||||
|
||||
const outputContent = JSON.stringify(response, null, 4) // indented with 4 spaces
|
||||
output.textContent = outputContent
|
||||
|
||||
}, reason => { // Error!
|
||||
console.log(reason)
|
||||
|
||||
waiting.classList.add('hide')
|
||||
response.classList.remove('hide')
|
||||
responseArea.classList.remove('hide')
|
||||
messageFail.classList.remove('hide')
|
||||
|
||||
const outputContent = reason.status + ' ' + reason.statusText
|
||||
|
Loading…
Reference in New Issue
Block a user