joejohnmurphy / switchcalc

switch access calculator for the web
2 stars 1 forks source link

Variables/functions to eliminate repetition with playing each audio file #5

Open joejohnmurphy opened 5 years ago

joejohnmurphy commented 5 years ago

For example, each button currently has code like this in the html file: <div class='btn f seafood' tabindex='1'>seafood</div> <audio id='seafood' controls style='display:none'><source src='sounds/seafood.mp3' type='audio/mpeg'> Your browser does not support the audio element.</audio>

And this in the talker.js file: if ($(':focus').hasClass('seafood')) {document.getElementById('seafood').play()}

Is there a way to streamline this so the repetitive code is eliminated and there's just a list of words referenced?

Drizej commented 5 years ago

Hi Joe, I added a fix for this on the calculator and talker pages to the develop branch. I am using a "data-attribute" to identify the id of the sound element to be played. You can see how I am handling the backspace press event in calc.js and talker.js. I havent added the data-sound attribute to all the html pages yet, so I am keeping some of the old code in talker.js.

Let me know if this causes any issues to either the talker or calculator!

joejohnmurphy commented 5 years ago

Thank you so much, Andrzej! I hope to test everything out this weekend. data-attributes are new to me and it looks really promising!

joejohnmurphy commented 5 years ago

This appears to be working perfectly! I think the dev-soundlinks branch is working really well. This has everything but the re-reading after pressing Enter, right? As noted on that issue, I'm wondering now if it is really needed given the differences in the content between the button labels and mp3s. What do you think?

Drizej commented 5 years ago

I think you're right. Using the mp3s gives you a lot more flexibility on the speech vs. text that is read. I guess the only downside is you have to make the mp3s. I can roll-back develop to dev-soundlinks if that is our sweet spot right now.

joejohnmurphy commented 5 years ago

Yes, I think rolling back develop to dev-soundlinks sounds like the way to go and then I'll merge develop into master. Does that sound good to you?

Drizej commented 5 years ago

Sounds good to me! I rolled the dev-enter and added the rest of the sound attributes to develop. It should be ready to merge into master.