Harrington Web

Javascript send text function

Thursday, September 29, 2016
Simple send text function that you could use for front end tests within a browser. Replacing the value is quite easy with standard Javascript, however the DOM does not realize that the value has changed. For instance lets say you had an input field that is required to be filled in. If you just change the value by its self it will never remove the required message. To complete this we fire off a change event.
function sendText(id, val) {
  //find the element
  var el = document.getElementById(id);

  //replace the value of the element with val
  el.value = val;

  //create an event to let the DOM know something changed.
  var event = new Event('change');

  //fire off the event
  el.dispatchEvent(event);
}

Display Guitar Chords on webpage

Wednesday, September 14, 2016
Sometimes its nice to have a handy tool for displaying different chords on a web page. For instance lets say that you want to show off some lyrics with chords to teach someone a song. I created ChordTab to have a simple way to display those chords.

Code Sample

<style>
svg {
    width: 100px;
}
</style>

<c-tab chord="g" instrument="guitar">
<script src="https://gitcdn.xyz/repo/blh0021/chordTab/master/src/tab.min.js"></script>

Sample Chord


Other Instruments

In addition to guitar, you can also change the instrument attribute to mandolin, ukulele, or banjo. Currently not every chord has been created data wise but work is being done all the time.