var app = angular.module("whyApp", []).config([
    '$compileProvider',
    function ($compileProvider) {
        $compileProvider.aHrefSanitizationWhitelist(/^\s*(view|parent|provider|https?|ftp|mailto|file):/);
        // Angular before v1.2 uses $compileProvider.urlSanitizationWhitelist(...)

    }
]);

app.controller("whyController", function UserController($scope, $http) {
$scope.charid=0;
$scope.Characters=[{"Name":"Edward Trusdale","id":0,"src":"ed","Movelist":[{"AName":"Throw(Air ok)","inputs":[{"img":"4"},{"img":"o"},{"img":"6"},{"img":"y"},{"img":"+"},{"img":"z"},{"img":"o"},{"img":"c"}],"note":"To escape throws press x+y or b while a exclamation point is shown","edit":false,"literal":"4o6y+zoc"},{"AName":"Chopperstyle","inputs":[{"img":"6"},{"img":"+"},{"img":"D"}],"edit":false},{"AName":"Winds of  Change: Away","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"D"}],"note":"Canceling into this will reduce the starting gauge by half. If opponent near corner any juggle will wall stick.","edit":false,"literal":"236+D"},{"AName":"Winds of  Change: Vacuum","inputs":[{"img":"2"},{"img":"1"},{"img":"4"},{"img":"+"},{"img":"D"}],"note":"Canceling into this will reduce the starting gauge by half.","edit":false,"literal":"214+D"},{"AName":"Winds of  Change: Gravity","inputs":[{"img":"2"},{"img":"2"},{"img":"+"},{"img":"D"}],"note":"Canceling into this will reduce the starting gauge by half. If opponent knocked down they cannot get up until wind stops.","edit":false,"literal":"22+D"},{"AName":"Winds of  Change: Float","inputs":[{"img":"2"},{"img":"8"},{"img":"+"},{"img":"D"}],"note":"Canceling into this will reduce the starting gauge by half. If opponent juggled they cannot tech.","edit":false,"literal":"28+D"},{"AName":"Lift off (Air Ok)","inputs":[{"img":"D"}],"note":"Can be done twice.","edit":false,"literal":"D"},{"AName":"Somersault","inputs":[{"img":"8"},{"img":"+"},{"img":"D"}],"note":"Can be canceled into Lift Off.","edit":false,"literal":"8+D","FU":true},{"AName":"Air Cutter","inputs":[{"img":"2"},{"img":"+"},{"img":"D"}],"edit":false,"literal":"2+D","FU":true},{"AName":"Turbulant Entry","inputs":[{"img":"6"},{"img":"+"},{"img":"D"}],"note":"if he clings to the wall it is untechable on hit","edit":false,"literal":"6+D","FU":true},{"AName":"Turbulent Shift","inputs":[{"img":"4"},{"img":"+"},{"img":"D"}],"note":"if he clings to the wall it is untechable on hit","edit":false,"literal":"4+D","FU":true},{"AName":"Cyclone Combination","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"B"}],"edit":false},{"AName":"First Beat","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"B"}],"edit":false,"FU":true,"literal":"236+B"},{"AName":"Second Step","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"B"}],"note":"Follow up to First beat.","edit":false,"literal":"236+B","FU":true},{"AName":"Typhoon","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"D"}],"note":"Follow up to First Beat. Uses 25% meter","edit":false,"literal":"236+D","FU":true},{"AName":"Cyclone Juke","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"C"}],"edit":false},{"AName":"Knuckle Split","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"C"}],"edit":false,"literal":"236+C","FU":true},{"AName":"Knuckle Spike","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"C"}],"note":"Follow up to Knuckle Split","edit":false,"literal":"236+C","FU":true},{"AName":"Typhoon","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"D"}],"note":"Follow up to Knuckle Split. Uses 25% meter","edit":false,"literal":"236+D","FU":true},{"AName":"Galeblade","inputs":[{"img":"6"},{"img":"2"},{"img":"3"},{"img":"+"},{"img":"B"},{"img":"o"},{"img":"C"},{"img":"o"},{"img":"D"}],"note":"D version uses 25% meter. Is OTG","edit":false,"literal":"623+BoCoD"},{"AName":"Inflow Assault","inputs":[{"img":"6"},{"img":"3"},{"img":"2"},{"img":"1"},{"img":"4"},{"img":"+"},{"img":"B"},{"img":"o"},{"img":"C"},{"img":"o"},{"img":"D"}],"edit":false},{"AName":"Big Tornado","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"C"}],"note":"Inputting Winds of Change while Tornado is out will affect how this attack ends.","edit":false,"literal":"236236+C"},{"AName":"(Air)Pressure Drop","inputs":[{"img":"6"},{"img":"3"},{"img":"2"},{"img":"1"},{"img":"4"},{"img":"6"},{"img":"+"},{"img":"B"}],"edit":false},{"AName":"Endless Cyclone","inputs":[{"img":"r"},{"img":"+"},{"img":"D"}]}],"type":"Drive based movement","dr":"Edward has the ability to shift the wind in any direction he chooses, when done almost every move he has either gains new properties or has their properties changed. His dash is also affected by it. On top of that his opponent will feel the effects of this as well.","bio":"Ahahahahahha....oh you're still serious? Ok, this is an alternate universe where dumb ideas aren't greenlit anymore."}]

$scope.Character= $scope.Characters[0];
   $scope.jg = angular.toJson($scope.Characters, false);
$scope.savechar = function(E)
{

   $scope.Characters.push({ Name: E.Name, id: $scope.Characters.length, src:E.src, Movelist:[],type:E.type,bio:E.bio });
   $scope.jg = angular.toJson($scope.Characters, false);
$scope.Character= $scope.Characters[0];
}
$scope.savemove = function(M,i)
{
	var movearray =[];
	for(var a = 0;a<M.input.length;a++)
	{
		var c=M.input.charAt(a);
		movearray.push({img:c});
		}
	$scope.Characters[i].Movelist.push({AName:M.name,inputs:movearray,note:M.note,FU:M.FU})
   $scope.mg = angular.toJson($scope.Characters[i].Movelist, false);
   $scope.jg = angular.toJson($scope.Characters, false);
}
$scope.getchar = function(i)
{
$scope.charid=i;
$scope.Character= $scope.Characters[i];
$scope.E = $scope.Characters[i];
}
$scope.removemove=function(i,j)
{
	$scope.Characters[i].Movelist.splice(j, 1);
	 $scope.jg = angular.toJson($scope.Characters, false);
	}
	
	$scope.update=function(i,E)
{
	$scope.Characters[i]=E;
	 $scope.jg = angular.toJson($scope.Characters, false);
	}
    //$http.get("scripts/characters.js").success(function (response)
   // {
       // if (response.length > 0) {
function Comparative(c)
{
	var str ="abcxyzso+";
	
	for(var i =0;i<str.length;i++)
	{
	 if(c==str[i])
	    return true;	
	}
	return false;
}
		   
  $scope.updatemove = function(i,mi,str)
{
	var movearray =[];
	var j=0
	var ins ="";
	var c='';
	for(var a = 0;a<str.length;a++)
	{
			if(a+j <str.length)
		{
			while(!Comparative(str.charAt(a+j))&&isNaN(str.charAt(a+j))&& j<3)
			{
			  ins+=str.charAt(a+j);
			  j++;
			}
			if(ins.length>0){
			movearray.push({img:ins});
			a+=j-1;
			}
		 else{
		 c=str.charAt(a);
		movearray.push({img:c});
		}
	   }
		j=0;
		ins="";
     }
	 $scope.Characters[i].Movelist[mi].inputs = movearray;
	 //$scope.Characters[i].Movelist[mi].literal = str;
	 $scope.jg = angular.toJson($scope.Characters, false);
}          
      //  }
    //})
$scope.goBack =function() {
    window.history.back();
}
})