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":"Belmont Trusdale","id":0,"src":"bel","Movelist":[
{"AName":"Devil's Sidekick","inputs":[{"img":"4"},{"img":"+"},{"img":"z"}],"note":"","edit":false,"literal":"4+z"},
{"AName":"Deepest Lowe","inputs":[{"img":"6"},{"img":"+"},{"img":"z"}],"note":"","edit":false,"literal":"6+z"},
{"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":"Shadow Steal","inputs":[{"img":"D"}],"note":"must catch the shard as it comes back in order to increase the total amount","edit":false},{"AName":"Sinful Pierce","inputs":[{"img":"6"},{"img":"+"},{"img":"d"}],"note":"","edit":false},{"AName":"Dark Cloud","inputs":[{"img":"2"},{"img":"+"},{"img":"D"}],"note":"Does not use a shard in (TS)","edit":false,"literal":"2+D"},{"AName":"Swift Return","inputs":[{"img":"4"},{"img":"+"},{"img":"D"}],"note":"Will recover health if you catch the shard in (TS). Only works on pinned opponent.","edit":false,"literal":"4+D"},{"AName":"(Air Only)Serious Impact","inputs":[{"img":"D"}],"note":"The more shards he has, the more damage it deals as well as different effects. Uses up to 4, 3 in (TS)","edit":false,"literal":"D"},{"AName":"Black Slice","inputs":[{"img":"2"},{"img":"1"},{"img":"4"},{"img":"+"},{"img":"b"}],"note":"More hitstun on counterhit.","edit":false},{"AName":"Heavy Black Slice","inputs":[{"img":"2"},{"img":"1"},{"img":"4"},{"img":"+"},{"img":"c"}],"note":"Overhead. Untechable on counterhit.","edit":false},{"AName":"EX Black Slice","inputs":[{"img":"2"},{"img":"1"},{"img":"4"},{"img":"+"},{"img":"d"}],"note":"Requires 25%. Additional damage on counterhit.","edit":false},{"AName":"Cruel Impact","inputs":[{"img":"6"},{"img":"2"},{"img":"3"},{"img":"+"},{"img":"B"}],"note":"More hitstun on counterhit. Will home in on opponent during (TS). Cancel out of move by inputting F,F on hit during (TS)","edit":false,"literal":"623+B"},{"AName":"Heavy Cruel Impact","inputs":[{"img":"6"},{"img":"2"},{"img":"3"},{"img":"+"},{"img":"C"}],"note":"Hits low. Untechable on counterhit. Will home in on opponent during (TS).","edit":false,"literal":"623+C"},{"AName":"EX Cruel Impact","inputs":[{"img":"6"},{"img":"2"},{"img":"3"},{"img":"+"},{"img":"D"}],"note":"Will home in on opponent during (TS).","edit":false,"literal":"623+D"},{"AName":"Twilight Synergy (TS)","inputs":[{"img":"6"},{"img":"3"},{"img":"2"},{"img":"1"},{"img":"4"},{"img":"6"},{"img":"+"},{"img":"D"}],"note":"Forward dash becomes a teleport. Cruel Impact dash becomes a teleport. Any teleport will auto-correct behind opponent. Any teleport is completely invulnerable. Gains 6 shards, 5D is unaffected by this and will instead use none.","edit":true,"literal":"632146+D"},{"AName":"(ST)Shadow Sneak","inputs":[{"img":"6"},{"img":"3"},{"img":"2"},{"img":"1"},{"img":"4"},{"img":"6"},{"img":"+"},{"img":"d"}],"note":"Continue to hold D to appear behind opponent.","edit":false},{"AName":"Perpetual Nightmare","inputs":[{"img":"2"},{"img":"3"},{"img":"6"},{"img":"2"},{"img":"3"},{"img":"6"},{"img":"+"},{"img":"d"}],"note":"Shard will not go away until Belmont is hit or is out of power.","edit":false},{"AName":"Dream of Black","inputs":[{"img":"r"},{"img":"+"},{"img":"d"}],"note":"Requires max power and opponent to have 1/4th life remaining.","edit":false}],"type":"Dash/Double Jump/Air Dash","dr":"Belmont has the ability to create shards of pure energy from his own life-force.Doing so allows him to pin the opponent as well as steal the opponents life-force to create another and send it back to himself. He starts with at least 3 each round. Any shard he throws will slightly home in to the opponent almost 100% of the time.","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})
   $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();
}
})