about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@gmail.com>2018-12-27 00:19:29 -0500
committerZach DeCook <zachdecook@gmail.com>2018-12-27 00:19:29 -0500
commit793f9970376e99e2330d7285734a8966655e55aa (patch)
tree1165218b72a8663ca6caf10fac588c22fbc2611f
parentb34e3db69dd6d5e54a79e7720ef3916ab3ffedfe (diff)
downloadprosongsa-793f9970376e99e2330d7285734a8966655e55aa.tar.gz
- Laravel: add Chordarea and remove some moved code
-rwxr-xr-xindex.php7
-rw-r--r--laravel/resources/views/song.blade.php29
-rw-r--r--page.php130
3 files changed, 17 insertions, 149 deletions
diff --git a/index.php b/index.php
index 72b4bbf..266f0da 100755
--- a/index.php
+++ b/index.php
@@ -141,12 +141,7 @@ crossorigin="anonymous"></script>
 <?php
 if(isset($_GET['song']) && $_GET['song'])
 echo '
-<script type="text/javascript" src="index.js"></script>
-<script type="text/javascript" src="chordsdata/chords.js"></script>
-<script type="text/javascript" src="chordsdata/ukulelechords.js"></script>
-<script type="text/javascript" src="page.js"></script>
-<script type="text/javascript" src="jsonly.js"></script>
-<script type="text/javascript" src="ccharter/scripts/ccharter.js"></script>
+<script src="https://api.reftagger.com/v2/RefTagger.js"></script>
 ';
 ?>
 <script>
diff --git a/laravel/resources/views/song.blade.php b/laravel/resources/views/song.blade.php
index 0b66195..8a5e0f8 100644
--- a/laravel/resources/views/song.blade.php
+++ b/laravel/resources/views/song.blade.php
@@ -5,7 +5,6 @@
 
 <div class='container'>
     <h2>{{$song['title']}}</h2>
-
     <form>
     <select name="transp" id="transp"
         value = "<?php echo $transp;?>"
@@ -28,6 +27,10 @@
     <pre>
     {!! $song['escapedText'] !!}
     </pre>
+    <div id="chordarea">
+        <canvas id='guitarregion' width="100" height="100" onclick="cycle(guitarObj);"></canvas>
+        <canvas id='ukuleleregion' width="100" height="100" onclick="cycle(ukeObj);"></canvas>
+    </div>
 </div>
 
 <script src='/js/chordsdata/chords.js'></script>
@@ -38,18 +41,18 @@
 <script src='/js/ccharter/ccharter.js'></script>
 <!--<script src="https://api.reftagger.com/v2/RefTagger.js"></script>
 <script>
-	var refTagger = {
-		settings: {
-			bibleVersion: "NET",
-			socialSharing:[],
-			noSearchClassNames:["tabs"],
-		}
-	};
-	(function(d, t) {
-		var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
-		g.src = "//api.reftagger.com/v2/RefTagger.js";
-		s.parentNode.insertBefore(g, s);
-	}(document, "script"));
+    var refTagger = {
+        settings: {
+            bibleVersion: "NET",
+            socialSharing:[],
+            noSearchClassNames:["tabs"],
+        }
+    };
+    (function(d, t) {
+        var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
+        g.src = "//api.reftagger.com/v2/RefTagger.js";
+        s.parentNode.insertBefore(g, s);
+    }(document, "script"));
 </script>-->
 
 @endsection
diff --git a/page.php b/page.php
index 98fb3cf..835e1cb 100644
--- a/page.php
+++ b/page.php
@@ -308,32 +308,6 @@ function renderSS( $suggestedSong = array(), $songKeys, $transp )
 	return implode($ss) . implode($bs);
 }
 
-/**
- * @brief Determine whether or not this line contains chords.
- */
-function chordline($line)
-{
-	$chords = 
-		array( "C","C#","D","D#","E","F","F#","G","G#","A#","B",//"A",
-		"Db", "Eb", "Gb", "Bb",//"Ab",
-		"Cm", "Dm", "Fm", "Gm", "Bm",  //"Em", "Am",
-		);
-	$ambiguous = array( "Ab", "Em", "Am", "A" );
-	$line = str_replace(array('/','7', "\n", '2', '4'), ' ', $line);
-	$tokens = array_filter(explode(' ', $line));
-
-	$badtokens = 0;
-	$ambtokens = 0;
-	$goodtokens = 0;
-	foreach ($tokens as $token) {
-		if( in_array( substr($token, 0,2), $chords ) ) $goodtokens++;
-		else if ( in_array( substr( $token, 0,2), $ambiguous) ) $ambtokens++;
-		else if( $badtokens > 10 ) return FALSE;
-		else $badtokens++;
-	}
-	return ($goodtokens *2)+ $ambtokens >= $badtokens;
-}
-
 function normalizechords($line, $space=TRUE)
 {
 	// Get rid of flats
@@ -358,97 +332,6 @@ function normalizechords($line, $space=TRUE)
 	return $line;
 }
 
-function z_transpose2( $line, $transp )
-{
-	$newchords = z_transparray( $transp );
-	$newline = '';
-	$space = 0; ///@< Spaces that need to be added or removed.
-	$inCurly = 0;
-	for($i = 0; $i < strlen($line); $i++)
-	{
-		$char = $line[$i];
-		$nchar = isset($line[$i+1]) ? $line[$i+1] : '';
-		$upchar = strtoupper($line[$i]);
-		$cval = ord($upchar);
-		if ( $char == '}' && $inCurly ){ $inCurly = 0;}
-		if ( $char == '{' || $inCurly ){ $inCurly = 1; $newline .= $char; continue;}
-		// A-G
-		if( $cval <= 71 && $cval >=65 )
-		{
-			// Exception for Cmaj7
-			if( $upchar == 'A' && $nchar == 'j' )
-			{
-				$newline .= $char;
-			}
-			else if( $nchar == 'b' || $nchar =='#')
-			{
-				$i++; //We have read an extra character now.
-				$newchord = $newchords[$upchar . $nchar];
-				if( strlen($newchord) == 1 )
-				{
-					// Need to insert an extra space.
-					$space += 1;
-				}
-				$newline .= $newchord;
-			}
-			else
-			{
-				$newchord = $newchords[$upchar];
-				if( strlen($newchord) == 2 )
-				{
-					// Need to remove an extra space.
-					$space -= 1;
-				}
-				$newline .= $newchord;
-			}
-		}
-		else if ( $char == ' ' )
-		{
-			if( $space >= 0)
-			{
-				for ($j = 0; $j <= $space; $j++)
-				{
-					$newline .= ' ';
-				}
-				$space = 0;
-			}
-			else
-			{
-				// Only balance negative spaces if one will be left remaining
-				if( $nchar == ' ' )
-				{
-					$i++;
-					$space += 1;
-				}
-				$newline .= ' ';
-			}
-		}
-		else
-		{
-			$newline .= $char;
-		}
-	}
-	return $newline;
-}
-
-function z_transparray( $transp )
-{
-	$chords = 
-		array( "C","C#","D","D#","E","F","F#","G","G#","A","Bb","B" );
-	$newchords = array();
-	// Create array to map old chords to new ones
-	for ($i=0; $i < 12; $i++)
-	{ 
-		$newchords[$chords[$i]] = $chords[($i+$transp+12)%12];
-	}
-	$newchords["Db"] = $newchords["C#"];
-	$newchords["Eb"] = $newchords["D#"];
-	$newchords["Gb"] = $newchords["F#"];
-	$newchords["Ab"] = $newchords["G#"];
-	$newchords["A#"] = $newchords["Bb"];
-	return $newchords;
-}
-
 function difftransp( $fromkey, $tokey )
 {
 	$chords = array_flip(array( "C","C#","D","D#","E","F","F#","G","G#","A","A#","B" ));
@@ -461,16 +344,3 @@ function difftransp( $fromkey, $tokey )
 	$tokey = trim($tokey, 'm');
 	return $chords[$fromkey] - $chords[$tokey];
 }
-
-function transpadd( $fromkey, $integer )
-{
-	$chords = array_flip(array( "C","C#","D","D#","E","F","F#","G","G#","A","A#","B" ));
-	$chords["Db"] = $chords["C#"];
-	$chords["Eb"] = $chords["D#"];
-	$chords["Gb"] = $chords["F#"];
-	$chords["Ab"] = $chords["G#"];
-	$chords["Bb"] = $chords["A#"];
-	$ochords = array( "C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B" );
-	$fromkey = trim($fromkey, 'm');
-	return $ochords[($chords[$fromkey] + $integer + 24)%12];
-}