Firstly, a place to develop and host it. Codepen.io is my go to choice. Now this is almost ad-hoc and not planned out or scoped (I guess more software engineering principles will be focused later down the line).
- The first stab involved setting up an HTML front end with a minimal of styling with CSS. It consists of two input boxes and a button.
- Then I changed the text styling from something other than default.
- Then once those were working I putting them into a function.
- This function was then called on the onclick property of the button.
So this basically allows text to be entered into one input box and clicking on the button will push it to the other one.
It’s nowhere near completion but not too shabby for rabid typing in between a lecture (Java of all classes). So this will be the first iteration and more soon to follow, including:
- logic for the binary to decimal conversion.
- restricting the entry value to 1’s and 0’s, probably using regular expression.
Closing thoughts and caveats
One constant internal nag that I had was that the html elements weren’t entirely up to standards. I just essentially cobbled together items from memory and out of necessity i.e. I need a text box, just get it in and enter a non semantic, untagged text as its label.
I’d created an empty paragraph <p></p> to which I added an Id and then tried to push the value into that empty paragraph. It’s only later that I realised that I would’ve had need to affect the innerHTML property for an element like paragraph. It works fine with the input fields, as it does have a value property that can be updated with an getElementById train.