'DivinElegy.components.simfiles',
'DivinElegy.pages.index',
'DivinElegy.pages.upload',
- 'DivinElegy.pages.simfiles'
+ 'DivinElegy.pages.simfiles',
+ 'DivinElegy.pages.packs'
]).
config(['$routeProvider', '$locationProvider', function($routeProvider) {
templateUrl: 'pages/simfiles/simfiles.html',
controller: 'SimfileController'
}).
+ when('/packs',
+ {
+ templateUrl: 'pages/packs/packs.html',
+ controller: 'PackController'
+ }).
otherwise({redirectTo: '/'});
}]).
--- /dev/null
+<input type="text" ng-model="packTitleFilterKeyword" placeholder="pack title..."/>\r
+<input type="text" ng-model="artistFilterKeyword" placeholder="artist..."/>\r
+<input type="text" ng-model="songTitleFilterKeyword" placeholder="song title..."/>\r
+<select ng-model="difficultyFilterKeyword">\r
+ <option value="Any" selected="selected">Any</option>\r
+ <option value="Novice">Novice</option>\r
+ <option value="Easy">Easy</option>\r
+ <option value="Medium">Medium</option>\r
+ <option value="Hard">Hard</option>\r
+ <option value="Expert">Expert</option>\r
+</select>\r
+<input type="text" ng-model="ratingFilterKeyword" placeholder="rating..."/>\r
+<input type="text" ng-model="stepArtistFilterKeyword" placeholder="step artist..."/>\r
+FG changes: <input type="checkbox" ng-model="fgChangesFilterKeyword">\r
+BG changes: <input type="checkbox" ng-model="bgChangesFilterKeyword">\r
+BPM changes: <input type="checkbox" ng-model="bpmChangesFilterKeyword">\r
+\r
+<ul class="simfileList">\r
+ <li class="simfileListing" ng-class="{active: isListingActive($index)}" ng-repeat="pack in packList | filter: packTitleFilter\r
+ | filter: artistFilter\r
+ | filter: songTitleFilter\r
+ | filter: stepsFilter\r
+ | filter: fgChangesFilter\r
+ | filter: bgChangesFilter\r
+ | filter: bpmChangesFilter\r
+ " ng-init="contributors=getContributors(pack.contributors)">\r
+ <a ng-click="openListing($index)">{{pack.title}}</a>\r
+ <div class="content" ng-show="isListingActive($index)">\r
+ <img ng-src="{{rockEndpoint}}{{pack.banner}}" alt="swage" />\r
+ <table>\r
+ <tr>\r
+ <th>Title:</th>\r
+ <td>{{pack.title}}</td>\r
+ </tr>\r
+ <tr>\r
+ <th>Contributors:</th>\r
+ <td>{{contributors}}</td>\r
+ </tr>\r
+ </table>\r
+ <div class="clearfix"></div>\r
+ <h1>Charts</h1>\r
+ <ul>\r
+ <li class="simfileListing" ng-repeat="simfile in pack.simfiles" ng-class="{active: isListingActive(getSimfileListingIndex(pack.title,$index))}">\r
+ <a ng-click="openListing(getSimfileListingIndex(pack.title,$index))">{{simfile.title}}</a>\r
+ <div class="content" ng-show="isListingActive(getSimfileListingIndex(pack.title,$index))">\r
+ <simfile rock-endpoint="rockEndpoint"\r
+ simfile="simfile"\r
+ banner="simfile.banner"\r
+ title="simfile.title"\r
+ artist="simfile.artist"\r
+ steps="simfile.steps"\r
+ bpm-changes="simfile.bpmChanges"\r
+ bg-changes="simfile.bgChanges"\r
+ fg-changes="simfile.fgChanges"\r
+ />\r
+ </div>\r
+ </li>\r
+ </ul>\r
+ </div>\r
+ </li>\r
+</ul>
\ No newline at end of file
--- /dev/null
+'use strict';
+
+angular.module("DivinElegy.pages.packs", ["DivinElegy.components.simfiles","DivinElegy.components.config"])
+
+.controller("PackController", ['$scope', 'rockEndpoint', 'SimfileService', function($scope, rockEndpoint, SimfileService)
+{
+ $scope.rockEndpoint = rockEndpoint;
+ $scope.activeListings = [];
+ $scope.packTitleFilterKeyword = null;
+ $scope.artistFilterKeyword = null;
+ $scope.songTitleFilterKeyword = null;
+ $scope.difficultyFilterKeyword = 'Any';
+ $scope.ratingFilterKeyword = null;
+ $scope.contributorFilterKeyword = null;
+ $scope.fgChangesFilterKeyword = null;
+ $scope.bgChangesFilterKeyword = null;
+ $scope.bpmChangesFilterKeyword = null;
+ $scope.simfileList = [];
+
+ $scope.openListing = function(listing)
+ {
+ if($scope.isListingActive(listing))
+ {
+ $scope.activeListings.splice($scope.activeListings.indexOf(listing), 1);
+ } else {
+ $scope.activeListings.push(listing);
+ }
+ };
+
+ $scope.isListingActive = function(listing)
+ {
+ if($scope.activeListings.indexOf(listing) > -1)
+ {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ $scope.getContributors = function(contribs)
+ {
+ return contribs.join(', ');
+ }
+
+ $scope.getSimfileListingIndex = function(packName, index)
+ {
+ return packName + "" + index;
+ }
+
+ $scope.packTitleFilter = function (pack)
+ {
+ var re = new RegExp($scope.packTitleFilterKeyword, 'i');
+ return !$scope.packTitleFilterKeyword || re.test(pack.title);
+ };
+
+ $scope.artistFilter = function (pack)
+ {
+ var re = new RegExp($scope.artistFilterKeyword, 'i');
+ var simfiles = pack.simfiles;
+ var match = false;
+ for(var i=0; i<simfiles.length; i++)
+ {
+ match = re.test(simfiles[i].artist);
+ if(match) break;
+ }
+
+ return !$scope.artistFilterKeyword || match;
+ };
+
+ $scope.songTitleFilter = function (pack)
+ {
+ var re = new RegExp($scope.songTitleFilterKeyword, 'i');
+ var simfiles = pack.simfiles;
+ var match = false;
+ for(var i=0; i<simfiles.length; i++)
+ {
+ match = re.test(simfiles[i].title);
+ if(match) break;
+ }
+
+ return !$scope.songTitleFilterKeyword || match;
+ };
+
+ $scope.stepsFilter = function(pack)
+ {
+ // Step 0: Both rating and difficulty keyword are null
+ if(!$scope.ratingFilterKeyword && $scope.difficultyFilterKeyword === 'Any' && !$scope.stepArtistFilterKeyword)
+ {
+ return true;
+ }
+
+ var re = new RegExp($scope.stepArtistFilterKeyword, 'i');
+ var simfiles = pack.simfiles;
+
+ for(var i=0; i<simfiles.length; i++)
+ {
+ for(var j=0; j<simfiles[i].steps.single.length; j++)
+ {
+ var chartInfo = simfiles[i].steps.single[j];
+ var match = true;
+ if($scope.ratingFilterKeyword && chartInfo.rating !== $scope.ratingFilterKeyword)
+ {
+ match = false;
+ }
+
+ if($scope.difficultyFilterKeyword !== 'Any' && chartInfo.difficulty !== $scope.difficultyFilterKeyword)
+ {
+ match = false;
+ }
+
+ if($scope.stepArtistFilterKeyword && !re.test(chartInfo.artist))
+ {
+ match = false;
+ }
+
+ if(match) return true;
+ }
+
+ for(var j=0; j<simfiles[i].steps.double.length; j++)
+ {
+ var chartInfo = simfiles[i].steps.double[j];
+ var match = true;
+ if($scope.ratingFilterKeyword && chartInfo.rating !== $scope.ratingFilterKeyword)
+ {
+ match = false;
+ }
+
+ if($scope.difficultyFilterKeyword !== 'Any' && chartInfo.difficulty !== $scope.difficultyFilterKeyword)
+ {
+ match = false;
+ }
+
+ if($scope.stepArtistFilterKeyword && !re.test(chartInfo.artist))
+ {
+ match = false;
+ }
+
+ if(match) return true;;
+ }
+ }
+
+ return false;
+ };
+
+ $scope.fgChangesFilter = function(simfile)
+ {
+ return !$scope.fgChangesFilterKeyword || simfile.fbChanges === 'Yes';
+ };
+
+ $scope.bgChangesFilter = function(simfile)
+ {
+ return !$scope.bgChangesFilterKeyword || simfile.bgChanges === 'Yes';
+ };
+
+ $scope.bpmChangesFilter = function(simfile)
+ {
+ return !$scope.bpmChangesFilterKeyword || simfile.bpmChanges === 'Yes';
+ };
+
+ SimfileService.getPacks().then(function(packs)
+ {
+ $scope.packList = packs;
+ });
+}]);
\ No newline at end of file