Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 291fdaf

Browse files
Single
1 parent 4deb880 commit 291fdaf

File tree

7 files changed

+74
-29
lines changed

7 files changed

+74
-29
lines changed

‎Web/SinglePageAngularJS/controller/dashboardController.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
app.controller('dashboardCtr', function($scope,$mdDialog,$rootScope) {
22

3-
//console.log("dashboard");
3+
////console.log("dashboard");
4+
// $filter('currency')(amount, symbol, fractionSize)
45

56
$scope.showAdvanced = function(presentData) {
67
//console.log(presentData);
@@ -18,16 +19,32 @@ $scope.showAdvanced = function(presentData) {
1819
$scope.cancel = function() {
1920
$mdDialog.cancel();
2021
}
22+
//var v;
23+
24+
25+
2126

2227
$rootScope.favouriteElements = [];
28+
//$rootScope.favouriteElements = $scope.locals.cart;
2329
$scope.favourite = function(favouriteData){
30+
//$rootScope.favouriteElements = v;
31+
// if(locals.length != 0){
32+
//
33+
// }
34+
2435
var index;
2536
index = $rootScope.favouriteElements.indexOf(favouriteData);
2637
if(index==-1){
2738
$rootScope.favouriteElements.push(favouriteData);
2839
}
40+
// locals:{
41+
// cart = $rootScope.favouriteElements;
42+
// }
43+
// $scope.locals.cart = cart;
44+
//v = $rootScope.favouriteElements;
2945
}
3046
});
47+
3148
app.controller('dialogCtr',function ($scope, $mdDialog, locals) {
3249
//Assigned from construction <code>locals</code> options...
3350
$scope.locals = locals.phoneData;

‎Web/SinglePageAngularJS/controller/homeController.js

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
app.controller('homeCtr', function($scope, $mdSidenav, readJsonData, $state, $mdDialog, $rootScope) {
22

3+
//$filter('currency')(amount, symbol, fractionSize)
4+
$state.go('home.dashboard');
35

6+
$scope.homePage = function(){
7+
$state.go('home.dashboard');
8+
}
9+
//$state.go('home');
410
$scope.toggleLeft = buildToggler('left');
511
function buildToggler(id) {
612
return function() {
@@ -18,9 +24,10 @@ app.controller('homeCtr', function($scope, $mdSidenav, readJsonData, $state, $md
1824
}
1925
}
2026
}
21-
2227
$scope.logout = function(){
2328
$state.go('login');
29+
30+
2431
}
2532

2633
$scope.fileData = function(){
@@ -65,9 +72,9 @@ function adding(array,id){
6572
array.push(id);
6673
}
6774
}
68-
$state.go('home.dashboard');
6975

70-
console.log($scope.quantity);
76+
77+
//console.log($scope.quantity);
7178

7279
$scope.showFavorite = function(){
7380
$state.go('home.favourite');
@@ -78,47 +85,64 @@ $scope.showFavorite = function(){
7885

7986
$scope.numbers = [1,2,3,4,5];
8087
//console.log($scope.quantity);
81-
$scope.quantity = 0;
88+
89+
90+
91+
$scope.addingQuantity = function(s,f){
92+
$scope.quantity=0;
8293
$scope.presentPrice = 0;
8394
$scope.p = [];
84-
$scope.addingQuantity = function(s,f){
85-
$scope.presentPrice = 0;
8695
//console.log($rootScope.favouriteElements);
96+
var a = $scope.p;
8797
var index;
8898
// if ($scope.p.length != 0) {
8999
// for (var i = 0; i < $scope.p.length; i++)
90100
var count = 0;
91101
for (var i = 1; i <= 5; i++) {
92-
index = $scope.p.indexOf({id:f.id,quantity:i});
102+
index = findingIndex({id:f.id,quantity:i});
93103
console.log(index);
94-
console.log({id:f.id,quantity:i});
104+
//console.log({id:f.id,quantity:i});
95105
if (index > -1) {
96-
$scope.p.splice(index,1);
97-
$scope.p.push({id:f.id,quantity:s})
106+
a.splice(index,1);
107+
a.push({id:f.id,quantity:s})
98108
count++;
99109
}
100110

101-
console.log(i);
111+
//console.log(i);
102112
}
103113
if(count==0) {
104-
$scope.p.push({id:f.id,quantity:s});
114+
a.push({id:f.id,quantity:s});
105115
}
106-
116+
$scope.p=a;
107117
//}
108118
//}
109-
console.log($scope.p);
119+
// console.log($scope.p[0].quantity);
110120
var cartFile = $rootScope.favouriteElements;
111121
//console.log(cartFile);
112-
for (var i = 0; i < cartFile.length; i++) {
113-
$scope.quantity = (s*cartFile[i].price);
122+
$scope.quantity = 0;
123+
for (var i = 0; i < $scope.p.length; i++) {
124+
for (var j = 0; j < cartFile.length; j++) {
125+
//console.log($scope.p[i].id,'id',cartFile[j].id);
126+
if ($scope.p[i].id == cartFile[j].id) {
127+
$scope.quantity = $scope.quantity + (($scope.p[i].quantity)*(cartFile[j].price));
128+
}
129+
}
114130
}
115-
116-
$scope.presentPrice = $scope.presentPrice+$scope.quantity;
117-
// console.log(f.price);
118-
// console.log($scope.quantity);
131+
$scope.presentPrice = $scope.quantity ;
132+
//console.log(f.price);
133+
//console.log($scope.quantity);
119134
//console.log($scope.presentPrice);
120-
135+
function findingIndex(o) {
136+
for (var i = 0; i < $scope.p.length; i++) {
137+
if ($scope.p[i].id == o.id && $scope.p[i].quantity == o.quantity) {
138+
return i;
139+
}
140+
}
141+
return -1;
142+
}
121143
}
144+
145+
122146
$scope.ad = function(num){
123147
//console.log(num);
124148
}
@@ -140,4 +164,4 @@ $scope.ad = function(num){
140164

141165
});
142166

143-
$state.go('home.favourite');
167+
//$state.go('home.favourite');

‎Web/SinglePageAngularJS/controller/loginController.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ app.controller('loginCtr', function($scope, $state) {
33
// console.log($scope.user);
44
// console.log($scope.pass);
55
// }
6+
67
$scope.goToHomePage = function() {
78
console.log($scope.user);
89
console.log($scope.pass);
10+
911
$state.go('home');
1012
}
1113
});

‎Web/SinglePageAngularJS/filter/filterDashboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ app.filter('filterDashboard', function() {
55
return function(item, maker, storage, operating, camera) {
66
//console.log(fav);
77
if (maker.length != 0 || storage.length != 0 || operating.length != 0 || camera.length != 0 ) {
8-
console.log(fav);
8+
//console.log(fav);
99
if (maker.length != 0) {
1010
sortedHai = adding(item, maker, 'manufacturer');
1111
} else {

‎Web/SinglePageAngularJS/filter/filterFavorites.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ app.filter('filterFavourite', function($state){
66
}
77
else {
88
$state.go('home.dashboard')
9-
109
}
11-
1210
}
1311
})

‎Web/SinglePageAngularJS/templates/dashboard.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
</md-button>
2626
</div>
2727
<!-- <img src="bower_components/material-design-icons/icons8-us-dollar-80.png" alt="" style="height:20px;width:20px;"> -->
28-
<md-card-actions layout="row" layout-align="end">
29-
<p style="font-weight:bold;">$ {{file.price}}</p>
28+
<md-card-actions layout="row" layout-align="end">
29+
<p style="font-weight:bold;"> {{file.price | currency}}</p>
3030
</md-card-actions>
3131
</md-card-actions>
3232
</md-card>

‎Web/SinglePageAngularJS/templates/toolbar.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
<md-button class="iconButton" ng-click="toggleLeft()">
88
<md-icon md-svg-icon="bower_components/material-design-icons/navigation/svg/design/ic_menu_48px.svg" class="toolbarMenuColor"></md-icon>
99
</md-button>
10+
<md-no-ink ng-click="homePage()" flex="7" id="toolbarNameColor" style="outline:none">
11+
MOBILE
12+
</md-no-ink>
13+
<div class="" flex>
1014

11-
<h2flex="" md-truncate="" id="toolbarNameColor">MOBILE</h2>
15+
</div>
1216

1317
<md-button class="iconButton" aria-label="Favorite" ng-click="showFavorite()" style="color:grey">
1418
<md-icon md-svg-icon="bower_components/material-design-icons/action/svg/design/ic_shopping_cart_48px.svg" class="favouriteIcon"></md-icon>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /