This repository was archived by the owner on Feb 21, 2018. It is now read-only.
forked from ubergesundheit/tshirt_bestellung
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShirtCtrl.js
121 lines (106 loc) · 2.78 KB
/
ShirtCtrl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
angular.module('shirtApp', ['ngStorage', 'xeditable']).controller('ShirtCtrl',function($scope,$localStorage) {
$scope.$storage = $localStorage.$default({
shirts: []
});
$scope.studies = [
"GEO",
"GI",
"LÖK"
];
$scope.gender = [
"Herren",
"Damen"
];
$scope.sizes = [
"XXL",
"XL",
"L",
"M",
"S"
];
$scope.colors = [
"Black",
"White",
"Natural",
"Navy",
"RiverBlue",
"Chocolate",
"Red",
"CityGreen"
];
$scope.prints = [
"Weiß",
"NeonGrün",
"Rot",
"NeonPink",
"Blau",
"Hellblau",
"NeonGelb",
"Gelb",
"Beige",
"Schwarz",
"Kackbraun",
"Orange",
"NeonOrange",
"Lila",
"Türkis",
"Grün"
];
$scope.master = {
shirtName: '',
shirtEmail: '',
shirtAnzahl: 1,
shirtStudiengang: '',
shirtGeschlecht: '',
shirtGroesse: '',
shirtFarbe: '',
shirtAufdruck: ''
};
$scope.deleteShirts = function() {
if (window.confirm("Wirklich alle Shirts löschen?")) {
delete $localStorage.shirts;
}
};
$scope.deleteShirt = function(shirt) {
if (window.confirm("Wirklich dieses Shirt löschen?")) {
if ($scope.$storage.shirts.indexOf(shirt) != -1) {
$scope.$storage.shirts.splice($scope.$storage.shirts.indexOf(shirt), 1);
}
}
};
$scope.femaleSelected = function() {
return ($scope.shirt.shirtGeschlecht === 'Damen' ? true : false);
};
$scope.bigN = function(what) {
return (what.indexOf("Neon") != -1 ? "N" : "");
};
$scope.addShirt = function() {
$scope.$storage.shirts.push({
name: $scope.shirt.shirtName,
email: $scope.shirt.shirtEmail,
anzahl: $scope.shirt.shirtAnzahl,
studiengang: $scope.shirt.shirtStudiengang,
geschlecht: $scope.shirt.shirtGeschlecht,
groesse: $scope.shirt.shirtGroesse,
farbe: $scope.shirt.shirtFarbe,
aufdruck: $scope.shirt.shirtAufdruck
});
$scope.reset();
};
$scope.reset = function() {
$scope.shirt = angular.copy($scope.master);
};
$scope.isUnchanged = function(shirt) {
return angular.equals(shirt, $scope.master);
};
$scope.download = function() {
var jsonexport = [];
angular.copy($scope.$storage.shirts, jsonexport);
var csv = json2csv(jsonexport.sort(function(a,b) { return (a.studiengang > b.studiengang ? 1 : -1) }));
window.open("data:text/csv;charset=utf-8," + escape(csv), 'shirts.csv');
};
$scope.reset();
});
window.onbeforeunload = function() {
//return false;
};