diff --git a/web/index.html b/web/index.html index 729b001..74caa6e 100644 --- a/web/index.html +++ b/web/index.html @@ -42,6 +42,8 @@ + +
diff --git a/web/js/demo-js-interop.js b/web/js/demo-js-interop.js index 921c3bd..1042d13 100644 --- a/web/js/demo-js-interop.js +++ b/web/js/demo-js-interop.js @@ -11,6 +11,21 @@ btn.addEventListener('click', function() { appState.onTokenReceived('token123'); }) + + let colorChangeBtnRed = document.getElementById('colorChangeBtnRed'); + colorChangeBtnRed.addEventListener('click', function() { + var hexColor = '#FF0000'.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i + , (m, r, g, b) => '#ff' + r + r + g + g + b + b).substring(1); + var numColor = parseInt(hexColor, 16); + appState.changeColor(numColor) + }) + let colorChangeBtnBlue = document.getElementById('colorChangeBtnBlue'); + colorChangeBtnBlue.addEventListener('click', function() { + var hexColor = '#0000FF'.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i + , (m, r, g, b) => '#ff' + r + r + g + g + b + b).substring(1); + var numColor = parseInt(hexColor, 16); + appState.changeColor(numColor) + }) } }()); \ No newline at end of file