Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!window.var) var work = angular.module('work', []).
- config(function($routeProvider){
- $routeProvider.
- when('/', {controller:workCtrl, templateUrl:'/ang/work/list.html'}).
- when('/log/:memberId', {controller:logCtrl, templateUrl:'/ang/work/log.html'}).
- when('/edit/:itemId', {controller: itemEditCtrl, templateUrl:'/ang/work/edit.html'}).
- when('/add/', {controller:workNewCtrl, templateUrl:'/ang/work/add.html'}).
- when('/add-log/:memberId', {controller:logNewCtrl, templateUrl:'/ang/work/add-log.html'}).
- //when('/del/:memberId', {controller:packageDelCtrl}).
- otherwise({redirectTo:'/'});
- });
- //list member controller
- function workCtrl($scope, $http, $location){
- $http({
- method: 'POST',
- headers: 'application/x-www-form-urlencoded',
- url: "/ang/work/ajax.php",
- data: {'action':"list" }
- }).success(function (data, code) {
- $scope.list = data.list;
- $scope.status = "";
- });
- // show status while loading member
- $scope.status = "loading works direct";
- // return member count
- $scope.list_count = function(){
- if ($scope.list){
- return $scope.list.length;
- } else {
- return 0;
- }
- }
- //del
- $scope.del_item = function(id){
- $http({
- method: 'POST',
- headers: 'application/x-www-form-urlencoded',
- url: "/ang/work/ajax.php",
- data: {'action':"del", "id":id }
- }).success(function (data, code) {
- $scope.status = "deleted";
- var old_list = $scope.list;
- $scope.list = [];
- if (data.data == 'ok'){
- angular.forEach(old_list, function(item){
- if (item.id != id) $scope.list.push(item);
- });
- }
- });
- }//*/
- }
- //gamelog controller
- function logCtrl($scope, $http, $location, $routeParams){
- // show status while loading members
- $scope.status = "loading...";
- $scope.action = "update";
- $scope.result = 0;
- //$scope.paypal = 1;
- $scope.memberId = $routeParams.memberId;
- if (!$scope.memberId){
- $location.path('/');
- }
- $http({
- method: 'POST',
- headers: 'application/x-www-form-urlencoded',
- url: "/ang/work/ajax.php",
- data: {'action':"log", "id":$scope.memberId }
- }).success(function (data, code) {
- if (data.data == 'ok'){
- var log = data.items;
- $scope.log = [];
- angular.forEach(log, function(item){
- item.amount = parseFloat(item.amount);
- if (item.result == "W"){
- $scope.result += parseFloat(item.amount);
- }
- if (item.result == "L"){
- $scope.result -= parseFloat(item.amount);
- }
- $scope.log.push(item);
- });
- }
- $scope.status = "";
- });
- //del log item
- $scope.del_log_item = function(id){
- $http({
- method: 'POST',
- headers: 'application/x-www-form-urlencoded',
- url: "/ang/work/ajax.php",
- data: {'action':"del-log-item", "id":id }
- }).success(function (data, code) {
- $scope.status = "deleted";
- var old_log = $scope.log;
- $scope.log = [];
- if (data.data == 'ok'){
- angular.forEach(old_log, function(item){
- if (item.id != id) $scope.log.push(item);
- });
- }
- });
- }//*/
- // return member count
- $scope.log_count = function(){
- if ($scope.log){
- return $scope.log.length;
- } else {
- return 0;
- }
- }
- }
- //edit gamelog controller
- function itemEditCtrl($scope, $http, $location, $routeParams){
- // show status while loading members
- $scope.status = "loading...";
- $scope.action = "update";
- //$scope.paypal = 1;
- $scope.itemId = $routeParams.itemId;
- if (!$scope.itemId){
- $location.path('/');
- }
- $http({
- method: 'POST',
- headers: 'application/x-www-form-urlencoded',
- url: "/ang/work/ajax.php",
- data: {'action':"get", "id":$scope.itemId }
- }).success(function (data, code) {
- $scope.item = data.item;
- $scope.item.amount = parseInt($scope.item.amount);
- $scope.status = "";
- });
- $scope.update_item = function(){
- $http({
- method: 'POST',
- headers: 'application/x-www-form-urlencoded',
- url: "/ang/work/ajax.php",
- data: {'action':"update", 'item':$scope.item }
- }).success(function (data, code) {
- $location.path('/');
- });
- }
- }
- //new member controller
- function workNewCtrl($scope, $http, $location){
- $scope.status = "";
- $scope.action = "add";
- $scope.add_item = function(){
- $http({
- method: 'POST',
- headers: 'application/x-www-form-urlencoded',
- url: "/ang/work/ajax.php",
- data: {'action':"add", 'item':$scope.item }
- }).success(function (data, code) {
- $location.path('/');
- });
- }
- }//*/
- //new log controller
- function logNewCtrl($scope, $http, $location, $routeParams){
- $scope.status = "";
- $scope.action = "add-log";
- $scope.memberId = $routeParams.memberId;
- if (!$scope.memberId){
- $location.path('/');
- }
- $scope.add_item = function(){
- $http({
- method: 'POST',
- headers: 'application/x-www-form-urlencoded',
- url: "/ang/work/ajax.php",
- data: {'action':"add-log", 'item':$scope.item, 'id':$scope.memberId }
- }).success(function (data, code) {
- $location.path('/');
- });
- }
- }//*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement