From 88d1c0fb37c968b2c46edd9c0f12f45628c3bb9d Mon Sep 17 00:00:00 2001 From: DanielOndiordna <80363737+DanielOndiordna@users.noreply.github.com> Date: Tue, 21 Sep 2021 21:53:38 +0200 Subject: [PATCH] 6 missions per row Changed border size to 100% width and fit 6 missions per row. Also changed "Add to Category" to "Move to Category", and changed "Remove from Category" to "Move to Unsorted Missions" --- IMATTC.user.js | 58 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/IMATTC.user.js b/IMATTC.user.js index 06d5f29..65e1b1f 100644 --- a/IMATTC.user.js +++ b/IMATTC.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name IMATTC -// @version 1.8.0 +// @version 1.8.1 // @description A usability overhaul for the Ingress Mission Authoring Tool -// @author @Chyld314 +// @author @Chyld314 @DanielOndiordna // @match https://mission-author-dot-betaspike.appspot.com/ // @match https://mission-author-dot-betaspike.appspot.com/edit* // @match http://missions.ingress.com/ @@ -105,6 +105,9 @@ $(function() { + ".mission-list-item-submitted_and_published .button:hover {background-color: #4d6619;}" + ".mission-list-item-submitted_and_published .button .caret {border-bottom-color: springgreen;}"; + newCssRules += ".col-md-3 { width: 16.6%; }" + + ".container { width: 100%; }"; + newCssRules += ".dropup {position: relative;}" + ".dropup .dropdown-menu {top: initial; bottom: 30px; left: 0; right: 0; text-align: center;}" + ".dropdown-menu > li > a {cursor: pointer;}" @@ -224,6 +227,25 @@ function init() { //$('body').css('margin-top','0'); }; + function storeCategoryContent(categoryContent) { + let activeuser = $('.navbar-login a').first().text().trim(); // expect username here + w.localStorage.setItem('allCategories_' + activeuser, JSON.stringify(categoryContent)); + } + function restoreCategoryContent() { + if (w.localStorage.getItem('allCategories')) { // convert old storage to new storage per user + let categoryContentJSON = JSON.parse(w.localStorage.getItem('allCategories')) || []; + storeCategoryContent(categoryContentJSON); + w.localStorage.removeItem('allCategories'); + return categoryContentJSON; + } + let activeuser = $('.navbar-login a').first().text().trim(); // expect username here + return JSON.parse(w.localStorage.getItem('allCategories_' + activeuser)) || []; + } + function removeCategoryContent() { + let activeuser = $('.navbar-login a').first().text().trim(); // expect username here + w.localStorage.removeItem('allCategories_' + activeuser); + } + function missionEditSetup(editScope) { var editStep = editScope.mission.ui.view; @@ -244,7 +266,7 @@ function init() { editScope.categoryContent[editScope.selectedCategoryID].missions.push(editScope.savedWireMission.mission_guid); editScope.categoryContent[editScope.selectedCategoryID].collapse = false; editScope.selectedCategoryID = null; - w.localStorage.setItem('allCategories', JSON.stringify(editScope.categoryContent)); + storeCategoryContent(editScope.categoryContent); } w.$location.url("/") }).error(function(b) { @@ -347,7 +369,7 @@ function init() { break; case editScope.EditorScreenViews.PREVIEW: //If there are user generated categories, add a dropdown to add the new mission to one - editScope.categoryContent = JSON.parse(w.localStorage.getItem('allCategories')) || []; + editScope.categoryContent = restoreCategoryContent(); if (editScope.categoryContent.length > 0 && editScope.mission.mission_guid){ var showCategory = true; editScope.categoryContent.forEach(function(category){ @@ -426,7 +448,7 @@ function init() { missionScope.uncategorisedSort = 'initial'; missionScope.missions = w.$filter("orderBy")(missionScope.missions, 'definition.name'); missionScope.loadingPreview = false; - missionScope.unsortedCollapse = {collapse: w.localStorage.getItem('unsortedCollapse') || true}; + missionScope.unsortedCollapse = {collapse: JSON.parse(w.localStorage.getItem('unsortedCollapse') || true)}; //handling for legacy data format if (!!w.localStorage.getItem('categoryNames')){ @@ -445,7 +467,7 @@ function init() { missionScope.categoryContent.push(thisCategory); w.localStorage.removeItem('categoryContent' + i); } - w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent)); + storeCategoryContent(missionScope.categoryContent); //now tidy up the legacy data w.localStorage.removeItem('categoryNames'); @@ -453,7 +475,7 @@ function init() { } //get data for all categories - missionScope.categoryContent = JSON.parse(w.localStorage.getItem('allCategories')) || []; + missionScope.categoryContent = restoreCategoryContent(); missionScope.selectedCategoryMissionId = null; //Add position in initial array @@ -586,7 +608,7 @@ function init() { missionScope.categoryContent[categoryID].collapse = false; missionScope.selectedCategoryMissionId = null; missionScope.selectedCategoryID = null; - w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent)); + storeCategoryContent(missionScope.categoryContent); generateAllMissions(); } @@ -596,7 +618,7 @@ function init() { missionScope.categoryContent[category].missions.splice(i, 1); } } - w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent)); + storeCategoryContent(missionScope.categoryContent); generateAllMissions(); } @@ -614,14 +636,14 @@ function init() { sortCriteria: 'initial' }; missionScope.categoryContent.push(newCategory); - w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent)); + storeCategoryContent(missionScope.categoryContent); generateAllMissions(); } } missionScope.nukeCategories = function() { missionScope.categoryContent = []; - w.localStorage.setItem('allCategories', null); + removeCategoryContent(); generateAllMissions(); } @@ -629,7 +651,7 @@ function init() { 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.")) { //nuke localStorage category missionScope.categoryContent.splice(category, 1); - w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent)); + storeCategoryContent(missionScope.categoryContent); generateAllMissions(); } } @@ -648,7 +670,7 @@ function init() { missionScope.toggleCollapse = function(collapse, unsorted){ collapse.collapse = !collapse.collapse; unsorted ? w.localStorage.setItem('unsortedCollapse', collapse.collapse) - : w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent)); + : storeCategoryContent(missionScope.categoryContent); } missionScope.dragMissions = function(start_pos, start_cat, end_pos, end_cat) { @@ -686,7 +708,7 @@ function init() { } //then regenerate everything - w.localStorage.setItem('allCategories', JSON.stringify(missionScope.categoryContent)); + storeCategoryContent(missionScope.categoryContent); generateAllMissions(); } @@ -771,10 +793,10 @@ function init() { } if (selectedCategory === false) { //adding unsorted mission to category - newMissionCode += "