]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Regex for bolding title markup replctm. on edit.
authorWill Budicm <redacted>
Sun, 27 Dec 2020 19:32:10 +0000 (06:32 +1100)
committerWill Budicm <redacted>
Sun, 27 Dec 2020 19:32:10 +0000 (06:32 +1100)
htdocs/cgi-bin/wsrc/main.js

index caccf68ce1bf3fc1580b2d0641e71e06f1f6d6e4..ef7b1f5a559a66a277883196b4ff999d9f1479f8 100644 (file)
@@ -321,7 +321,7 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) {
             var chk = $(e.target).find('input[name="chk"]');
             var tr = e.target.parentNode.closest("tr");
             if(tr.id != "summary_row" && tr.id !="brw_row"){
-                if(!CHK_PREV.prop('checked')){        
+                if(CHK_PREV && !CHK_PREV.prop('checked')){        
                     CHK_PREV.closest("tr").removeClass("hover");
                 }
                 $(e.target.parentNode).closest("tr").addClass("hover");
@@ -474,10 +474,20 @@ function decodeToHTMLText(txt) {
     return txt;
 }
 
+var BOLD_MATCH = /(?<o>^\<b\>)(?<title>.+)(?<c>\<\/b\>)\s+(?<text>.*)/gi;
 function decodeToText(txt) {
     //bug 7 fix
     txt = txt.replace(/<hr>.*RTF<\/button>/gm, "");
     txt = txt.replace(/<br\s*[\/]?>/gi, "\n");
+    //If first line bolded
+    
+    let res = txt.matchAll(BOLD_MATCH);
+    if(res){
+        for(let r of res) { //WB: In a loop? JS can be weird, nested iter...
+            let {o, title, close, text} = r.groups;
+            txt = "*" + title + "*\n" + text;
+        }//
+    }
     return txt;
 }