Loquicom 5 years ago
parent
commit
e89a70c3b3
2 changed files with 16 additions and 14 deletions
  1. 15 13
      src/index.html
  2. 1 1
      src/js/script.js

+ 15 - 13
src/index.html

@@ -74,7 +74,7 @@
     <div class="tap-target" data-target="float-add-btn">
         <div class="tap-target-content">
             <h5>Ajouter une note</h5>
-            <p>Pour ajouter une note il suffit de cliquer sur ce bouton<br>(pour faire disparaitre cette information cliquez sur le bouton)</p>
+            <p>Pour ajouter une note il suffit de cliquer sur ce bouton<br>(cliquez pour faire disparaitre)</p>
         </div>
     </div>
 
@@ -111,19 +111,20 @@
                 printContent(scope);
                 // Show page
                 setTimeout(() => {
-                    pageLoader(false);
-                }, 1000);   
+                    pageLoader(false);  
+                    //Show discovery the first time
+                    if (!getCookie('discovery')) {
+                        // Load discovery
+                        const discovery = M.TapTarget.init(document.querySelectorAll('.tap-target'), {onClose: () => {
+                            document.cookie = "discovery=closed";
+                        }})[0];
+                        setTimeout(() => {discovery.open();}, 500);
+                    } 
+                }, 500);   
             });
 
             // Load floating button
             const floatingButton = M.FloatingActionButton.init(document.querySelectorAll('.fixed-action-btn'))[0];
-            // Load discovery
-            const discovery = M.TapTarget.init(document.querySelectorAll('.tap-target'), {onClose: () => {
-                document.cookie = "discovery=closed";
-            }})[0];
-            if (!getCookie('discovery')) {
-                discovery.open();
-            }    
             // Load modal
             modal = M.Modal.init(document.querySelectorAll('.modal'))[0];
         });
@@ -138,7 +139,8 @@
             return new Promise(resolve => {
                 // Load from local storage
                 if (localStorage.list) {
-                    for (element of localStorage.list) {
+                    const list = JSON.parse(localStorage.list)
+                    for (element of list) {
                         toArray ? data.push(localStorage[element]) : data[element] = localStorage[element];
                     }
                 } else {
@@ -162,7 +164,7 @@
 
         function printContent(scope) {
             for(element of scope.card) {
-                element.content = element.content.toMarkdown();
+                element.content = element.content.toHTML();
             }
             looper(scope);
             PR.prettyPrint();
@@ -182,7 +184,7 @@
             const id = idElement.innerHTML;
             promise.then(data => {
                 $('#modal-title').html(data[id].title);
-                $('#modal-content').html(data[id].content.toMarkdown())
+                $('#modal-content').html(data[id].content.toHTML())
                 $('#modal-delete').attr('data-id', id);
                 PR.prettyPrint();
                 modal.open();

+ 1 - 1
src/js/script.js

@@ -1,7 +1,7 @@
 /**
  * Transform markdown string to html 
  */
-String.prototype.toMarkdown = function() {
+String.prototype.toHTML = function() {
     return DOMPurify.sanitize(marked(this.toString()).replace(/<code>/g, '<pre class="prettyprint">').replace(/<\/code>/g, '</pre>'));
 }