From b265e739fc918f8a49c0e5152dd2dd65047b42e2 Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 23 Jun 2020 17:46:18 +0100 Subject: [PATCH] tags can now be toggled through the command line --- public/css/style.scss | 3 ++ public/js/account.js | 1 + public/js/commandline.js | 66 ++++++++++++++++++++++++++++++++++++++-- public/js/script.js | 10 +++--- 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/public/css/style.scss b/public/css/style.scss index f0a4f714f..8f2752471 100644 --- a/public/css/style.scss +++ b/public/css/style.scss @@ -274,6 +274,9 @@ a:hover { font-size: 0.75rem; line-height: 0.75rem; color: var(--sub-color); + .fas{ + margin-right: .5rem; + } &:last-child{ border-radius: 0 0 var(--roundness) var(--roundness); } diff --git a/public/js/account.js b/public/js/account.js index 7f673d0fd..f0c7ac57c 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -163,6 +163,7 @@ firebase.auth().onAuthStateChanged(function(user) { console.log('DB snapshot ready'); accountIconLoading(false); updateFilterTags(); + updateCommandsTagsList(); }); var displayName = user.displayName; var email = user.email; diff --git a/public/js/commandline.js b/public/js/commandline.js index 0ae9ad4a1..811f2c4a0 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -13,6 +13,17 @@ let commands = { restartTest(); } }, + { + visible: false, + id: "changeTags", + display: "Change tags...", + subgroup: true, + exec: () => { + updateCommandsTagsList(); + currentCommands.push(commandsTags); + showCommandLine(); + } + }, { id: "toggleSmoothCaret", display: "Toggle smooth caret", @@ -426,6 +437,51 @@ let commandsFontSize = { ] }; +let commandsTags = { + title: "Change tags...", + list: [ + + ] +}; + +function updateCommandsTagsList(){ + if(dbSnapshot.tags.length > 0){ + commandsTags.list = []; + dbSnapshot.tags.forEach(tag => { + + let dis = tag.name; + + if(tag.active === true){ + dis = '' + dis; + }else{ + dis = '' + dis; + } + + + commandsTags.list.push({ + id: "toggleTag" + tag.id, + display: dis, + sticky: true, + exec: () => { + toggleTag(tag.id); + updateTestModesNotice(); + let txt = tag.name; + + + + if(tag.active === true){ + txt = '' + txt; + }else{ + txt = '' + txt; + } + $(`#commandLine .suggestions .entry[command='toggleTag${tag.id}']`).html(txt); + } + }) + }) + commands.list[1].visible = true; + } +} + let themesList; $.getJSON("themes/list.json", function(data) { @@ -644,6 +700,7 @@ function triggerCommand(command){ let subgroup = false; let input = false; let list = currentCommands[currentCommands.length-1]; + let sticky = false; $.each(list.list, (i, obj) => { if (obj.id == command) { if (obj.input) { @@ -654,10 +711,13 @@ function triggerCommand(command){ if (obj.subgroup !== null && obj.subgroup !== undefined) { subgroup = obj.subgroup; } + if(obj.sticky === true){ + sticky = true; + } } } }); - if (!subgroup && !input) { + if (!subgroup && !input && !sticky) { try{ firebase.analytics().logEvent('usedCommandLine', { command: command @@ -721,7 +781,7 @@ function hideCommandLine() { let list = currentCommands[currentCommands.length-1]; if (inputVal[0] == "") { $.each(list.list, (index, obj) => { - obj.found = true; + if(obj.visible !== false) obj.found = true; }); } else { $.each(list.list, (index, obj) => { @@ -737,7 +797,7 @@ function hideCommandLine() { } }); if (foundcount > 0) { - obj.found = true; + if(obj.visible !== false) obj.found = true; } else { obj.found = false; } diff --git a/public/js/script.js b/public/js/script.js index a9ef725a1..a2f81cc93 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -874,12 +874,12 @@ function showResult(difficultyFailed = false) { } let tagsText = ""; - activeTags.forEach(tagid => { - dbSnapshot.tags.forEach(snaptag => { - if(tagid === snaptag.id){ - tagsText += "
"+snaptag.name; + dbSnapshot.tags.forEach(tag => { + // dbSnapshot.tags.forEach(snaptag => { + if(tag.active === true){ + tagsText += "
"+tag.name; } - }) + // }) }) if(tagsText == ""){