mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-21 07:46:15 +08:00
active tags are now saved in a cookie
This commit is contained in:
parent
b265e739fc
commit
1923cc61c9
|
@ -164,6 +164,7 @@ firebase.auth().onAuthStateChanged(function(user) {
|
|||
accountIconLoading(false);
|
||||
updateFilterTags();
|
||||
updateCommandsTagsList();
|
||||
loadActiveTagsFromCookie();
|
||||
});
|
||||
var displayName = user.displayName;
|
||||
var email = user.email;
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue