Backend for songs.zachdecook.com
* Easy Transp buttons: Fix JS
| -rw-r--r-- | jsonly.js | 13 | ||||
| -rw-r--r-- | page.js | 7 | ||||
| -rw-r--r-- | page.php | 6 |
3 files changed, 13 insertions, 13 deletions
@@ -29,10 +29,13 @@ function do_transpose() console.log($(this)); var oldKey = $(this).attr('data-key'); var newKey = transpadd(oldKey, transp - lastTransp); - $(this).removeClass('btn-'+oldKey); - $(this).addClass('btn-'+newKey); - $(this).attr('data-key', newKey); - $(this).text( $(this).attr('data-words') + newKey ); + if ( typeof newKey !== 'undefined' ) + { + $(this).removeClass('btn-'+oldKey); + $(this).addClass('btn-'+newKey); + $(this).attr('data-key', newKey); + $(this).text( $(this).attr('data-words') + newKey ); + } var tt = parseInt($(this).attr('href').match(/transp=(.+)/)[1]); tt = ( transp - lastTransp + 24 + tt)%12; var newhref = $(this).attr('href').match(/(.*?&transp=).+/)[1] + tt; @@ -107,4 +110,4 @@ function getChordFrets(chord) });*/ $("#messages").prepend("Couldn't find a chord for '"+ chord +"'"); } -}
\ No newline at end of file +} @@ -104,8 +104,9 @@ function transpadd( fromkey, integer ) chords["Eb"] = chords["D#"]; chords["Gb"] = chords["F#"]; chords["Ab"] = chords["G#"]; - chords["Bb"] = chords["A#"]; + chords["Bb"] = chords["A#"]; var ochords = [ "C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B" ]; - return ochords[(parseInt(chords[fromkey]) + integer + 24)%12]; -}
\ No newline at end of file + var val = ochords[(parseInt(chords[fromkey]) + integer + 24)%12]; + return val; +} @@ -157,7 +157,6 @@ function renderEasyTransp( $transp, $num, $songKeys = array() ) //up two semitones $classT = 'btn col-xs-12'; $nsongKey = 'Z'; - $data = ''; $words = "Transposed up 2 semitones"; if (isset ( $songKeys[0] ) ) { @@ -167,11 +166,8 @@ function renderEasyTransp( $transp, $num, $songKeys = array() ) $presentKey = transpadd( $origKey, $transp ); $s .= getKeyButton( "Transpose down to", $transp - 2, $pastKey, $num, $classT ); $s .= getKeyButton( "Current Key: ", $transp, $presentKey, $num, $classT ); - $data = "data-key='$presentKey' data-words='Current Key: '"; - $nsongKey = transpadd( $presentKey, 2) ?: 'Z'; $words = "Transpose up to "; - $data = "data-key='$nsongKey' data-words='$words'"; } $s .= getKeyButton( $words, $transp + 2, $nsongKey, $num, $classT ); @@ -182,7 +178,7 @@ function getKeyButton( $text, $value, $key, $num, $classT ) { $zkey = $key ?: 'Z'; $key = ($key == 'Z') ? '' : $key; - return "<a href='?song=$num&transp=$value' class='$classT btn-$zkey' $data>" + return "<a href='?song=$num&transp=$value' class='$classT btn-$zkey' data-key='$key' data-words='$text '>" . "$text $key</a>"; } |