@@ -671,8 +661,8 @@
incorrect chars |
mode |
-
difficulty |
-
language |
+
info |
+
tags |
date |
diff --git a/public/js/account.js b/public/js/account.js
index a12495a93..f5a0652bc 100644
--- a/public/js/account.js
+++ b/public/js/account.js
@@ -165,6 +165,12 @@ firebase.auth().onAuthStateChanged(function(user) {
updateFilterTags();
updateCommandsTagsList();
loadActiveTagsFromCookie();
+ updateResultEditTagsPanelButtons();
+ config.resultFilters.forEach(filter => {
+ if(filter.substring(0,4) === "tag_" && filter !== "tag_notag"){
+ toggleFilterButton(filter);
+ }
+ })
});
var displayName = user.displayName;
var email = user.email;
@@ -483,6 +489,53 @@ function loadMoreLines(){
if (raw == undefined){
raw = '-';
}
+
+
+ let icons = `
`;
+
+ if(diff === 'normal'){
+ icons += `
`;
+ }else if(diff === "expert"){
+ icons += `
`;
+ }else if(diff === "master"){
+ icons += `
`;
+ }
+
+ if(result.punctuation){
+ icons += `
`;
+ }
+
+ if(result.blindMode){
+ icons += `
`;
+ }
+
+ let tagNames = "";
+
+ if(result.tags !== undefined && result.tags.length > 0){
+ result.tags.forEach(tag => {
+ dbSnapshot.tags.forEach(snaptag => {
+ if(tag === snaptag.id){
+ tagNames += snaptag.name + ", ";
+ }
+ })
+ })
+ tagNames = tagNames.substring(0, tagNames.length - 2);
+ }
+
+ // if(tagNames !== ""){
+ // icons += `
`;
+ // }
+
+ let tagIcons = `
`;
+
+ if(tagNames !== ""){
+ if(result.tags !== undefined && result.tags.length > 1){
+ tagIcons = `
`;
+ }else{
+ tagIcons = `
`;
+ }
+ }
+
$(".pageAccount .history table tbody").append(`
@@ -492,8 +545,8 @@ function loadMoreLines(){
${result.correctChars} |
${result.incorrectChars} |
${result.mode} ${result.mode2}${withpunc} |
- ${diff} |
- ${result.language.replace('_',' ')} |
+ ${icons} |
+ ${tagIcons} |
${moment(result.timestamp).format('DD MMM YYYY HH:mm')} |
`);
}
@@ -806,3 +859,102 @@ function refreshAccountPage() {
cont();
}
}
+
+
+function showResultEditTagsPanel(){
+ if ($("#resultEditTagsPanelWrapper").hasClass("hidden")) {
+ $("#resultEditTagsPanelWrapper")
+ .stop(true, true)
+ .css("opacity", 0)
+ .removeClass("hidden")
+ .animate({opacity: 1},125);
+ }
+}
+
+function hideResultEditTagsPanel(){
+ if (!$("#resultEditTagsPanelWrapper").hasClass("hidden")) {
+ $("#resultEditTagsPanelWrapper")
+ .stop(true, true)
+ .css("opacity", 1)
+ .animate(
+ {
+ opacity: 0
+ },100,e => {
+ $("#resultEditTagsPanelWrapper").addClass('hidden');
+ });
+ }
+}
+
+$(document).on('click','.pageAccount .group.history #resultEditTags',f => {
+ let resultid = $(f.target).parents('span').attr('resultid');
+ let tags = $(f.target).parents('span').attr('tags');
+ $("#resultEditTagsPanel").attr('resultid',resultid);
+ $("#resultEditTagsPanel").attr('tags',tags);
+ updateActiveResultEditTagsPanelButtons(JSON.parse(tags));
+ showResultEditTagsPanel();
+})
+
+$(document).on('click','#resultEditTagsPanelWrapper .button.tag',f => {
+ $(f.target).toggleClass('active');
+})
+
+$("#resultEditTagsPanelWrapper").click(e => {
+ if($(e.target).attr('id') === "resultEditTagsPanelWrapper"){
+ hideResultEditTagsPanel();
+ }
+})
+
+function updateResultEditTagsPanelButtons(){
+ $("#resultEditTagsPanel .buttons").empty();
+ dbSnapshot.tags.forEach(tag => {
+ $("#resultEditTagsPanel .buttons").append(`
${tag.name}
`);
+ })
+}
+
+function updateActiveResultEditTagsPanelButtons(active){
+ if(active === []) return;
+ $.each($("#resultEditTagsPanel .buttons .button"), (index,obj) => {
+ let tagid = $(obj).attr('tagid');
+ if(active.includes(tagid)){
+ $(obj).addClass('active');
+ }else{
+ $(obj).removeClass('active');
+ }
+ // active.forEach(activetagid => {
+ // if(activetagid === tagid){
+ // $(obj).addClass('active');
+ // }else{
+ // $(obj).removeClass('active');
+ // }
+ // })
+ });
+}
+
+$("#resultEditTagsPanel .confirmButton").click(f => {
+ let resultid = $("#resultEditTagsPanel").attr('resultid');
+ let oldtags = JSON.parse($("#resultEditTagsPanel").attr('tags'));
+
+ let newtags = [];
+ $.each($("#resultEditTagsPanel .buttons .button"), (index,obj) => {
+ let tagid = $(obj).attr('tagid');
+ if($(obj).hasClass('active')){
+ newtags.push(tagid);
+ }
+ });
+ showBackgroundLoader();
+ hideResultEditTagsPanel();
+ updateResultTags({uid:firebase.auth().currentUser.uid,tags:newtags,resultid:resultid}).then(r=>{
+ hideBackgroundLoader();
+ if(r.data.resultCode === 1){
+ showNotification('Tags updated',1000);
+ dbSnapshot.results.forEach(result => {
+ if(result.id === resultid){
+ result.tags = newtags;
+ }
+ })
+ refreshAccountPage();
+ }else{
+ showNotification('Error updating tags',3000);
+ }
+ });
+})
\ No newline at end of file
diff --git a/public/js/script.js b/public/js/script.js
index 60715139a..d38742ce9 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -34,7 +34,7 @@ const testCompleted = firebase.functions().httpsCallable('testCompleted');
const addTag = firebase.functions().httpsCallable('addTag');
const editTag = firebase.functions().httpsCallable('editTag');
const removeTag = firebase.functions().httpsCallable('removeTag');
-
+const updateResultTags = firebase.functions().httpsCallable('updateResultTags');
function showNotification(text, time) {
let noti = $(".notification");