Fossil SCM
chat: removed an extraneous layer of DOM elements. CSS tweaks.
Commit
ce988f94077314f1c952fb92ac57b17fecf5b2a0fd198023a8eb4465c1aeaa48
Parent
ee53e449a5086a6…
1 file changed
+17
-10
+17
-10
| --- tools/chat.tcl | ||
| +++ tools/chat.tcl | ||
| @@ -58,24 +58,29 @@ | ||
| 58 | 58 | <hr> |
| 59 | 59 | <p> |
| 60 | 60 | <a href="chat/env">CGI environment</a> | |
| 61 | 61 | <a href="chat/self">Wapp script</a> |
| 62 | 62 | <style> |
| 63 | +.chat-message {/*style common to .chat-mx and .chat-ms*/ | |
| 64 | + padding: 0.5em; | |
| 65 | + border-radius: 0.5em; | |
| 66 | + border: 1px solid black; | |
| 67 | + box-shadow: 0.2em 0.2em 0.2em rgba(0, 0, 0, 0.29); | |
| 68 | + /* Bob Ross might approve of... */ | |
| 69 | + /* | |
| 70 | + background-image: linear-gradient(45deg, #FFC107 0%, #ff8b5f 100%); | |
| 71 | + border-bottom: solid 3px #c58668; | |
| 72 | + */ | |
| 73 | +} | |
| 63 | 74 | .chat-mx { |
| 64 | 75 | float: left; |
| 65 | 76 | margin-right: 3em; |
| 66 | - padding: 0.5em; | |
| 67 | - border-radius: 1em; | |
| 68 | - border: 1px solid black; | |
| 69 | 77 | } |
| 70 | 78 | .chat-ms { |
| 71 | 79 | float: right; |
| 72 | 80 | margin-left: 3em; |
| 73 | - padding: 0.5em; | |
| 74 | - border-radius: 1em; | |
| 75 | 81 | background-color: #d2dde1; |
| 76 | - border: 1px solid black; | |
| 77 | 82 | } |
| 78 | 83 | \#dialog { |
| 79 | 84 | width: 97%; |
| 80 | 85 | } |
| 81 | 86 | \#chat-input-area { |
| @@ -136,11 +141,13 @@ | ||
| 136 | 141 | const rxUrl = /\\b(?:https?|ftp):\\/\\/\[a-z0-9-+&@\#\\/%?=~_|!:,.;]*\[a-z0-9-+&@\#\\/%=~_|]/gim; |
| 137 | 142 | const rxAtName = /@\\w+/gmi; |
| 138 | 143 | // ^^^ achtung, extra backslashes needed for the outer TCL. |
| 139 | 144 | // Converts a message string to a message-containing DOM element |
| 140 | 145 | // and returns that element, which may contain child elements. |
| 141 | - const messageToDOM = function f(str){ | |
| 146 | + // If 2nd arg is passed, it must be a DOM element to which all | |
| 147 | + // child elements are appended. | |
| 148 | + const messageToDOM = function f(str, tgtElem){ | |
| 142 | 149 | "use strict"; |
| 143 | 150 | if(!f.rxUrl){ |
| 144 | 151 | f.rxUrl = rxUrl; |
| 145 | 152 | f.rxAt = rxAtName; |
| 146 | 153 | f.rxNS = /\\S/; |
| @@ -198,11 +205,11 @@ | ||
| 198 | 205 | } |
| 199 | 206 | //console.debug("accum2 =",accum2); |
| 200 | 207 | }); |
| 201 | 208 | delete f.accum; |
| 202 | 209 | //console.debug("accum2 =",accum2); |
| 203 | - const span = f.ce('span'); | |
| 210 | + const span = tgtElem || f.ce('span'); | |
| 204 | 211 | accum2.forEach(function(e){ |
| 205 | 212 | if('string'===typeof e) e = f.ct(e); |
| 206 | 213 | span.appendChild(e); |
| 207 | 214 | }); |
| 208 | 215 | //console.debug("span =",span.innerHTML); |
| @@ -239,12 +246,12 @@ | ||
| 239 | 246 | } |
| 240 | 247 | let br = document.createElement("br"); |
| 241 | 248 | br.style.clear = "both"; |
| 242 | 249 | span.appendChild(br); |
| 243 | 250 | } |
| 244 | - const dmsg = messageToDOM(m.xmsg || "??empty??"); | |
| 245 | - span.appendChild(dmsg); | |
| 251 | + messageToDOM(m.xmsg || "??empty??", span); | |
| 252 | + span.classList.add('chat-message'); | |
| 246 | 253 | if( m.xfrom!=_me ){ |
| 247 | 254 | span.classList.add('chat-mx'); |
| 248 | 255 | }else{ |
| 249 | 256 | span.classList.add('chat-ms'); |
| 250 | 257 | } |
| 251 | 258 |
| --- tools/chat.tcl | |
| +++ tools/chat.tcl | |
| @@ -58,24 +58,29 @@ | |
| 58 | <hr> |
| 59 | <p> |
| 60 | <a href="chat/env">CGI environment</a> | |
| 61 | <a href="chat/self">Wapp script</a> |
| 62 | <style> |
| 63 | .chat-mx { |
| 64 | float: left; |
| 65 | margin-right: 3em; |
| 66 | padding: 0.5em; |
| 67 | border-radius: 1em; |
| 68 | border: 1px solid black; |
| 69 | } |
| 70 | .chat-ms { |
| 71 | float: right; |
| 72 | margin-left: 3em; |
| 73 | padding: 0.5em; |
| 74 | border-radius: 1em; |
| 75 | background-color: #d2dde1; |
| 76 | border: 1px solid black; |
| 77 | } |
| 78 | \#dialog { |
| 79 | width: 97%; |
| 80 | } |
| 81 | \#chat-input-area { |
| @@ -136,11 +141,13 @@ | |
| 136 | const rxUrl = /\\b(?:https?|ftp):\\/\\/\[a-z0-9-+&@\#\\/%?=~_|!:,.;]*\[a-z0-9-+&@\#\\/%=~_|]/gim; |
| 137 | const rxAtName = /@\\w+/gmi; |
| 138 | // ^^^ achtung, extra backslashes needed for the outer TCL. |
| 139 | // Converts a message string to a message-containing DOM element |
| 140 | // and returns that element, which may contain child elements. |
| 141 | const messageToDOM = function f(str){ |
| 142 | "use strict"; |
| 143 | if(!f.rxUrl){ |
| 144 | f.rxUrl = rxUrl; |
| 145 | f.rxAt = rxAtName; |
| 146 | f.rxNS = /\\S/; |
| @@ -198,11 +205,11 @@ | |
| 198 | } |
| 199 | //console.debug("accum2 =",accum2); |
| 200 | }); |
| 201 | delete f.accum; |
| 202 | //console.debug("accum2 =",accum2); |
| 203 | const span = f.ce('span'); |
| 204 | accum2.forEach(function(e){ |
| 205 | if('string'===typeof e) e = f.ct(e); |
| 206 | span.appendChild(e); |
| 207 | }); |
| 208 | //console.debug("span =",span.innerHTML); |
| @@ -239,12 +246,12 @@ | |
| 239 | } |
| 240 | let br = document.createElement("br"); |
| 241 | br.style.clear = "both"; |
| 242 | span.appendChild(br); |
| 243 | } |
| 244 | const dmsg = messageToDOM(m.xmsg || "??empty??"); |
| 245 | span.appendChild(dmsg); |
| 246 | if( m.xfrom!=_me ){ |
| 247 | span.classList.add('chat-mx'); |
| 248 | }else{ |
| 249 | span.classList.add('chat-ms'); |
| 250 | } |
| 251 |
| --- tools/chat.tcl | |
| +++ tools/chat.tcl | |
| @@ -58,24 +58,29 @@ | |
| 58 | <hr> |
| 59 | <p> |
| 60 | <a href="chat/env">CGI environment</a> | |
| 61 | <a href="chat/self">Wapp script</a> |
| 62 | <style> |
| 63 | .chat-message {/*style common to .chat-mx and .chat-ms*/ |
| 64 | padding: 0.5em; |
| 65 | border-radius: 0.5em; |
| 66 | border: 1px solid black; |
| 67 | box-shadow: 0.2em 0.2em 0.2em rgba(0, 0, 0, 0.29); |
| 68 | /* Bob Ross might approve of... */ |
| 69 | /* |
| 70 | background-image: linear-gradient(45deg, #FFC107 0%, #ff8b5f 100%); |
| 71 | border-bottom: solid 3px #c58668; |
| 72 | */ |
| 73 | } |
| 74 | .chat-mx { |
| 75 | float: left; |
| 76 | margin-right: 3em; |
| 77 | } |
| 78 | .chat-ms { |
| 79 | float: right; |
| 80 | margin-left: 3em; |
| 81 | background-color: #d2dde1; |
| 82 | } |
| 83 | \#dialog { |
| 84 | width: 97%; |
| 85 | } |
| 86 | \#chat-input-area { |
| @@ -136,11 +141,13 @@ | |
| 141 | const rxUrl = /\\b(?:https?|ftp):\\/\\/\[a-z0-9-+&@\#\\/%?=~_|!:,.;]*\[a-z0-9-+&@\#\\/%=~_|]/gim; |
| 142 | const rxAtName = /@\\w+/gmi; |
| 143 | // ^^^ achtung, extra backslashes needed for the outer TCL. |
| 144 | // Converts a message string to a message-containing DOM element |
| 145 | // and returns that element, which may contain child elements. |
| 146 | // If 2nd arg is passed, it must be a DOM element to which all |
| 147 | // child elements are appended. |
| 148 | const messageToDOM = function f(str, tgtElem){ |
| 149 | "use strict"; |
| 150 | if(!f.rxUrl){ |
| 151 | f.rxUrl = rxUrl; |
| 152 | f.rxAt = rxAtName; |
| 153 | f.rxNS = /\\S/; |
| @@ -198,11 +205,11 @@ | |
| 205 | } |
| 206 | //console.debug("accum2 =",accum2); |
| 207 | }); |
| 208 | delete f.accum; |
| 209 | //console.debug("accum2 =",accum2); |
| 210 | const span = tgtElem || f.ce('span'); |
| 211 | accum2.forEach(function(e){ |
| 212 | if('string'===typeof e) e = f.ct(e); |
| 213 | span.appendChild(e); |
| 214 | }); |
| 215 | //console.debug("span =",span.innerHTML); |
| @@ -239,12 +246,12 @@ | |
| 246 | } |
| 247 | let br = document.createElement("br"); |
| 248 | br.style.clear = "both"; |
| 249 | span.appendChild(br); |
| 250 | } |
| 251 | messageToDOM(m.xmsg || "??empty??", span); |
| 252 | span.classList.add('chat-message'); |
| 253 | if( m.xfrom!=_me ){ |
| 254 | span.classList.add('chat-mx'); |
| 255 | }else{ |
| 256 | span.classList.add('chat-ms'); |
| 257 | } |
| 258 |