active tags are now saved in a cookie

This commit is contained in:
Jack 2020-06-23 18:17:08 +01:00
parent b265e739fc
commit 1923cc61c9
4 changed files with 45 additions and 1 deletions

View file

@ -164,6 +164,7 @@ firebase.auth().onAuthStateChanged(function(user) {
accountIconLoading(false);
updateFilterTags();
updateCommandsTagsList();
loadActiveTagsFromCookie();
});
var displayName = user.displayName;
var email = user.email;

View file

@ -1405,6 +1405,9 @@ function hideBackgroundLoader(){
function updateTestModesNotice(){
let anim = false;
if($(".pageTest #testModesNotice").text() === "") anim = true;
$(".pageTest #testModesNotice").empty();
if(config.difficulty === "expert"){
@ -1438,6 +1441,14 @@ function updateTestModesNotice(){
}
if(anim){
$(".pageTest #testModesNotice").css('transition','none').css('opacity',0).animate({
opacity: 1
},125, (e) => {
$(".pageTest #testModesNotice").css('transition','.125s');
});
}
}

View file

@ -165,7 +165,7 @@ function showActiveTags(){
}
function toggleTag(tagid){
function toggleTag(tagid, nosave = false){
dbSnapshot.tags.forEach(tag => {
if(tag.id === tagid){
if(tag.active === undefined){
@ -176,6 +176,7 @@ function toggleTag(tagid){
}
})
updateTestModesNotice();
if(!nosave) saveActiveTagsToCookie();
}
//smooth caret

View file

@ -38,6 +38,28 @@ function saveConfigToCookie() {
restartCount = 0;
}
function saveActiveTagsToCookie(){
let tags = [];
try{
dbSnapshot.tags.forEach(tag => {
if(tag.active === true){
tags.push(tag.id);
}
})
let d = new Date();
d.setFullYear(d.getFullYear() + 1);
$.cookie("activeTags", null);
$.cookie("activeTags", JSON.stringify(tags), {
expires: d,
path: '/'
});
}catch(e){
}
}
function loadConfigFromCookie() {
let newConfig = $.cookie('config');
if (newConfig && newConfig != null && newConfig != "null") {
@ -75,6 +97,15 @@ function loadConfigFromCookie() {
saveConfigToCookie();
}
function loadActiveTagsFromCookie(){
let newTags = $.cookie('activeTags');
newTags = JSON.parse(newTags);
newTags.forEach(ntag => {
toggleTag(ntag, true);
})
saveActiveTagsToCookie();
}
function showTestConfig() {
$("#top .config").removeClass('hidden').css("opacity",1);
}