reorganized qmCSV service
added heraldry markers
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
angular.module('quartermaester', ['ui.bootstrap', 'uiGmapgoogle-maps', 'fCsv', 'toggle-switch', 'rzModule'])
|
||||
angular.module('quartermaester', ['ui.bootstrap', 'uiGmapgoogle-maps', '$q-spread', 'fCsv', 'toggle-switch', 'rzModule'])
|
||||
|
||||
.config(function(uiGmapGoogleMapApiProvider) {
|
||||
uiGmapGoogleMapApiProvider.configure({
|
||||
|
||||
+66
-152
@@ -1,13 +1,21 @@
|
||||
angular.module('quartermaester')
|
||||
|
||||
.controller("mapCtrl", function($scope, $q, $filter, $timeout, uiGmapGoogleMapApi, smgMapType, qmCsv) {
|
||||
.controller("mapCtrl", function($scope, $filter, $timeout, uiGmapGoogleMapApi, smgMapType, qmCsv) {
|
||||
|
||||
var qmData = {};
|
||||
$scope.state = "slider";
|
||||
$scope.search = "";
|
||||
$scope.slider = {
|
||||
show: "episodes",
|
||||
currentEpisode: 0,
|
||||
currentChapter: 0
|
||||
};
|
||||
$scope.options = {
|
||||
characterPaths: true,
|
||||
houseHeraldry: false,
|
||||
geographicRegions: false,
|
||||
politicalAllegiances: false
|
||||
};
|
||||
$scope.map = {
|
||||
center: {
|
||||
latitude: 1.3182,
|
||||
@@ -16,60 +24,67 @@ angular.module('quartermaester')
|
||||
zoom: 4,
|
||||
options: {
|
||||
maxZoom: 5,
|
||||
minZoom: 1
|
||||
minZoom: 1,
|
||||
disableDefaultUI: true,
|
||||
zoomControl: true
|
||||
},
|
||||
events: {
|
||||
click: mapClick
|
||||
},
|
||||
control: {},
|
||||
smgMapType: smgMapType,
|
||||
locationClick: locationClick,
|
||||
locations: []
|
||||
heraldryClick: heraldryClick
|
||||
};
|
||||
$scope.options = {
|
||||
characterPaths: true,
|
||||
houseHeraldry: false,
|
||||
geographicRegions: false,
|
||||
politicalAllegiances: false
|
||||
$scope.mapModels = {
|
||||
towns: [],
|
||||
heraldry: [],
|
||||
characters: [],
|
||||
paths: [],
|
||||
regions: [],
|
||||
loyalties: []
|
||||
};
|
||||
$scope.search = "";
|
||||
$scope.smgMapType = smgMapType;
|
||||
$scope.episodes = [];
|
||||
$scope.chapters = [];
|
||||
$scope.searchResults = [];
|
||||
$scope.toState = toState;
|
||||
$scope.slideTo = slideTo;
|
||||
$scope.panTo = panTo;
|
||||
$scope.episodes = [];
|
||||
$scope.chapters = [];
|
||||
$scope.searchResults = [
|
||||
{
|
||||
icon: "glyphicon-user",
|
||||
title: "Eddard Stark",
|
||||
subtitle: "House Stark",
|
||||
search: "Eddard Stark",
|
||||
click: function(){showCharacter("eddard")}
|
||||
}
|
||||
];
|
||||
$scope.refreshMap = refreshMap;
|
||||
$scope.locationDetail = null;
|
||||
|
||||
// Set up promises
|
||||
uiGmapGoogleMapApi.then(onMapLoad);
|
||||
$q.all([
|
||||
qmCsv.get('locations.csv'),
|
||||
qmCsv.get('houses.csv')
|
||||
]).then(createLocationMarkers);
|
||||
$q.all([
|
||||
qmCsv.get('books.csv'),
|
||||
qmCsv.get('chapters.csv')
|
||||
]).then(addChaptersToScope);
|
||||
qmCsv.get('episodes.csv').then(addEpisodesToScope);
|
||||
$q.all([
|
||||
qmCsv.get('characters.csv'),
|
||||
qmCsv.get('houses.csv')
|
||||
]).then(addCharactersToScope);
|
||||
$q.all([
|
||||
qmCsv.get('regions.csv'),
|
||||
qmCsv.get('borders.csv')
|
||||
]).then(addRegionsToScope);
|
||||
qmCsv.loadData().then(addToScope);
|
||||
|
||||
|
||||
//////////////////
|
||||
|
||||
function addToScope(d) {
|
||||
qmData = d;
|
||||
|
||||
// Add data from CSV files into $scope
|
||||
$scope.episodes = qmData.episodes;
|
||||
$scope.chapters = qmData.chapters;
|
||||
$scope.characters = qmData.characters;
|
||||
$scope.searchResults = qmData.searchResults;
|
||||
$scope.mapModels.regions = qmData.regions;
|
||||
|
||||
$scope.$watch('slider', refreshMap, true);
|
||||
$scope.$watch('options', refreshMap, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function refreshMap() {
|
||||
// Redraw map with new slider values
|
||||
$scope.mapModels.towns = $filter('qmSlider')(qmData.towns, $scope.slider);
|
||||
$scope.mapModels.heraldry = $scope.options.houseHeraldry ? $filter('qmSlider')(qmData.heraldry, $scope.slider) : [];
|
||||
//console.log("heraldry", $scope.mapModels.heraldry);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function toState(stateName) {
|
||||
$scope.state = stateName;
|
||||
if (stateName=="search")
|
||||
@@ -79,21 +94,22 @@ angular.module('quartermaester')
|
||||
}
|
||||
|
||||
function slideTo(input) {
|
||||
var books = $scope.books.map(function(book) {return book.abbreviation;});
|
||||
var sliderIndex = ($scope.slider.show=="episodes") ? "currentEpisode" : "currentChapter";
|
||||
console.log("qmData", qmData);
|
||||
var books = qmData.books.map(function(book) {return book.abbreviation;});
|
||||
var measure = ($scope.slider.show=="episodes") ? "currentEpisode" : "currentChapter";
|
||||
var sliderMax = ($scope.slider.show=="episodes") ? $scope.episodes.length-1 : $scope.chapters.length-1;
|
||||
switch (input) {
|
||||
case -10:
|
||||
$scope.slider[sliderIndex] = 0;
|
||||
$scope.slider[measure] = 0;
|
||||
break;
|
||||
case -1:
|
||||
if ($scope.slider[sliderIndex]>0) $scope.slider[sliderIndex]--;
|
||||
if ($scope.slider[measure]>0) $scope.slider[measure]--;
|
||||
break;
|
||||
case 1:
|
||||
if ($scope.slider[sliderIndex]<sliderMax) $scope.slider[sliderIndex]++;
|
||||
if ($scope.slider[measure]<sliderMax) $scope.slider[measure]++;
|
||||
break;
|
||||
case 10:
|
||||
$scope.slider[sliderIndex] = sliderMax;
|
||||
$scope.slider[measure] = sliderMax;
|
||||
break;
|
||||
default:
|
||||
$scope.state = "slider";
|
||||
@@ -107,7 +123,7 @@ angular.module('quartermaester')
|
||||
$scope.slider.show = "chapters";
|
||||
var reMatch = /(\w{4})\-(\d+)/.exec(input);
|
||||
var bookId = books.indexOf(reMatch[1]);
|
||||
$scope.slider.currentChapter = parseInt($scope.books[bookId].precedingChapters, 10) + parseInt(reMatch[2], 10);
|
||||
$scope.slider.currentChapter = parseInt(qmData.books[bookId].precedingChapters, 10) + parseInt(reMatch[2], 10);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -122,114 +138,12 @@ angular.module('quartermaester')
|
||||
$scope.state = "location";
|
||||
}
|
||||
|
||||
function addEpisodesToScope(response) {
|
||||
$scope.episodes = response.map(function(episode) {
|
||||
var epNumber = (episode.episode.length==2) ? episode.episode : "0"+episode.episode;
|
||||
return {
|
||||
name: "S" + episode.season + "E" + epNumber + ": " + episode.title,
|
||||
url: (episode.awoiaf=="") ? "https://en.wikipedia.org/wiki/"+episode.wikipedia : "http://awoiaf.westeros.org/index.php/"+episode.awoiaf
|
||||
};
|
||||
});
|
||||
//console.log("e", $scope.episodes);
|
||||
|
||||
$scope.searchResults = $scope.searchResults.concat(response.map(function(episode) {
|
||||
var epNumber = (episode.episode.length==2) ? episode.episode : "0"+episode.episode;
|
||||
return {
|
||||
icon: "glyphicon-facetime-video",
|
||||
title: episode.title,
|
||||
subtitle: "HBO episode",
|
||||
search: episode.title,
|
||||
abbr: "S" + episode.season + "E" + epNumber + ": " + episode.title,
|
||||
click: function(){slideTo(this.abbr)}
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
function addChaptersToScope(response) {
|
||||
$scope.books = response[0];
|
||||
$scope.chapters = response[1].map(function(chapter) {
|
||||
return {
|
||||
name: response[0][chapter.book].abbreviation + "-" + chapter.chapter + ": " + chapter.title,
|
||||
url: "http://awoiaf.westeros.org/index.php/"+chapter.awoiaf
|
||||
};
|
||||
});
|
||||
//console.log("c", $scope.chapters);
|
||||
|
||||
$scope.searchResults = $scope.searchResults.concat(response[1].map(function(chapter) {
|
||||
return {
|
||||
icon: "glyphicon-book",
|
||||
title: chapter.title,
|
||||
subtitle: response[0][chapter.book].title,
|
||||
search: chapter.title,
|
||||
abbr: response[0][chapter.book].abbreviation + "-" + chapter.chapter,
|
||||
click: function(){slideTo(this.abbr)}
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
function addCharactersToScope(responses) {
|
||||
$scope.characters = responses[0].map(function(character) {
|
||||
var output = {
|
||||
name: character.name,
|
||||
url: "http://awoiaf.westeros.org/index.php/" + character.awoiaf,
|
||||
house: ""
|
||||
}
|
||||
if (character.house!="") {
|
||||
matchingHouse = $filter('filter')(responses[1], {wikiKey: character.house})[0];
|
||||
output.house = {
|
||||
name: decodeURI(matchingHouse.wikiKey).replace(/_/g," "),
|
||||
url: "http://awoiaf.westeros.org/index.php/" + matchingHouse.wikiKey,
|
||||
img: matchingHouse.img
|
||||
}
|
||||
}
|
||||
return output;
|
||||
});
|
||||
}
|
||||
|
||||
function addRegionsToScope(responses) {
|
||||
// console.log("regions", responses[0]);
|
||||
// console.log("borders", responses[1]);
|
||||
|
||||
var borderArrays = {};
|
||||
for (var i=0; i<responses[1].length; i++) {
|
||||
if (!(responses[1][i].name in borderArrays)) borderArrays[responses[1][i].name] = [];
|
||||
borderArrays[responses[1][i].name].push(responses[1][i]);
|
||||
}
|
||||
|
||||
$scope.map.regions = responses[0].map(function(region) {
|
||||
return {
|
||||
key: region.name,
|
||||
fill: {
|
||||
color: region.color,
|
||||
opacity: 0.5
|
||||
},
|
||||
stroke: {
|
||||
weight: 0
|
||||
},
|
||||
path: borderArrays[region.name]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createLocationMarkers(responses) {
|
||||
$scope.houses = responses[1];
|
||||
$scope.map.locations = qmCsv.setHomes(responses[0], responses[1]);
|
||||
//console.log("locations", $scope.map.locations);
|
||||
|
||||
$scope.searchResults = $scope.searchResults.concat($scope.map.locations.map(function(location) {
|
||||
return {
|
||||
icon: "glyphicon-map-marker",
|
||||
key: location.key,
|
||||
title: location.name,
|
||||
subtitle: (location.occupants.length) ? location.occupants[0].name : "",
|
||||
search: (location.occupants.length) ? location.name + " " + location.occupants[0].name : location.name,
|
||||
click: function(){panTo(this.key)}
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
function locationClick(marker, eventName, model) {
|
||||
model.currentOccupant = qmCsv.getCurrentOccupant(model);
|
||||
$scope.locationDetail = model;
|
||||
$scope.state = "location";
|
||||
}
|
||||
|
||||
function heraldryClick(marker, eventName, model) {
|
||||
$scope.locationDetail = model;
|
||||
$scope.state = "location";
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(e){"use strict";e.module("$q-spread",[]).config(["$provide",function(e){e.decorator("$q",["$delegate",function(e){var r=e.defer;return e.defer=function(){var e=r().promise.constructor.prototype;return Object.defineProperty(e,"spread",{value:function(e,r){function n(r){return e.apply(void 0,r)}return this.then(n,r)},writable:!0,enumerable:!1}),r()},e}])}])}(window.angular);
|
||||
+271
-60
@@ -49,17 +49,277 @@ angular.module('quartermaester')
|
||||
|
||||
})
|
||||
|
||||
.factory('qmCsv', function($http, $filter, fCsv) {
|
||||
.factory('qmCsv', function($q, $http, $filter, fCsv) {
|
||||
|
||||
var csvLocation = "http://www.rslc.us/quartermaester/data/";
|
||||
return {
|
||||
get: getFile,
|
||||
setHomes: setHomes,
|
||||
getCurrentOccupant: getCurrentOccupant
|
||||
// get: getFile,
|
||||
loadData: loadData,
|
||||
// setHomes: setHomes,
|
||||
// setHeraldry: setHeraldry,
|
||||
// getCurrentOccupant: getCurrentOccupant
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
function loadData() {
|
||||
return $q.all([
|
||||
getFile('books.csv'),
|
||||
getFile('chapters.csv'),
|
||||
getFile('seasons.csv'),
|
||||
getFile('episodes.csv'),
|
||||
getFile('houses.csv'),
|
||||
getFile('characters.csv'),
|
||||
getFile('regions.csv'),
|
||||
getFile('towns.csv'),
|
||||
getFile('borders.csv'),
|
||||
// getFile('stops.csv'),
|
||||
// getFile('waypoints.csv'),
|
||||
// getFile('paths.csv')
|
||||
]).spread(parseData);
|
||||
}
|
||||
|
||||
function parseData(books, chapters, seasons, episodes, houses, characters, regions, towns, borders, stops, waypoints, paths) {
|
||||
var qmData = {
|
||||
borderArrays: {}
|
||||
};
|
||||
|
||||
|
||||
for (var i=0; i<borders.length; i++) {
|
||||
if (!(borders[i].name in qmData.borderArrays))
|
||||
qmData.borderArrays[borders[i].name] = [];
|
||||
qmData.borderArrays[borders[i].name].push(borders[i]);
|
||||
}
|
||||
|
||||
qmData.episodes = episodes.map(episodeModel);
|
||||
qmData.chapters = chapters.map(chapterModel);
|
||||
qmData.books = books;
|
||||
qmData.regions = regions.map(regionModel);
|
||||
qmData.characters = characters.map(characterModel);
|
||||
qmData.towns = getTownMarkers(towns, houses);
|
||||
qmData.heraldry = houses.map(heraldryMarkerModel);
|
||||
|
||||
|
||||
qmData.searchResults = [].concat(
|
||||
towns.map(townSearchModel),
|
||||
characters.map(characterSearchModel),
|
||||
houses.map(houseSearchModel),
|
||||
episodes.map(episodeSearchModel),
|
||||
chapters.map(chapterSearchModel)
|
||||
);
|
||||
|
||||
|
||||
return qmData;
|
||||
|
||||
|
||||
function episodeModel(episode) {
|
||||
var epNumber = (episode.episode.length==2) ? episode.episode : "0"+episode.episode;
|
||||
return {
|
||||
name: "S" + episode.season + "E" + epNumber + ": " + episode.title,
|
||||
url: (episode.awoiaf=="") ? "https://en.wikipedia.org/wiki/"+episode.wikipedia : "http://awoiaf.westeros.org/index.php/"+episode.awoiaf
|
||||
};
|
||||
}
|
||||
|
||||
function episodeSearchModel(episode) {
|
||||
var epNumber = (episode.episode.length==2) ? episode.episode : "0"+episode.episode;
|
||||
return {
|
||||
icon: "glyphicon-facetime-video",
|
||||
title: episode.title,
|
||||
subtitle: "HBO episode",
|
||||
abbr: "S" + episode.season + "E" + epNumber + ": " + episode.title,
|
||||
click: function(){slideTo(this.abbr)}
|
||||
};
|
||||
}
|
||||
|
||||
function chapterModel(chapter) {
|
||||
return {
|
||||
name: books[chapter.book].abbreviation + "-" + chapter.chapter + ": " + chapter.title,
|
||||
url: "http://awoiaf.westeros.org/index.php/"+chapter.awoiaf
|
||||
};
|
||||
}
|
||||
|
||||
function chapterSearchModel(chapter) {
|
||||
return {
|
||||
icon: "glyphicon-book",
|
||||
title: chapter.title,
|
||||
subtitle: books[chapter.book].title,
|
||||
abbr: books[chapter.book].abbreviation + "-" + chapter.chapter,
|
||||
click: function(){slideTo(this.abbr)}
|
||||
};
|
||||
}
|
||||
|
||||
function getTownMarkers(towns, houses) {
|
||||
var output = [];
|
||||
var matchingHouses = [];
|
||||
for (var townId=0; townId<towns.length; townId++) {
|
||||
var town = towns[townId];
|
||||
var matchingHouses = $filter('filter')(houses, {seatKey: town.key});
|
||||
|
||||
// Towns without nobility or other locations
|
||||
if (matchingHouses.length==0) output.push({
|
||||
key: town.key,
|
||||
name: decodeURI(town.key).replace(/_/g," "),
|
||||
url: "http://awoiaf.westeros.org/index.php/" + town.key,
|
||||
house: "No known lord",
|
||||
houseUrl: null,
|
||||
timing: {
|
||||
episodes: [0,999],
|
||||
chapters: [0,999]
|
||||
},
|
||||
direct: "#@" + town.key,
|
||||
coords: {
|
||||
latitude: parseFloat(town.latitude),
|
||||
longitude: parseFloat(town.longitude)
|
||||
},
|
||||
options: {
|
||||
icon: {path: 0, strokeOpacity: 0, scale: 3}
|
||||
}
|
||||
});
|
||||
|
||||
for (var houseId=0; houseId<matchingHouses.length; houseId++) {
|
||||
var house = matchingHouses[houseId];
|
||||
output.push({
|
||||
key: town.key,
|
||||
name: decodeURI(town.key).replace(/_/g," "),
|
||||
url: "http://awoiaf.westeros.org/index.php/" + town.key,
|
||||
house: decodeURI(house.wikiKey).replace(/_/g," "),
|
||||
houseUrl: "http://awoiaf.westeros.org/index.php/" + house.wikiKey,
|
||||
houseImg: house.img,
|
||||
timing: {
|
||||
episodes: [
|
||||
parseInt(house.firstEpisode, 10) || 0,
|
||||
parseInt(house.lastEpisode , 10) || 999
|
||||
],
|
||||
chapters: [
|
||||
parseInt(house.firstChapter, 10) || 0,
|
||||
parseInt(house.lastChapter , 10) || 999
|
||||
]
|
||||
},
|
||||
direct: "#@" + town.key,
|
||||
coords: {
|
||||
latitude: parseFloat(town.latitude),
|
||||
longitude: parseFloat(town.longitude)
|
||||
},
|
||||
options: {
|
||||
icon: {path: 0, strokeOpacity: 0, scale: 3}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
function townSearchModel(town) {
|
||||
return {
|
||||
icon: "glyphicon-map-marker",
|
||||
key: town.key,
|
||||
title: town.name,
|
||||
subtitle: town.region.replace(/_/g," "),
|
||||
click: function(){panTo(this.key)}
|
||||
};
|
||||
}
|
||||
|
||||
function characterModel(character) {
|
||||
var output = {
|
||||
name: character.name,
|
||||
url: "http://awoiaf.westeros.org/index.php/" + character.awoiaf,
|
||||
house: ""
|
||||
}
|
||||
if (character.house!="") {
|
||||
matchingHouse = $filter('filter')(houses, {wikiKey: character.house})[0];
|
||||
output.house = {
|
||||
name: decodeURI(matchingHouse.wikiKey).replace(/_/g," "),
|
||||
url: "http://awoiaf.westeros.org/index.php/" + matchingHouse.wikiKey,
|
||||
img: matchingHouse.img
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function characterSearchModel(character) {
|
||||
return {
|
||||
icon: "glyphicon-user",
|
||||
key: character.key,
|
||||
title: character.name,
|
||||
subtitle: decodeURI(character.house).replace(/_/g," "),
|
||||
click: function(){showCharacter(this.key)}
|
||||
};
|
||||
}
|
||||
|
||||
function heraldryMarkerModel(house, index) {
|
||||
if (house.seatKey=="") {
|
||||
var coords = {
|
||||
latitude: parseFloat(house.lat),
|
||||
longitude: parseFloat(house.lng)
|
||||
};
|
||||
} else {
|
||||
var matchingTown = $filter('filter')(qmData.towns, {key: house.seatKey})[0];
|
||||
var coords = matchingTown.coords;
|
||||
}
|
||||
house.isGreat = (house.isGreat=="TRUE");
|
||||
|
||||
return {
|
||||
key: "house-" + index,
|
||||
name: decodeURI(house.wikiKey).replace(/_/g," "),
|
||||
url: "http://awoiaf.westeros.org/index.php/" + house.wikiKey,
|
||||
seat: decodeURI(house.seatKey).replace(/_/g," ") || house.clue || "unknown",
|
||||
seatUrl: "http://awoiaf.westeros.org/index.php/" + house.seatKey,
|
||||
houseImg: house.img,
|
||||
timing: {
|
||||
episodes: [
|
||||
parseInt(house.firstEpisode, 10) || 0,
|
||||
parseInt(house.lastEpisode , 10) || 999
|
||||
],
|
||||
chapters: [
|
||||
parseInt(house.firstChapter, 10) || 0,
|
||||
parseInt(house.lastChapter , 10) || 999
|
||||
]
|
||||
},
|
||||
direct: "#@" + house.seatKey,
|
||||
coords: coords,
|
||||
options: {
|
||||
icon: {
|
||||
url: house.img,
|
||||
scaledSize: house.isGreat ? {height:60, width:50} : {height:30, width:25},
|
||||
anchor: house.isGreat ? {x:30, y:25} : {x:15, y:12}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function houseSearchModel(house) {
|
||||
return {
|
||||
icon: "glyphicon-home",
|
||||
title: decodeURI(house.wikiKey).replace(/_/g," "),
|
||||
subtitle: (house.seatKey=="") ? house.clue : decodeURI(house.seatKey).replace(/_/g," "),
|
||||
click: function(){showCharacter(character.key)}
|
||||
};
|
||||
}
|
||||
|
||||
function regionModel(region) {
|
||||
return {
|
||||
key: region.key,
|
||||
fill: {
|
||||
color: region.color,
|
||||
opacity: 0.5
|
||||
},
|
||||
stroke: {weight: 0},
|
||||
path: qmData.borderArrays[region.key]
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function getFile(filename) {
|
||||
return $http
|
||||
.get(csvLocation + filename)
|
||||
@@ -72,52 +332,6 @@ angular.module('quartermaester')
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
function setHomes(locations, houses) {
|
||||
//console.log(locations, houses);
|
||||
|
||||
var markers = locations.map(locationModel);
|
||||
|
||||
for (var i=0; i<markers.length; i++) {
|
||||
var matchingHouses = $filter('filter')(houses, {seatKey: locations[i].key});
|
||||
markers[i].occupants = matchingHouses.map(function(house) {
|
||||
return {
|
||||
name: decodeURI(house.wikiKey).replace(/_/g," "),
|
||||
url: "http://awoiaf.westeros.org/index.php/" + house.wikiKey,
|
||||
img: house.img,
|
||||
firstChapter: parseInt(house.firstChapter, 10) || null,
|
||||
lastChapter: parseInt(house.lastChapter, 10) || null,
|
||||
firstEpisode: parseInt(house.firstEpisode, 10) || null,
|
||||
lastEpisode: parseInt(house.lastEpisode, 10) || null
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return markers;
|
||||
}
|
||||
|
||||
function locationModel(json) {
|
||||
return {
|
||||
key: json.key,
|
||||
name: decodeURI(json.key).replace(/_/g," "),
|
||||
url: "http://awoiaf.westeros.org/index.php/" + json.key,
|
||||
direct: "#@" + json.key,
|
||||
coords: {
|
||||
latitude: parseFloat(json.latitude),
|
||||
longitude: parseFloat(json.longitude)
|
||||
},
|
||||
options: {
|
||||
icon: {path: 0, strokeOpacity: 0, scale: 3}
|
||||
},
|
||||
occupants: []
|
||||
};
|
||||
}
|
||||
|
||||
function getCurrentOccupant(marker) {
|
||||
if (marker.occupants.length==0) return null;
|
||||
if (marker.occupants.length==1) return marker.occupants[0];
|
||||
return $filter('qmSlider')(marker.occupants, "episodes", 0)[0];
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@@ -125,18 +339,15 @@ angular.module('quartermaester')
|
||||
|
||||
// In the return function, we must pass in a single parameter which will be the data we will work on.
|
||||
// We have the ability to support multiple other parameters that can be passed into the filter optionally
|
||||
return function(inputArray, slider, value) {
|
||||
return function(inputArray, slider) {
|
||||
|
||||
var outputArray = [];
|
||||
var currentValue = (slider.show=="episodes") ? slider.currentEpisode : slider.currentChapter;
|
||||
|
||||
outputArray = [];
|
||||
for (var i=0; i<inputArray.length; i++) {
|
||||
switch (slider) {
|
||||
case "episodes":
|
||||
if (inputArray[i].firstEpisode==null || (value>=inputArray[i].firstEpisode && value<=inputArray[i].lastEpisode)) outputArray.push(inputArray[i]);
|
||||
break;
|
||||
case "chapters":
|
||||
if (inputArray[i].firstChapter==null || (value>=inputArray[i].firstChapter && value<=inputArray[i].lastChapter)) outputArray.push(inputArray[i]);
|
||||
break;
|
||||
}
|
||||
if (currentValue < inputArray[i].timing[slider.show][0]) continue;
|
||||
if (currentValue > inputArray[i].timing[slider.show][1]) continue;
|
||||
outputArray.push(inputArray[i]);
|
||||
}
|
||||
|
||||
return outputArray;
|
||||
|
||||
Reference in New Issue
Block a user