]> git.mdlowis.com Git - proto/journal.git/commitdiff
added logic to set title to today's date
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 30 Nov 2017 13:49:56 +0000 (08:49 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 30 Nov 2017 13:49:56 +0000 (08:49 -0500)
editor.js
index.html

index c89d1add143730cb76578f87ce4b47c539f30dcb..5be7118550a7bf2d904acf35bb91d91e55b671ba 100644 (file)
--- a/editor.js
+++ b/editor.js
         },
     };
 
+    const ymd_string = () => {
+        const date = new Date();
+        const month = date.getMonth() + 1;
+        const day = date.getDate();
+        return "" +
+            date.getFullYear() + "." +
+            (month > 9 ? '' : '0') + month + "." +
+            (day > 9 ? '' : '0') + day
+    };
+
+    header.onkeyup = (evnt) => {
+        document.title = header.innerText;
+    }
+
     content.onkeydown = (evnt) => {
         const keyfn = keys[evnt.key];
         return (keyfn ? keyfn(evnt) : true);
     }
+
+    /* set the title to todays date */
+    header.innerHTML = '<h1 align="center" contenteditable="true">'
+                     + ymd_string() + '</h1><hr/>';
+    document.title = header.innerText;
 })();
index 8e3c9b50ca94f64ebcd129517d1f98db6a2bb7fc..0e6f56b7c96f316714724a2f7b25a0ce54321f1b 100644 (file)
@@ -4,14 +4,13 @@
         <title>Journal</title>
         <meta charset="utf-8">
         <meta name="description" content="Journal">
-               <link rel="stylesheet" type="text/css" href="style.css">
+        <link rel="stylesheet" type="text/css" href="style.css">
     </head>
     <body>
         <section>
-            <header>
-                <h1 align="center">
-                    <span>2017.12.01</span>
-                    <span contenteditable="true"> - New Entry</span>
+            <header id="header">
+                <h1 align="center" contenteditable="true">
+                    2017.12.01
                 </h1>
                 <hr>
             </header>
                 <ol>
                     <li>foo</li>
                 </ol>
-                               <p>table:</p>
+                <p>table:</p>
                 <table>
-                       <thead>
-                               <tr>
-                               <th>Header 1</th>
-                               <th>Header 2</th>
-                               </tr>
-                       </thead>
-                       <tbody>
-                       <tr>
-                               <td>Cell 1</td>
-                               <td>Cell 2</td>
-                       </tr>
-                       </tbody>
+                    <thead>
+                        <tr>
+                            <th>Header 1</th>
+                            <th>Header 2</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        <tr>
+                            <td>Cell 1</td>
+                            <td>Cell 2</td>
+                        </tr>
+                    </tbody>
                 </table>
 
                 <p>code block:</p>