Fossil SCM
Basic /chat search is working, but it's missing the load-more-context buttons and appropriate timestamps. Checking in for purposes of dogfooding it on my server.
Commit
7561498cf78d1640497a795a2d3809d8c6ea851a14f5558a4673187e27b208ee
Parent
7f745aa647fa6b0…
2 files changed
+25
-2
+1
+25
-2
| --- src/fossil.page.chat.js | ||
| +++ src/fossil.page.chat.js | ||
| @@ -2171,15 +2171,38 @@ | ||
| 2171 | 2171 | Submits a history search using the main input field's current |
| 2172 | 2172 | text. It is assumed that Chat.e.viewSearch===Chat.e.currentView. |
| 2173 | 2173 | */ |
| 2174 | 2174 | Chat.submitSearch = function(){ |
| 2175 | 2175 | const term = this.inputValue(true); |
| 2176 | - const eMWC = D.clearElement( | |
| 2176 | + const eMsgTgt = D.clearElement( | |
| 2177 | 2177 | this.e.viewSearch.querySelector('.message-widget-content') |
| 2178 | 2178 | ); |
| 2179 | 2179 | if( !term ) return; |
| 2180 | - D.append(eMWC, "TODO: search term = ", term); | |
| 2180 | + D.append(eMsgTgt, "TODO: search term = ", term); | |
| 2181 | + F.fetch( | |
| 2182 | + "chat-query", { | |
| 2183 | + urlParams: {q: term}, | |
| 2184 | + responseType: 'json', | |
| 2185 | + onload:function(jx){ | |
| 2186 | + let prevId = 0; | |
| 2187 | + console.log("jx =",jx); | |
| 2188 | + D.clearElement(eMsgTgt); | |
| 2189 | + jx.msgs.forEach((m)=>{ | |
| 2190 | + const mw = new Chat.MessageWidget(m); | |
| 2191 | + D.append( eMsgTgt, mw.e.body ); | |
| 2192 | + prevId = m.msgid; | |
| 2193 | + }); | |
| 2194 | + if( jx.msgs.length ){ | |
| 2195 | + // TODO: MessageSpacer | |
| 2196 | + }else{ | |
| 2197 | + D.append( D.clearElement(eMsgTgt), | |
| 2198 | + 'No results matching the search term: ', | |
| 2199 | + term ); | |
| 2200 | + } | |
| 2201 | + } | |
| 2202 | + } | |
| 2203 | + ); | |
| 2181 | 2204 | }; |
| 2182 | 2205 | |
| 2183 | 2206 | const afterFetch = function f(){ |
| 2184 | 2207 | if(true===f.isFirstCall){ |
| 2185 | 2208 | f.isFirstCall = false; |
| 2186 | 2209 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -2171,15 +2171,38 @@ | |
| 2171 | Submits a history search using the main input field's current |
| 2172 | text. It is assumed that Chat.e.viewSearch===Chat.e.currentView. |
| 2173 | */ |
| 2174 | Chat.submitSearch = function(){ |
| 2175 | const term = this.inputValue(true); |
| 2176 | const eMWC = D.clearElement( |
| 2177 | this.e.viewSearch.querySelector('.message-widget-content') |
| 2178 | ); |
| 2179 | if( !term ) return; |
| 2180 | D.append(eMWC, "TODO: search term = ", term); |
| 2181 | }; |
| 2182 | |
| 2183 | const afterFetch = function f(){ |
| 2184 | if(true===f.isFirstCall){ |
| 2185 | f.isFirstCall = false; |
| 2186 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -2171,15 +2171,38 @@ | |
| 2171 | Submits a history search using the main input field's current |
| 2172 | text. It is assumed that Chat.e.viewSearch===Chat.e.currentView. |
| 2173 | */ |
| 2174 | Chat.submitSearch = function(){ |
| 2175 | const term = this.inputValue(true); |
| 2176 | const eMsgTgt = D.clearElement( |
| 2177 | this.e.viewSearch.querySelector('.message-widget-content') |
| 2178 | ); |
| 2179 | if( !term ) return; |
| 2180 | D.append(eMsgTgt, "TODO: search term = ", term); |
| 2181 | F.fetch( |
| 2182 | "chat-query", { |
| 2183 | urlParams: {q: term}, |
| 2184 | responseType: 'json', |
| 2185 | onload:function(jx){ |
| 2186 | let prevId = 0; |
| 2187 | console.log("jx =",jx); |
| 2188 | D.clearElement(eMsgTgt); |
| 2189 | jx.msgs.forEach((m)=>{ |
| 2190 | const mw = new Chat.MessageWidget(m); |
| 2191 | D.append( eMsgTgt, mw.e.body ); |
| 2192 | prevId = m.msgid; |
| 2193 | }); |
| 2194 | if( jx.msgs.length ){ |
| 2195 | // TODO: MessageSpacer |
| 2196 | }else{ |
| 2197 | D.append( D.clearElement(eMsgTgt), |
| 2198 | 'No results matching the search term: ', |
| 2199 | term ); |
| 2200 | } |
| 2201 | } |
| 2202 | } |
| 2203 | ); |
| 2204 | }; |
| 2205 | |
| 2206 | const afterFetch = function f(){ |
| 2207 | if(true===f.isFirstCall){ |
| 2208 | f.isFirstCall = false; |
| 2209 |
+1
| --- src/style.chat.css | ||
| +++ src/style.chat.css | ||
| @@ -611,10 +611,11 @@ | ||
| 611 | 611 | |
| 612 | 612 | body.chat.fossil-dark-style #chat-button-attach > svg { |
| 613 | 613 | /* The black paperclip is barely visible in dark-mode |
| 614 | 614 | skins when they have dark buttons */ |
| 615 | 615 | filter: invert(0.8); |
| 616 | + transform: scale(130%); | |
| 616 | 617 | } |
| 617 | 618 | |
| 618 | 619 | body.cpage-chat-search .searchForm { |
| 619 | 620 | margin-top: 1em; |
| 620 | 621 | } |
| 621 | 622 |
| --- src/style.chat.css | |
| +++ src/style.chat.css | |
| @@ -611,10 +611,11 @@ | |
| 611 | |
| 612 | body.chat.fossil-dark-style #chat-button-attach > svg { |
| 613 | /* The black paperclip is barely visible in dark-mode |
| 614 | skins when they have dark buttons */ |
| 615 | filter: invert(0.8); |
| 616 | } |
| 617 | |
| 618 | body.cpage-chat-search .searchForm { |
| 619 | margin-top: 1em; |
| 620 | } |
| 621 |
| --- src/style.chat.css | |
| +++ src/style.chat.css | |
| @@ -611,10 +611,11 @@ | |
| 611 | |
| 612 | body.chat.fossil-dark-style #chat-button-attach > svg { |
| 613 | /* The black paperclip is barely visible in dark-mode |
| 614 | skins when they have dark buttons */ |
| 615 | filter: invert(0.8); |
| 616 | transform: scale(130%); |
| 617 | } |
| 618 | |
| 619 | body.cpage-chat-search .searchForm { |
| 620 | margin-top: 1em; |
| 621 | } |
| 622 |