"
+ + "";
var compiledBread = $compile(newBreadcrumb)(editScope);
$(".view").append(compiledBread);
@@ -231,31 +229,28 @@ function init() {
if (editStep == editScope.EditorScreenViews.TYPE) {
//Overhauled UI on Mission Type page, including more editorialising on non-linear missions in banners
$(".type-view .bordered-panel").empty().addClass('ready');
- var editCode = "
Agents visit portals and field trip markers in a set order.
Best suited to missions in a banner series, or one-offs with a pre-determined route.
"
- editCode += "
Agents visit portals and field trip markers in a set order, but the location of every waypoint beyond the first is hidden, meaning players rely on clues in the waypoint text.
Good for more puzzle-based missions, but please ensure you provide adequate clues for agents to find all the waypoints.
"
- editCode += "
Agents visit portals and field trip markers in any order. Excellent for one-off missions where a specific route isn't required, but terrible for missions in banner serieses.
It is strongly advised that if you are making missions for a banner, you set them as Sequential missions - your rating on IngressMosaik will thank you!
"
+ var editCode = "
"
+ + ""
+ + ""
+ + ""
+ + "
"
+ + "
Agents visit portals and field trip markers in a set order.
Best suited to missions in a banner series, or one-offs with a pre-determined route.
"
+ + "
Agents visit portals and field trip markers in a set order, but the location of every waypoint beyond the first is hidden, meaning players rely on clues in the waypoint text.
Good for more puzzle-based missions, but please ensure you provide adequate clues for agents to find all the waypoints.
"
+ + "
Agents visit portals and field trip markers in any order. Excellent for one-off missions where a specific route isn't required, but terrible for missions in banner serieses.
It is strongly advised that if you are making missions for a banner, you set them as Sequential missions - your rating on IngressMosaik will thank you!
";
var compiledContent = $compile(editCode)(editScope);
$(".type-view .bordered-panel").append(compiledContent);
} else if (editStep == editScope.EditorScreenViews.NAME) {
//Overhauled UI on Mission Name/Image pages
$(".name-view .bordered-panel").empty().addClass('ready');
- var editCode = "
";
- editCode += "";
- editCode += "
";
- editCode += "
";
- editCode += "";
- editCode += "
";
- editCode += "
";
- editCode += "
";
+ var editCode = "
"
+ + ""
+ + "
"
+ + "
"
+ + ""
+ + "
"
+ + "
"
+ + "
";
var compiledContent = $compile(editCode)(editScope);
$(".name-view .bordered-panel").append(compiledContent);
}
@@ -302,52 +297,46 @@ function init() {
return dfd.promise;
}
+ missionScope.categoryContent = [];
+ missionScope.categorisedMissions = [];
+ missionScope.uncategorisedMissions = [];
+ missionScope.uncategorisedSort = 'initial';
missionScope.missions = w.$filter("orderBy")(missionScope.missions, 'definition.name');
missionScope.loadingPreview = false;
- //missionScope.getFullMissionData(missionScope.missions).then(function(data){
- //for (var i=0;i 0) {
- missionScope.categoryContent = [];
- //create uncategorised mission bucket, that categories will take missions from. Add position in initial array
- for (var i = 0; i < missionScope.missions.length; i++) {
- missionScope.missions[i].position = i;
- }
- missionScope.uncategorisedMissions = angular.copy(missionScope.missions);
-
- //loop through each category of GUIDs, and add actual missions to scope
- categoryGUIDs.forEach(function(category) {
- var catobj = [];
- category.forEach(function(guid) {
- for (var i = 0; i < missionScope.uncategorisedMissions.length ; i++) {
- //once the right mission is found, add position, push it to the holding array and remove from uncategorised
- if (missionScope.uncategorisedMissions[i].mission_guid == guid) {
- catobj.push(missionScope.uncategorisedMissions[i]);
- missionScope.uncategorisedMissions.splice(i, 1);
- break;
- }
- }
- })
- missionScope.categoryContent.push(catobj)
- })
+ missionScope.unsortedCollapse = {collapse: w.localStorage.getItem('unsortedCollapse') || true};
+
+ //handling for legacy data format
+ if (!!w.localStorage.getItem('categoryNames')){
+ let oldegoriesLength = parseInt(w.localStorage.getItem('categoriesLength')) || 0,
+ categoryNames = w.localStorage.getItem('categoryNames') ? w.localStorage.getItem('categoryNames').split(',') : [],
+ thisCategory;
+ //create categories in new format
+ for (var i= 0; i < oldegoriesLength; i++){
+ thisCategory = {
+ id: i,
+ name: categoryNames[i],
+ missions: w.localStorage.getItem('categoryContent' + i) ? w.localStorage.getItem('categoryContent' + i).split(',') : [],
+ collapse: true,
+ sortCriteria: 'initial'
+ };
+ missionScope.categoryContent.push(thisCategory);
+ w.localStorage.removeItem('categoryContent' + i);
}
+ w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent));
- //})
+ //now tidy up the legacy data
+ w.localStorage.removeItem('categoryNames');
+ w.localStorage.removeItem('categoriesLength');
+ }
+
+ //get data for all categories
+ missionScope.categoryContent = JSON.parse(w.localStorage.getItem('allCategories')) || [];
+ missionScope.selectedCategoryMissionId = null;
+
+ //Add position in initial array
+ for (var i = 0; i < missionScope.missions.length; i++) {
+ missionScope.missions[i].position = i;
+ }
//function to calculate distances between two sets of coordinates taken from geodatasource.com
missionScope.distance = function(lat1, lon1, lat2, lon2, unit) {
@@ -385,8 +374,8 @@ function init() {
distance += missionScope.distance(
mission.definition.waypoints[i-1]._poi.location.latitude,
mission.definition.waypoints[i-1]._poi.location.longitude,
- mission.definition.waypoints[i]._poi.location.latitude,
- mission.definition.waypoints[i]._poi.location.longitude,
+ mission.definition.waypoints[i]._poi.location.latitude,
+ mission.definition.waypoints[i]._poi.location.longitude,
"K")
}
@@ -410,10 +399,10 @@ function init() {
missionScope.previewBanner = function(category) {
$('#previewMissionModel .modal-body .notloading').empty();
missionScope.loadingPreview = true;
- missionScope.getFullMissionData(missionScope.categoryContent[category]).then(function(data){
+ missionScope.getFullMissionData(missionScope.categorisedMissions[category]).then(function(data){
missionScope.banner = {
definition: {
- name: categoryNames[category],
+ name: missionScope.categoryContent[category].name,
author_nickname: data[0].author_nickname,
description: data[0].description,
_sequential: data[0]._sequential,
@@ -421,14 +410,14 @@ function init() {
waypoints: []
},
stats: {
- num_completed: missionScope.categoryContent[category][data.length -1].stats ? missionScope.categoryContent[category][data.length -1].stats.num_completed : 0,
+ num_completed: missionScope.categorisedMissions[category][data.length -1].stats ? missionScope.categorisedMissions[category][data.length -1].stats.num_completed : 0,
rating: 0,
median_completion_time: 0
},
};
- for (var i = 0; i < missionScope.categoryContent[category].length; i++){
- missionScope.banner.stats.rating += missionScope.categoryContent[category][i].stats ? missionScope.categoryContent[category][i].stats.rating : 0;
- missionScope.banner.stats.median_completion_time += missionScope.categoryContent[category][i].stats ? missionScope.categoryContent[category][i].stats.median_completion_time : 0;
+ for (var i = 0; i < missionScope.categorisedMissions[category].length; i++){
+ missionScope.banner.stats.rating += missionScope.categorisedMissions[category][i].stats ? missionScope.categorisedMissions[category][i].stats.rating : 0;
+ missionScope.banner.stats.median_completion_time += missionScope.categorisedMissions[category][i].stats ? missionScope.categorisedMissions[category][i].stats.median_completion_time : 0;
data[i].waypoints.forEach(function(wp){
missionScope.banner.definition.waypoints.push(wp)
})
@@ -470,32 +459,21 @@ function init() {
$(".modal-backdrop.fade").remove();
$("body").removeClass("modal-open");
var categoryID = missionScope.selectedCategoryID;
- categoryGUIDs[categoryID].push(missionScope.selectedCategoryMissionId);
- //find mission in uncategorised missions
- for (var i = 0; i < missionScope.uncategorisedMissions.length; i++) {
- if (missionScope.uncategorisedMissions[i].mission_guid == missionScope.selectedCategoryMissionId) {
- missionScope.categoryContent[categoryID].push(missionScope.uncategorisedMissions[i]);
- missionScope.uncategorisedMissions.splice(i, 1);
- break;
- }
- }
+ missionScope.categoryContent[categoryID].missions.push(missionScope.selectedCategoryMissionId);
+ missionScope.categoryContent[categoryID].collapse = false;
missionScope.selectedCategoryMissionId = null;
- w.localStorage.setItem('categoryContent' + categoryID, categoryGUIDs[categoryID]);
- missionScope.categoryCollapse[categoryID] = true;
missionScope.selectedCategoryID = null;
+ w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent));
generateAllMissions();
}
missionScope.removeFromCategory = function(category, mission) {
- for (var i = 0; i < categoryGUIDs[category].length; i++) {
- if (categoryGUIDs[category][i] == mission.mission_guid) {
- missionScope.uncategorisedMissions.push(mission);
- missionScope.categoryContent[category].splice(i, 1);
- categoryGUIDs[category].splice(i, 1);
+ for (var i = 0; i < missionScope.categoryContent[category].missions.length; i++) {
+ if (missionScope.categoryContent[category].missions[i] == mission.mission_guid) {
+ missionScope.categoryContent[category].missions.splice(i, 1);
}
}
- w.localStorage.setItem('categoryContent' + category, categoryGUIDs[category]);
- missionScope.categoryCollapse[category] = true;
+ w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent));
generateAllMissions();
}
@@ -504,61 +482,58 @@ function init() {
if (categoryName == null || categoryName == "") {
//no result
} else {
- //create category elements in various places
- categoriesLength++;
- w.localStorage.setItem('categoriesLength', categoriesLength);
- categoryNames.push(categoryName);
- w.localStorage.setItem('categoryNames', categoryNames);
- missionScope.categoryContent = missionScope.categoryContent || [];
- categoryGUIDs.push([]);
- missionScope.categoryContent.push([]);
- w.localStorage.setItem('categoryContent' + (categoriesLength - 1), []);
+ //create category elements
+ var newCategory = {
+ id: missionScope.categoryContent.length,
+ name: categoryName,
+ missions: [],
+ collapse: false,
+ sortCriteria: 'initial'
+ };
+ missionScope.categoryContent.push(newCategory);
+ w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent));
generateAllMissions();
}
}
+
missionScope.nukeCategories = function() {
- w.localStorage.clear();
+ missionScope.categoryContent = [];
+ w.localStorage.setItem('allCategories', []);
generateAllMissions();
}
missionScope.deleteCategory = function(category) {
- if (confirm("Are you sure you want to delete the " + categoryNames[category] + " category? Any missions you've placed in this category will be retured to Unsorted missions.")) {
- //remove cateory from GUID list, move scope missions out, nuke localStorage categories
- categoryGUIDs.splice(category, 1);
+ if (confirm("Are you sure you want to delete the " + missionScope.categoryContent[category].name + " category? Any missions you've placed in this category will be retured to Unsorted missions.")) {
+ //move scope missions out, nuke localStorage categories
missionScope.categoryContent[category].forEach(function(mission) {
missionScope.uncategorisedMissions.push(mission);
})
missionScope.categoryContent.splice(category, 1);
- for (var i = 0; i < categoriesLength; i++) {
- w.localStorage.removeItem('categoryContent' + i);
- }
- //remove other mission data
- categoriesLength--;
- w.localStorage.setItem('categoriesLength', categoriesLength);
- categoryNames.splice(category, 1);
- w.localStorage.setItem('categoryNames', categoryNames);
- missionScope.categoryCollapse.splice(category, 1);
- //then rebuild localStorage
- for (var i = 0; i < categoriesLength; i++) {
- w.localStorage.setItem('categoryContent' + i, categoryGUIDs[i]);
- }
+ w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent));
generateAllMissions();
}
}
- missionScope.sortCategory = function(category, criteria){
+ missionScope.sortCategory = function(category){
if (category == 'all'){
- missionScope.missions = w.$filter("orderBy")(missionScope.missions, missionScope.sortCriteria[0]);
+ missionScope.missions = w.$filter("orderBy")(missionScope.missions, missionScope.sortCriteria[0] == 'initial' ? 'position' : missionScope.sortCriteria[0]);
} else if (category == 'unsorted'){
- missionScope.uncategorisedMissions = w.$filter("orderBy")(missionScope.uncategorisedMissions, missionScope.sortCriteria[categoriesLength]);
+ missionScope.uncategorisedSort = missionScope.sortCriteria[missionScope.categoryContent.length];
} else {
- missionScope.categoryContent[category] = w.$filter("orderBy")(missionScope.categoryContent[category], missionScope.sortCriteria[category]);
+ missionScope.categoryContent[category].sortCriteria = missionScope.sortCriteria[category];
}
generateAllMissions();
}
+ missionScope.toggleCollapse = function(collapse, unsorted){
+ collapse.collapse = !collapse.collapse;
+ unsorted ? w.localStorage.setItem('unsortedCollapse', collapse.collapse)
+ : w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent));
+ }
+
var generateSort = function (category){
var criteria = [
+ {name: "Initial", value: "initial"},
{name: "Alphabetical (ascending)", value: "definition.name"},
{name: "Alphabetical (descending)", value: "-definition.name"},
{name: "Creation order", value: "created_ms"},
@@ -571,7 +546,7 @@ function init() {
sortContent += "0";
break;
case "unsorted":
- sortContent += categoriesLength;
+ sortContent += missionScope.categoryContent.length;
break;
default:
sortContent += category;
@@ -588,13 +563,13 @@ function init() {
var generateMission = function(mission, id, selectedCategory) {
var missionState = mission.missionListState.toLowerCase();
- var newMissionCode = "
";
if (missionScope.getButton2Title(mission))
@@ -661,34 +636,62 @@ function init() {
newMissionCode += "
";
return newMissionCode;
}
+
var generateAllMissions = function() {
$(".missions-list").empty();
- if (categoriesLength == 0) {
+ if (missionScope.categoryContent.length == 0) {
$(".missions-list").addClass("row");
}
missionScope.sortCriteria = [];
w.$injector.invoke(function($compile) {
var missionContent = "";
- if (categoriesLength > 0) {
- //if there are user-defined categories, loop over them
+ if (missionScope.categoryContent.length > 0) {
+ //if there are user-defined categories, first sort the categorised/uncategorised missions
+ missionScope.categorisedMissions = [];
+ missionScope.uncategorisedMissions = angular.copy(missionScope.missions);
+
+ //loop through each category of GUIDs, and add actual missions to scope
+ missionScope.categoryContent.forEach(function(category) {
+ var catobj = [];
+ category.missions.forEach(function(guid) {
+ //TODO: Do this with filters, not loops
+ for (var i = 0; i < missionScope.uncategorisedMissions.length ; i++) {
+ //once the right mission is found, add position, push it to the holding array and remove from uncategorised
+ if (missionScope.uncategorisedMissions[i].mission_guid == guid) {
+ catobj.push(missionScope.uncategorisedMissions[i]);
+ missionScope.uncategorisedMissions.splice(i, 1);
+ break;
+ }
+ }
+ })
+ missionScope.categorisedMissions.push(catobj);
+ })
+
+ //then get the categories sorted
+ missionScope.categoryContent.forEach(function(category) {
+ if (category.sortCriteria != 'initial') {missionScope.categorisedMissions[category.id] = w.$filter("orderBy")(missionScope.categorisedMissions[category.id], category.sortCriteria);}
+ })
+ if (missionScope.uncategorisedSort != 'initial') {missionScope.uncategorisedMissions = w.$filter("orderBy")(missionScope.uncategorisedMissions, missionScope.uncategorisedSort);}
+
+ //once all the categorisation is done, create the HTML for the categories!
missionContent += "
";
- for (var i = 0; i < categoriesLength; i++) {
- missionContent += "
";
for (var i = 0; i < missionScope.missions.length; i++) {
var mission = missionScope.missions[i];
missionContent += generateMission(mission, i, false);
}
}
//modal for adding missions to categories
- missionContent += "
{{missionTitle}}
";
- missionContent += "
";
//modal for previewing missions
- missionContent += "
Preview Mission
";
- missionContent += "
";
- missionContent += "
";
+ missionContent += "
Preview Mission
"
+ + "
"
+ + "
";
// Pass our fragment content to $compile, and call the function that $compile returns with the scope.
var compiledContent = $compile(missionContent)(missionScope);
@@ -738,9 +740,36 @@ function init() {
});
}
+ missionScope.exportData = function() {
+ prompt("Copy this text and paste it into the textbox for Import Data", JSON.stringify(missionScope.categoryContent));
+ };
+
+ missionScope.importData = function() {
+ var dataInput = prompt("Please paste in the text you got from the Export Data popup");
+ if (dataInput == null || dataInput == "") {
+ //don't do anything
+ } else {
+ //try to parse data, then turn it into object
+ try {
+ missionScope.categoryContent = JSON.parse(dataInput);
+ w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent));
+ generateAllMissions();
+ } catch (e){
+ alert('Something went wrong!!');
+ }
+ }
+ }
+
//compiling the buttons
w.$injector.invoke(function($compile) {
var buttonContent = "
";
+
+ //button for adding categories
+ buttonContent += ""
+ + ""
+ + "";
+ //buttonContent += "";
+
//tally up available missions, and missions in draft states
var draftMissions = w.$filter('filter')(missionScope.missions, {missionListState: "DRAFT"}, true).length;
var dopMissions = w.$filter('filter')(missionScope.missions, {missionListState: "DRAFT_OF_PUBLISHED_MISSION"}, true).length;
@@ -748,7 +777,7 @@ function init() {
var sapMissions = w.$filter('filter')(missionScope.missions, {missionListState: "SUBMITTED_AND_PUBLISHED"}, true).length;
var publishedMissions = w.$filter('filter')(missionScope.missions, {missionListState: "PUBLISHED"}, true).length;
var remainder = 150 - (dopMissions + submittedMissions + sapMissions + publishedMissions);
- buttonContent += "
";
// Pass our fragment content to $compile, and call the function that $compile returns with the scope.
var compiledContent = $compile(buttonContent)(missionScope);
// Put the output of the compilation in to the page using jQuery
$('.list').prepend(compiledContent);
});
- $('.list .bordered-panel').append($('.list div:not(.bordered-panel) button.yellow.create-mission-button'));
+ $('.list .bordered-panel').prepend($('.list div:not(.bordered-panel) button.yellow.create-mission-button'));
//initiating the missions
$(".missions-list").removeClass("row").addClass('ready');