Просмотр исходного кода

Bug fix

In Trello: "In a given added idea, if the user adds an idea with two different tag terms, only the first one will be assigned a tag"
Unknown 7 лет назад
Родитель
Сommit
1b8496754e
1 измененных файлов с 35 добавлено и 3 удалено
  1. 35 3
      canvas/js/canvas.js

+ 35 - 3
canvas/js/canvas.js

@@ -335,12 +335,44 @@ $(document).ready(function() {
          */
         window.setTimeout(function() {
             // Declarations
+            var loopCounter = 0;
             var text;
             
             // For every added item
             $("li.added_item .expandable").each(function() {            
                 // Declarations
+                text = $(this).text();
                 
+                // For every tag in the database that belongs to the active user
+                for(t in tags) {
+                    console.log(loopCounter);
+                    // If the current tag exists in the textarea
+                    if(text.indexOf(tags[loopCounter]) != -1) {
+                        // While loop here if we want to apply the tag for every instance of a given term (j49b3e4a)
+                        
+                        // Apply the tag
+                        text = text.replace(tags[loopCounter], "<a class='tag' contenteditable='false'>" + tags[loopCounter] + "</a>");
+                    }
+                    
+                    loopCounter++;
+                }
+                
+                $(this).html(text);
+            });
+            
+            // Show the tag window on tag click
+            showTagWindowOnTagClick();
+        }, 100);
+        
+        /*
+        window.setTimeout(function() {
+            // Declarations
+            var text;
+            
+            // For every added item
+            // $("li.added_item textarea").each(function() {
+            $("li.added_item div").each(function() {            
+                // Declarations
                 var loopCounter = 0;
                 
                 // For every tag in the database that belongs to the active user
@@ -349,7 +381,7 @@ $(document).ready(function() {
                     
                     // If the current tag exists in the textarea
                     if(text.indexOf(tags[loopCounter]) != -1) {
-                        // While loop here if we want to apply the tag for every instance of a given term (j49b3e4a)
+                        // While loop here if we want to apply the tag for every instance of a given term
                         
                         // Apply the tag
                         text = text.replace(tags[loopCounter], "<a class='tag' contenteditable='false'>" + tags[loopCounter] + "</a>");
@@ -363,10 +395,10 @@ $(document).ready(function() {
             // Show the tag window on tag click
             showTagWindowOnTagClick();
         }, 100);
+         */
         
         // Populate "Saved Tags"
-        loopCounter = 0;
-        
+        var loopCounter = 0;
         var savedTags = $("div.saved-tags p");
         
         savedTags.html("");