function Drop(ev) 
{
    var targetColor = '';

    //increment the number of drags the user had
    totalDrags++;

	//if the class is a drop area that is being dropped into
	if (/.*DropAreas.*/.test(ev.target.className) === true)
	{
		//determine the color of the img being dropped
		if (/^red/.test(ev.target.id) === true)
		{
			targetColor = "red";
		}
		else if (/^green/.test(ev.target.id) === true)
		{
			targetColor = "green";
		}
		else if (/^blue/.test(ev.target.id) === true)
		{
			targetColor = "blue";
		}
		else if (/^yellow/.test(ev.target.id) === true)
		{
			targetColor = "yellow";
		}
		else if (/^purple/.test(ev.target.id) === true)
		{
			targetColor = "purple";
		}
	
		//if the two colors are the same
		if (targetColor === mostRecentDragColor)
		{
		    if (soundToggle === "False") {
		        //play the correct drop sound
		        audio = new WebAudioAPISound("../../Audio/soundEffects/airPlaneDing.mp3");
		        audio.play(audio);
		    }

			//allow the drop to happen
			var data = ev.dataTransfer.getData("content");
			ev.target.appendChild(document.getElementById(data));
			
            //increment the number of correct drags
			numCorrectDrags++;

            //don't allow the old div to be dragged
			PreventClickInEmptyDiv();

            //see if the user won the game
			CheckIfWon();
		}
		else
		{
		    //allow the drop to happen
		    if (soundToggle === "False") {
		        //play the incorrect drop sound
		        audio = new WebAudioAPISound("../../Audio/soundEffects/metalClang.mp3");
		        audio.play(audio);
		    }
		}
	}
	ev.preventDefault();
	mostRecentDragColor = null;
}
//Allows the actual drop to happen
Allows the actual drop to happen
Allows the actual drop to happen
function Drop(ev) 
{
    var targetColor = '';
    totalDrags++;
	if (/.*DropAreas.*/.test(ev.target.className) === true)
	{
		if (/^red/.test(ev.target.id) === true)
		{
			targetColor = "red";
		}
		else if (/^green/.test(ev.target.id) === true)
		{
			targetColor = "green";
		}
		else if (/^blue/.test(ev.target.id) === true)
		{
			targetColor = "blue";
		}
		else if (/^yellow/.test(ev.target.id) === true)
		{
			targetColor = "yellow";
		}
		else if (/^purple/.test(ev.target.id) === true)
		{
			targetColor = "purple";
		}
		if (targetColor === mostRecentDragColor)
		{
		    if (soundToggle === "False") {
		        audio = new WebAudioAPISound("../../Audio/soundEffects/airPlaneDing.mp3");
		        audio.play(audio);
		    }
			var data = ev.dataTransfer.getData("content");
			ev.target.appendChild(document.getElementById(data));
			numCorrectDrags++;
			PreventClickInEmptyDiv();
			CheckIfWon();
		}
		else
		{
		    if (soundToggle === "False") {
		        audio = new WebAudioAPISound("../../Audio/soundEffects/metalClang.mp3");
		        audio.play(audio);
		    }
		}
	}
	ev.preventDefault();
	mostRecentDragColor = null;
}
function Drop ( ev ) { var targetColor = '' ; totalDrags ++ ; if ( / .*DropAreas.* / . test ( ev . target . className ) === true ) { if ( / ^red / . test ( ev . target . id ) === true ) { targetColor = "red" ; } else if ( / ^green / . test ( ev . target . id ) === true ) { targetColor = "green" ; } else if ( / ^blue / . test ( ev . target . id ) === true ) { targetColor = "blue" ; } else if ( / ^yellow / . test ( ev . target . id ) === true ) { targetColor = "yellow" ; } else if ( / ^purple / . test ( ev . target . id ) === true ) { targetColor = "purple" ; } if ( targetColor === mostRecentDragColor ) { if ( soundToggle === "False" ) { audio = new WebAudioAPISound ( "../../Audio/soundEffects/airPlaneDing.mp3" ) ; audio . play ( audio ) ; } var data = ev . dataTransfer . getData ( "content" ) ; ev . target . appendChild ( document . getElementById ( data ) ) ; numCorrectDrags ++ ; PreventClickInEmptyDiv ( ) ; CheckIfWon ( ) ; } else { if ( soundToggle === "False" ) { audio = new WebAudioAPISound ( "../../Audio/soundEffects/metalClang.mp3" ) ; audio . play ( audio ) ; } } } ev . preventDefault ( ) ; mostRecentDragColor = null ; }
Allows the actual drop to happen
Allows the actual drop to happen
//increment the number of drags the user had //if the class is a drop area that is being dropped into //determine the color of the img being dropped //if the two colors are the same //play the correct drop sound //allow the drop to happen //increment the number of correct drags //don't allow the old div to be dragged //see if the user won the game //allow the drop to happen //play the incorrect drop sound