Guest User

Untitled

a guest
Dec 13th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. function createContractElement(contractFunc, contractName, container) {
  2. switch (typeof contractFunc[1]) {
  3. case 'function':
  4. return createContractFunction(contractFunc, container)
  5. default:
  6. return createContractPropType(contractFunc, 'P')
  7. }
  8. }
  9.  
  10. function createContractFunction(contractFunc, container) {
  11. const btn = document.createElement('BUTTON')
  12. btn.innerText = contractFunc[0]
  13. btn.className = 'mui-btn mui-btn--primary mui-col-md-2'
  14. btn.addEventListener('click', () => {
  15. const div = document.createElement('DIV')
  16. div.className = 'mui-col-md-3'
  17. div.innerHTML = `
  18. <strong>Return Value:</strong> "${contractFunc[1]()}"
  19. `
  20.  
  21. container.appendChild(div)
  22. })
  23.  
  24. return btn
  25. }
  26.  
  27. function createContractPropType(contractProp, element) {
  28. const propName = contractProp[0]
  29. const hashesNames = {
  30. 'hash': 'hash',
  31. 'blockHash': 'blockHash',
  32. 'input': 'input',
  33. 'from': 'from',
  34. }
  35.  
  36. if (hashesNames[propName]) {
  37. return renderPropType(propName, contractProp[1], 'LI', '')
  38. } else {
  39. return renderPropType(propName, contractProp[1], 'P', 'mui-col-md-2 mui-panel')
  40. }
  41. }
Add Comment
Please, Sign In to add comment