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.

stephan 2024-06-30 15:11 fts5-chat-search
Commit 7561498cf78d1640497a795a2d3809d8c6ea851a14f5558a4673187e27b208ee
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -2171,15 +2171,38 @@
21712171
Submits a history search using the main input field's current
21722172
text. It is assumed that Chat.e.viewSearch===Chat.e.currentView.
21732173
*/
21742174
Chat.submitSearch = function(){
21752175
const term = this.inputValue(true);
2176
- const eMWC = D.clearElement(
2176
+ const eMsgTgt = D.clearElement(
21772177
this.e.viewSearch.querySelector('.message-widget-content')
21782178
);
21792179
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
+ );
21812204
};
21822205
21832206
const afterFetch = function f(){
21842207
if(true===f.isFirstCall){
21852208
f.isFirstCall = false;
21862209
--- 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
--- src/style.chat.css
+++ src/style.chat.css
@@ -611,10 +611,11 @@
611611
612612
body.chat.fossil-dark-style #chat-button-attach > svg {
613613
/* The black paperclip is barely visible in dark-mode
614614
skins when they have dark buttons */
615615
filter: invert(0.8);
616
+ transform: scale(130%);
616617
}
617618
618619
body.cpage-chat-search .searchForm {
619620
margin-top: 1em;
620621
}
621622
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button