'use strict';

angular.module('docsGeneratorApp')

  .controller('MainCtrl', function ($scope, $http) {
     $scope.currentFunction = {"name":"each","code":"_.each([1, 2, 3], alert);\n=> alerts each number in turn...\n_.each({one: 1, two: 2, three: 3}, alert);\n=> alerts each number value in turn...","signature":"_.each(list, iterator, [context])","description":"Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is bound to the context object, if one is passed. Each invocation of iterator is called with three arguments: (element, index, list). If list is a JavaScript object, iterator's arguments will be (value, key, list). Delegates to the native forEach function if it exists, and returns the original list for chaining."};
      $scope.toJSON = function(object){
         return JSON.stringify(object);
      }
      
      $scope.functionInText = '{"name": "paste your function here..."}';
     $scope.getYear = function(){
        var now = moment($scope.currentResource.date);
        return now.format("YYYY");
     }
     $scope.getTimeInCiteFormat = function(){
        var now = moment($scope.currentResource.date);
        console.log($scope.currentResource.date);
        return now.format("Do MMM. YYYY");
     }
     var currentDate = Date().toString(); 
     $scope.currentResource = {"author": "rain", title : "Awesome Resource", "date": currentDate, "url": "http://google.com" } 
      $scope.toJSON = function(object){
         return JSON.stringify(object);
      }
      $scope.resourceInText = '{"name": "load function..."}';
      $scope.reloadCurrentResource = function(){
         try{
            var parsedObject = JSON.parse(this.resourceInText);
            $scope.currentResource = parsedObject;
         } catch(e){
            console.log(e);
         };
      }
      $scope.reloadCurrentFunction = function(){
         try{
            var parsedObject = JSON.parse(this.functionInText);
            $scope.currentFunction = parsedObject;
         } catch(e){
            console.log(e);
         };
      }
      
     $scope.getYear = function(){
        var now = moment($scope.currentResource.date);
        return now.format("YYYY");
     }
     $scope.getTimeInCiteFormat = function(){
        var now = moment($scope.currentResource.date);
        console.log($scope.currentResource.date);
        return now.format("Do MMM. YYYY");
     }
     var currentDate = Date().toString(); 
     $scope.currentResource = {"author": "rain", title : "Awesome Resource", "date": currentDate, "url": "http://google.com" } 
      $scope.toJSON = function(object){
         return JSON.stringify(object);
      }
      $scope.resourceInText = '{"name": "load function..."}';
      $scope.reloadCurrentResource = function(){
         try{
            var parsedObject = JSON.parse(this.resourceInText);
            $scope.currentResource = parsedObject;
         } catch(e){
            console.log(e);
         };
      }

      $scope.urlResource = "crawl.json";
      $scope.loadFromURL = function(){
         $http.get($scope.urlResource)
            .success(function(data){
               $scope.currentResource = _.extend($scope.currentResource, data);
            });
      }
  });

@@ -1520,32 +1520,630 @@
 bject);%0A      %7D%0A
+     $scope.getYear = function()%7B%0A        var now = moment($scope.currentResource.date);%0A        return now.format(%22YYYY%22);%0A     %7D%0A     $scope.getTimeInCiteFormat = function()%7B%0A        var now = moment($scope.currentResource.date);%0A        console.log($scope.currentResource.date);%0A        return now.format(%22Do MMM. YYYY%22);%0A     %7D%0A     var currentDate = Date().toString(); %0A     $scope.currentResource = %7B%22author%22: %22rain%22, title : %22Awesome Resource%22, %22date%22: currentDate, %22url%22: %22http://google.com%22 %7D %0A      $scope.toJSON = function(object)%7B%0A         return JSON.stringify(object);%0A      %7D%0A      %0A
       $scope.res
@@ -2427,32 +2427,89 @@
      %7D;%0A      %7D%0A
+      %0A      $scope.functionInText = '%7B%22name%22: %22kaka%22%7D';%0A
       $scope.rel

fix conflict