From c72e3dac694c1936de9e77d08d9a4976979bcf2c Mon Sep 17 00:00:00 2001
From: "Hartung, Michael" <michael.hartung@uni-hamburg.de>
Date: Tue, 13 Sep 2022 14:36:36 +0200
Subject: [PATCH] update prefixCss: deal with string comaprison and class cases
 divided by :

---
 prefixCSS.py                                  | 33 +++++++++++++++----
 src/app/components/toast/toast.component.html |  2 +-
 src/app/services/toast/toast.service.ts       |  2 +-
 src/stylesheets/theme-styles.scss             |  6 +++-
 4 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/prefixCSS.py b/prefixCSS.py
index 55ddd1b6..b6b5e712 100644
--- a/prefixCSS.py
+++ b/prefixCSS.py
@@ -5,6 +5,7 @@ import subprocess
 import argparse
 
 
+
 def find_nth(haystack, needle, n):
     start = haystack.find(needle)
     while start >= 0 and n > 1:
@@ -31,15 +32,26 @@ class ParserHTML:
     def prefixNgClassStrings(self, line, classStart):
         start = False
         classIndices = []
+        stringComparison = False
+        seenQuestionmark = False
         for i, c in enumerate(line[classStart:], classStart):
-            if c == "'":
+            if c == "'" and not stringComparison:
                 if not start:
                     classIndices.append(i+1)
                     start = True
                 else:
                     start = False
-            elif c == '}':
+            elif c == '}' or c =='"':
                 break
+            elif c == ':' and not seenQuestionmark:
+                stringComparison = True
+            elif c == ',':
+                stringComparison = False
+                seenQuestionmark = False
+            elif c == '?':
+                # if we see a ?, the following : does not implicate a string comparison but a case separation
+                seenQuestionmark = True
+            
         for i, start in enumerate(classIndices):
             start += i * len(self.PREFIX)
             line = line[:start] + self.PREFIX + line[start:]
@@ -105,17 +117,24 @@ class ParserHTML:
         newLines = []
         with open(path) as f:
             content = ''
-            iTagOpen = False
             # remove linebreaks in tags
+            stringOpen = False
             for line in f:
                 if not len(line.strip()):
                     continue
                 # line.count('"') % 2 --> opened but not closed like [ngClass]="
                 if line.count('"') % 2 and not line.strip().endswith('>'):
                     content += line.strip() + ' '
+                    stringOpen = not stringOpen
                 else:
-                    content += line + '\n'         
-
+                    if stringOpen:
+                        # no new line
+                        content += line.strip() + ' '
+                    else:
+                        # new line
+                        content += line + '\n'   
+                    
+            iTagOpen = False
             for line in content.split('\n'):
                 line = line.strip()
                 if '<i' in line:
@@ -174,12 +193,12 @@ class ParserJS:
     
     ELEMENTBYIDSTRING = 'document.getElementById('
     
-    def findIdPos(self, line):
+    def findId(self, line):
         start = line.find(self.ELEMENTBYIDSTRING) + len(self.ELEMENTBYIDSTRING)+1
         return start
 
     def replaceElementById(self, line):
-        start = self.findIdPos(line)
+        start = self.findId(line)
         line = line[:start] + self.PREFIX + line[start:]
         return line
     
diff --git a/src/app/components/toast/toast.component.html b/src/app/components/toast/toast.component.html
index d265f9db..f8f17fca 100644
--- a/src/app/components/toast/toast.component.html
+++ b/src/app/components/toast/toast.component.html
@@ -3,7 +3,7 @@
         <div class="toast {{getDrugstoneClass(toast.value.type)}}">
             <a (click)="close(toast.key)" aria-label="close" class="close">
                 <span class="icon" title="Close analysis">
-                    <i class="fas fa-times" aria-hidden="true"></i>
+                    <i class="fas fa-times toast-times" aria-hidden="true"></i>
                 </span>
             </a>
             <p>{{toast.value.message}}</p>
diff --git a/src/app/services/toast/toast.service.ts b/src/app/services/toast/toast.service.ts
index 7b79b48b..e53464e2 100644
--- a/src/app/services/toast/toast.service.ts
+++ b/src/app/services/toast/toast.service.ts
@@ -27,7 +27,7 @@ export class ToastService {
   public setTimer(id: number) {
     setTimeout(() => {
       this.deleteToast(id);
-    }, 10000);
+    }, 100000000);
   }
 
   public deleteToast(id: number) {
diff --git a/src/stylesheets/theme-styles.scss b/src/stylesheets/theme-styles.scss
index 62bdb4dc..1da0834c 100644
--- a/src/stylesheets/theme-styles.scss
+++ b/src/stylesheets/theme-styles.scss
@@ -200,7 +200,7 @@
   }
 
 
-  .fa-exclamation-triangle, .color-danger, .help, .delete:after, .delete:before, .modal-close:after, .modal-close:before {
+  .fa-exclamation-triangle, .fa-times, .color-danger, .help, .delete:after, .delete:before, .modal-close:after, .modal-close:before {
     color: var(--drgstn-danger) !important;
   }
 
@@ -289,6 +289,10 @@
   ::-webkit-scrollbar-button:increment {
     width: 0px !important;
   }
+  
+  .toast-times {
+    color: var(--drgstn-text-secondary) !important;
+  }
 }
 
 // scrolllbar styles
-- 
GitLab