pbs/app.js

1 line
1.9 KiB
JavaScript

var pertApp,pertController;pertApp=angular.module("pertApp",["ui.router"]),pertApp.config(function($stateProvider,$urlRouterProvider,$locationProvider){return $urlRouterProvider.otherwise("/"),$locationProvider.html5Mode({enabled:!1,requireBase:!1}),$stateProvider.state("home",{url:"/",templateUrl:"welcome.html",controller:function($scope){}}),$stateProvider.state("rawedit",{url:"/rawedit",templateUrl:"rawedit.html",controller:pertController}),$stateProvider.state("edit",{url:"/edit",templateUrl:"edit.html",controller:pertController}),$stateProvider.state("pert",{url:"/pert",templateUrl:"pert.html",controller:pertController}),$stateProvider.state("gantt",{url:"/gantt",templateUrl:"gantt.html",controller:pertController}),$stateProvider.state("activities",{url:"/activities",templateUrl:"activities.html",controller:pertController}),$stateProvider.state("resources",{url:"/resources",templateUrl:"resources.html",controller:pertController})}),pertController=function($scope){return $scope.toLocalStorage=function(data,options){var e,error,ref,sdata;if(null==options&&(options={}),null==data&&(data={activities:[],resources:[]}),null==(null!=(ref=data.activities)?ref.push:void 0))return swal("Error","invalid data format. Try resetting","error");try{return sdata=JSON.stringify(data),console.log("Saving: "+sdata),localStorage.setItem("ganttpert",sdata),options.silent||swal("Ok","Data updated","success"),$scope.pbs=new PBS(data).calculate(),$scope.$broadcast("dataChanged")}catch(error){return e=error,swal("Error",e,"error")}},$scope.fromLocalStorage=function(options){var data,e,error,jdata;options=options||{},data=localStorage.getItem(options.name||"ganttpert"),null===data&&(data='{"activities":[], "resources":[]}');try{jdata=JSON.parse(data),null===jdata&&(jdata={activities:[],resources:[]})}catch(error){return e=error,options.silent||swal("JSON Error",e,"error"),{activities:[],resources:[]}}return options.raw?jdata:$scope.pbs=new PBS(jdata).calculate()}};