Skip to content

Commit 0e06b6d

Browse files
committed
board array is now on main controller instead of board and populates with route params
1 parent 3d6b88b commit 0e06b6d

16 files changed

+344
-225
lines changed

.Gruntfile.js.swo

100755100644
8 KB
Binary file not shown.

Gruntfile.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ module.exports = function (grunt) {
2121
dist: 'dist'
2222
};
2323

24+
//for connect middleware config
25+
var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
26+
2427
// Define the configuration for all the tasks
2528
grunt.initConfig({
2629

@@ -71,11 +74,16 @@ module.exports = function (grunt) {
7174
hostname: 'localhost',
7275
livereload: 35729
7376
},
77+
rules: [
78+
//this breaks everything
79+
//{from: "^/range/(.*)$", to: '/'},
80+
],
7481
livereload: {
7582
options: {
7683
open: true,
7784
middleware: function (connect) {
7885
return [
86+
rewriteRulesSnippet,
7987
connect.static('.tmp'),
8088
connect().use(
8189
'/bower_components',
@@ -91,6 +99,7 @@ module.exports = function (grunt) {
9199
port: 9001,
92100
middleware: function (connect) {
93101
return [
102+
rewriteRulesSnippet,
94103
connect.static('.tmp'),
95104
connect.static('test'),
96105
connect().use(
@@ -105,7 +114,12 @@ module.exports = function (grunt) {
105114
dist: {
106115
options: {
107116
open: true,
108-
base: '<%= yeoman.dist %>'
117+
base: '<%= yeoman.dist %>',
118+
middleware: function (connect) {
119+
return [
120+
rewriteRulesSnippet
121+
];
122+
}
109123
}
110124
}
111125
},
@@ -395,6 +409,7 @@ module.exports = function (grunt) {
395409

396410
grunt.task.run([
397411
'clean:server',
412+
'configureRewriteRules',
398413
'wiredep',
399414
'concurrent:server',
400415
'autoprefixer',

app/index.html

+9-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
<!-- build:css(.tmp) styles/main.css -->
1414
<link rel="stylesheet" href="styles/main.css">
1515
<!-- endbuild -->
16+
<base href="/">
1617
</head>
1718
<body ng-app="rangeStatApp">
1819

19-
<div ui-view></div>
20-
<a ui-sref="range({flop: 'theflop', range: 'therange'})">range</a>
20+
<div ng-controller="MainCtrl as main">
21+
<div ui-view="rangeSelector"></div>
22+
<div ui-view="rangeChart"></div>
23+
</div>
24+
25+
<a ui-sref="range({board: 'theflop', range: 'KK,QTs,88-22'})">change</a>
26+
<a ui-sref="range({board: 'theflop', range: 'therange'})">range</a>
2127
<a ui-sref="index">range</a>
2228

2329
<!-- build:js(.) scripts/oldieshim.js -->
@@ -65,6 +71,7 @@
6571
<script src="scripts/controllers/cardmatrix.js"></script>
6672
<script src="scripts/controllers/suitmatrix.js"></script>
6773
<script src="scripts/controllers/boardmatrix.js"></script>
74+
<script src="scripts/controllers/chart.js"></script>
6875
<script src="scripts/directives/preflophand.js"></script>
6976
<script src="scripts/directives/boardcard.js"></script>
7077
<script src="scripts/services/tagmatrix.js"></script>

app/scripts/app.js

+23-33
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
11
'use strict';
22

33
var rangeStatApp = angular.module('rangeStatApp', [
4-
// 'ngCookies',
54
'ngResource',
6-
// 'ngSanitize',
7-
// 'ngRoute',
85
'ui.router',
96
'underscore'
107
])
11-
//.config(['$routeProvider', function ($routeProvider) {
12-
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
13-
/*
14-
$routeProvider
15-
.when('/', {
16-
templateUrl: 'views/main.html',
17-
controller: 'MainCtrl'
18-
})
19-
.otherwise({
20-
redirectTo: '/'
21-
});
22-
*/
8+
.config(['$locationProvider', '$stateProvider', '$urlRouterProvider', function ($locationProvider, $stateProvider, $urlRouterProvider) {
9+
2310
$stateProvider
11+
.state('range', {
12+
url: "/range/:board/:range",
13+
views: {
14+
rangeSelector: {
15+
templateUrl: "views/base.html",
16+
// controller: 'MainCtrl as main'
17+
},
18+
rangeChart: {
19+
templateUrl: "views/chart.html",
20+
controller: 'ChartCtrl as chart',
21+
}
22+
}
23+
})
2424
.state('index', {
2525
url: "/",
26-
template: "<div>dis be index</div>",
27-
controller: function() {console.log('index')}
28-
})
29-
.state('range', {
30-
url: "/range/:flop/:board",
31-
templateUrl: "views/base.html",
32-
controller: 'MainCtrl as main'
26+
template: "<div>INDOX</div>"
3327
});
3428

35-
//$urlRouterProvider.when('/ex')
36-
$urlRouterProvider.otherwise('/index')
37-
/*
38-
.state('state1.list', {
39-
url: "/list",
40-
templateUrl: "partials/state1.list.html",
41-
controller: function($scope) {
42-
$scope.items = ["A", "List", "Of", "Items"];
43-
}
44-
});
45-
*/
29+
30+
31+
32+
$urlRouterProvider.otherwise('index')
33+
34+
// $locationProvider.html5Mode(true);
35+
4636
}]);

app/scripts/controllers/boardmatrix.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rangeStatApp.controller('boardMatrixCtrl', [function () {
55
var vm = this;
66
vm.ranks = "AKQJT98765432".split('');
77
vm.suits = "cdhs".split('');
8-
vm.board = [];
8+
// vm.board = [];
99

1010
vm.suitIcon = {
1111
c: 'club',

app/scripts/controllers/chart.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
'use strict';
3+
4+
rangeStatApp.controller('ChartCtrl', ['$stateParams', function ($stateParams) {
5+
console.log('inchartctrl');
6+
var vm = this;
7+
vm.load = function() {
8+
console.log('loadchart');
9+
console.log($stateParams);
10+
console.log('loadchart');
11+
}
12+
13+
14+
var data = mockRangeData();
15+
data = JSON.parse(data);
16+
console.log(data);
17+
18+
19+
20+
}]);
21+
22+
23+
function mockRangeData() {
24+
return '{"pocket_pair":{"percent":0.3076923076923077,"hands":["QQcd","QQch","QQcs","QQdc","QQdh","QQds","QQhc","QQhd","QQhs","QQsc","QQsd","QQsh","KKcd","KKch","KKcs","KKdc","KKdh","KKds","KKhc","KKhd","KKhs","KKsc","KKsd","KKsh"]},"premium_pocket":{"percent":0.3076923076923077,"hands":["QQcd","QQch","QQcs","QQdc","QQdh","QQds","QQhc","QQhd","QQhs","QQsc","QQsd","QQsh","KKcd","KKch","KKcs","KKdc","KKdh","KKds","KKhc","KKhd","KKhs","KKsc","KKsd","KKsh"]},"pair":{"percent":0.4230769230769231,"hands":["J9dd","J9hh","J9ss","JTdd","JThh","JTss","KTdd","KThh","KTss","QQcd","QQch","QQcs","QQdc","QQdh","QQds","QQhc","QQhd","QQhs","QQsc","QQsd","QQsh","KKcd","KKch","KKcs","KKdc","KKdh","KKds","KKhc","KKhd","KKhs","KKsc","KKsd","KKsh"]},"oesd":{"percent":0.2692307692307692,"hands":["J9dd","J9hh","J9ss","JTdd","JThh","JTss","KJcd","KJch","KJcs","KJdc","KJdd","KJdh","KJds","KJhc","KJhd","KJhh","KJhs","KJsc","KJsd","KJsh","KJss"]},"gutshot":{"percent":0.34615384615384615,"hands":["QQcd","QQch","QQcs","QQdc","QQdh","QQds","QQhc","QQhd","QQhs","QQsc","QQsd","QQsh","KQcd","KQch","KQcs","KQdc","KQdd","KQdh","KQds","KQhc","KQhd","KQhh","KQhs","KQsc","KQsd","KQsh","KQss"]},"pair_plus_flush_draw":{"percent":0.15384615384615385,"hands":["QQcd","QQch","QQcs","QQdc","QQhc","QQsc","KKcd","KKch","KKcs","KKdc","KKhc","KKsc"]},"flush":{"percent":0.02564102564102564,"hands":["KJcc","KQcc"]},"flush_draw":{"percent":0.3076923076923077,"hands":["KJcd","KJch","KJcs","KJdc","KJhc","KJsc","QQcd","QQch","QQcs","QQdc","QQhc","QQsc","KQcd","KQch","KQcs","KQdc","KQhc","KQsc","KKcd","KKch","KKcs","KKdc","KKhc","KKsc"]},"two_pair":{"percent":0.08974358974358974,"hands":["98dd","98hh","T8dd","T8hh","T9dd","T9hh","T9ss"]},"trips":{"percent":0.07692307692307693,"hands":["AAdh","AAds","AAhd","AAhs","AAsd","AAsh"]},"combo_draw":{"percent":0.23076923076923078,"hands":["KJcd","KJch","KJcs","KJdc","KJhc","KJsc","QQcd","QQch","QQcs","QQdc","QQhc","QQsc","KQcd","KQch","KQcs","KQdc","KQhc","KQsc"]},"premium_overs":{"percent":0.19230769230769232,"hands":["KQcd","KQch","KQcs","KQdc","KQdd","KQdh","KQds","KQhc","KQhd","KQhh","KQhs","KQsc","KQsd","KQsh","KQss"]},"mid_pair":{"percent":0.038461538461538464,"hands":["J9dd","J9hh","J9ss"]},"high_pair":{"percent":0.38461538461538464,"hands":["JTdd","JThh","JTss","KTdd","KThh","KTss","QQcd","QQch","QQcs","QQdc","QQdh","QQds","QQhc","QQhd","QQhs","QQsc","QQsd","QQsh","KKcd","KKch","KKcs","KKdc","KKdh","KKds","KKhc","KKhd","KKhs","KKsc","KKsd","KKsh"]}}';
25+
}

app/scripts/controllers/main.js

+9-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
'use strict';
22

3-
rangeStatApp.controller('MainCtrl', ['$scope', 'preflopHands', 'activeInputMode', '$stateParams', function ($scope, preflopHands, activeInputMode, $stateParams) {
4-
5-
console.log( ' main loaded' );
6-
console.log($stateParams);
7-
3+
rangeStatApp.controller('MainCtrl', ['$scope', '$rootScope', 'preflopHands', 'activeInputMode', '$state', '$stateParams', function ($scope, $rootScope, preflopHands, activeInputMode, $state, $stateParams) {
84

95
var vm = this;
106
vm.preflopHands = preflopHands;
117
vm.active = activeInputMode;
12-
13-
vm.rangeStringDummy = 'AA';
14-
vm.rangeStringModel = 'AA';
8+
vm.board=[];
159

16-
$scope.$watch(function() {return vm.rangeStringModel}, function() {
17-
console.log(vm.rangeStringModel);
18-
19-
});
10+
$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
11+
vm.rangeStringModel = toParams.range;
12+
vm.rangeStringDummy = toParams.range;
13+
vm.board = toParams.board.split(',');
14+
});
2015

21-
}])
16+
}])
2217

2318

2419
.directive('deb', function() {
@@ -29,11 +24,7 @@ console.log(vm.rangeStringModel);
2924
'ng-click="deb()">DEBUG</button>'].join('');},
3025
controller: ['$scope', function($scope) { //link works here too
3126
$scope.deb = function() {
32-
console.log($scope.main.preflopHands);
33-
console.log($scope.main.active.tag);
34-
$scope.main.preflopHands['97'].combos.cc = false;
35-
$scope.main.preflopHands['98'].combos.dc = false;
36-
$scope.main.preflopHands['99'].combos.cd = false;
27+
console.log($scope.main.board);
3728
};
3829
}]
3930
};

app/scripts/directives/boardcard.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ rangeStatApp.directive('boardCard', ['preflopHands', function(preflopHands) {
2121
s: 'spade'
2222
};
2323

24-
var on = false;
2524
$scope.toggleOn = function() {
26-
on = !on;
27-
if (on) {
25+
var on = $scope.isOn();
26+
if (!on) {
2827
$scope.board.push($scope.rank + $scope.suit);
2928
} else {
3029
var index = $scope.board.indexOf($scope.rank + $scope.suit);
@@ -33,11 +32,11 @@ rangeStatApp.directive('boardCard', ['preflopHands', function(preflopHands) {
3332
}
3433

3534
$scope.isOn = function() {
36-
return on;
35+
return $scope.board.indexOf($scope.rank + $scope.suit) > -1;
3736
}
3837

3938
$scope.validBoard = function() {
40-
return ($scope.board.length >= 5) && !on;
39+
return ($scope.board.length >= 5) && !$scope.isOn();
4140
}
4241

4342

0 commit comments

Comments
 (0)