Fossil SCM
/chat: when tapping on a #NNNN reference, if the referred-to message is not loaded in the local history then search the chat history for message #NNNN.
Commit
347084af906fd210f18811f618be02c133482a68fc8e51bae5abdf32f8c7ced7
Parent
5e26fd4c10af877…
1 file changed
+11
-10
+11
-10
| --- src/fossil.page.chat.js | ||
| +++ src/fossil.page.chat.js | ||
| @@ -1016,17 +1016,17 @@ | ||
| 1016 | 1016 | while(e && !e.classList.contains(className)){ |
| 1017 | 1017 | e = e.parentNode; |
| 1018 | 1018 | } |
| 1019 | 1019 | return e; |
| 1020 | 1020 | }; |
| 1021 | - | |
| 1021 | + | |
| 1022 | 1022 | /** To be passed each MessageWidget's top-level DOM element |
| 1023 | 1023 | after initial processing of the message, to set up |
| 1024 | 1024 | hashtag and numtag references. */ |
| 1025 | 1025 | const setupHashtags = function f(elem){ |
| 1026 | - if(!f.$click){ | |
| 1027 | - f.$click = function(ev){ | |
| 1026 | + if(!f.$clickTag){ | |
| 1027 | + f.$clickTag = function(ev){ | |
| 1028 | 1028 | /* Click handler for hashtags */ |
| 1029 | 1029 | const tag = ev.target.dataset.hashtag; |
| 1030 | 1030 | if(tag){ |
| 1031 | 1031 | Chat.setHashtagFilter( |
| 1032 | 1032 | tag===Chat.filter.hashtag.activeTag |
| @@ -1051,18 +1051,18 @@ | ||
| 1051 | 1051 | const rc = window.history.pushState(state, ""); |
| 1052 | 1052 | //console.debug("Pushing history for msgid", state); |
| 1053 | 1053 | //console.debug("Chat.numtagHistoryStack =",Chat.numtagHistoryStack); |
| 1054 | 1054 | } |
| 1055 | 1055 | }else{ |
| 1056 | - F.toast.warning("Message #"+tag+" not found in loaded messages."); | |
| 1056 | + Chat.submitSearch('#'+tag); | |
| 1057 | 1057 | } |
| 1058 | 1058 | } |
| 1059 | 1059 | }; |
| 1060 | 1060 | } |
| 1061 | 1061 | elem.querySelectorAll('[data-hashtag]').forEach(function(e){ |
| 1062 | 1062 | e.dataset.hashtag = e.dataset.hashtag.toLowerCase(); |
| 1063 | - e.addEventListener('click', f.$click, false); | |
| 1063 | + e.addEventListener('click', f.$clickTag, false); | |
| 1064 | 1064 | }) |
| 1065 | 1065 | elem.querySelectorAll('[data-numtag]').forEach( |
| 1066 | 1066 | (e)=>e.addEventListener('click', f.$clickNum, false) |
| 1067 | 1067 | ) |
| 1068 | 1068 | }/*setupHashtags()*/; |
| @@ -1483,11 +1483,11 @@ | ||
| 1483 | 1483 | }/*_handleLegendClicked()*/ |
| 1484 | 1484 | }/*MessageWidget.prototype*/; |
| 1485 | 1485 | /** Assumes that e is a MessageWidget element, ensures that |
| 1486 | 1486 | Chat.e.viewMessages is visible, scrolls the message, |
| 1487 | 1487 | and animates it a bit to make it more visible. */ |
| 1488 | - cf.scrollToMessageElem = function(e){ | |
| 1488 | + ctor.scrollToMessageElem = function(e){ | |
| 1489 | 1489 | if(e.firstElementChild){ |
| 1490 | 1490 | Chat.setCurrentView(Chat.e.viewMessages); |
| 1491 | 1491 | e.scrollIntoView(false); |
| 1492 | 1492 | Chat.animate(e, 'anim-fade-out-in'); |
| 1493 | 1493 | } |
| @@ -2569,15 +2569,16 @@ | ||
| 2569 | 2569 | } |
| 2570 | 2570 | return e; |
| 2571 | 2571 | }; |
| 2572 | 2572 | Chat.clearSearch(true); |
| 2573 | 2573 | /** |
| 2574 | - Submits a history search using the main input field's current | |
| 2575 | - text. It is assumed that Chat.e.viewSearch===Chat.e.currentView. | |
| 2574 | + Submits a history search using either its argument or the the | |
| 2575 | + main input field's current text. | |
| 2576 | 2576 | */ |
| 2577 | - Chat.submitSearch = function(){ | |
| 2578 | - const term = this.inputValue(true); | |
| 2577 | + Chat.submitSearch = function(term){ | |
| 2578 | + Chat.setCurrentView(Chat.e.viewSearch); | |
| 2579 | + if(!arguments.length) term = this.inputValue(true); | |
| 2579 | 2580 | const eMsgTgt = this.clearSearch(true); |
| 2580 | 2581 | if( !term ) return; |
| 2581 | 2582 | D.append( eMsgTgt, "Searching for ",term," ..."); |
| 2582 | 2583 | const fd = new FormData(); |
| 2583 | 2584 | fd.set('q', term); |
| 2584 | 2585 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -1016,17 +1016,17 @@ | |
| 1016 | while(e && !e.classList.contains(className)){ |
| 1017 | e = e.parentNode; |
| 1018 | } |
| 1019 | return e; |
| 1020 | }; |
| 1021 | |
| 1022 | /** To be passed each MessageWidget's top-level DOM element |
| 1023 | after initial processing of the message, to set up |
| 1024 | hashtag and numtag references. */ |
| 1025 | const setupHashtags = function f(elem){ |
| 1026 | if(!f.$click){ |
| 1027 | f.$click = function(ev){ |
| 1028 | /* Click handler for hashtags */ |
| 1029 | const tag = ev.target.dataset.hashtag; |
| 1030 | if(tag){ |
| 1031 | Chat.setHashtagFilter( |
| 1032 | tag===Chat.filter.hashtag.activeTag |
| @@ -1051,18 +1051,18 @@ | |
| 1051 | const rc = window.history.pushState(state, ""); |
| 1052 | //console.debug("Pushing history for msgid", state); |
| 1053 | //console.debug("Chat.numtagHistoryStack =",Chat.numtagHistoryStack); |
| 1054 | } |
| 1055 | }else{ |
| 1056 | F.toast.warning("Message #"+tag+" not found in loaded messages."); |
| 1057 | } |
| 1058 | } |
| 1059 | }; |
| 1060 | } |
| 1061 | elem.querySelectorAll('[data-hashtag]').forEach(function(e){ |
| 1062 | e.dataset.hashtag = e.dataset.hashtag.toLowerCase(); |
| 1063 | e.addEventListener('click', f.$click, false); |
| 1064 | }) |
| 1065 | elem.querySelectorAll('[data-numtag]').forEach( |
| 1066 | (e)=>e.addEventListener('click', f.$clickNum, false) |
| 1067 | ) |
| 1068 | }/*setupHashtags()*/; |
| @@ -1483,11 +1483,11 @@ | |
| 1483 | }/*_handleLegendClicked()*/ |
| 1484 | }/*MessageWidget.prototype*/; |
| 1485 | /** Assumes that e is a MessageWidget element, ensures that |
| 1486 | Chat.e.viewMessages is visible, scrolls the message, |
| 1487 | and animates it a bit to make it more visible. */ |
| 1488 | cf.scrollToMessageElem = function(e){ |
| 1489 | if(e.firstElementChild){ |
| 1490 | Chat.setCurrentView(Chat.e.viewMessages); |
| 1491 | e.scrollIntoView(false); |
| 1492 | Chat.animate(e, 'anim-fade-out-in'); |
| 1493 | } |
| @@ -2569,15 +2569,16 @@ | |
| 2569 | } |
| 2570 | return e; |
| 2571 | }; |
| 2572 | Chat.clearSearch(true); |
| 2573 | /** |
| 2574 | Submits a history search using the main input field's current |
| 2575 | text. It is assumed that Chat.e.viewSearch===Chat.e.currentView. |
| 2576 | */ |
| 2577 | Chat.submitSearch = function(){ |
| 2578 | const term = this.inputValue(true); |
| 2579 | const eMsgTgt = this.clearSearch(true); |
| 2580 | if( !term ) return; |
| 2581 | D.append( eMsgTgt, "Searching for ",term," ..."); |
| 2582 | const fd = new FormData(); |
| 2583 | fd.set('q', term); |
| 2584 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -1016,17 +1016,17 @@ | |
| 1016 | while(e && !e.classList.contains(className)){ |
| 1017 | e = e.parentNode; |
| 1018 | } |
| 1019 | return e; |
| 1020 | }; |
| 1021 | |
| 1022 | /** To be passed each MessageWidget's top-level DOM element |
| 1023 | after initial processing of the message, to set up |
| 1024 | hashtag and numtag references. */ |
| 1025 | const setupHashtags = function f(elem){ |
| 1026 | if(!f.$clickTag){ |
| 1027 | f.$clickTag = function(ev){ |
| 1028 | /* Click handler for hashtags */ |
| 1029 | const tag = ev.target.dataset.hashtag; |
| 1030 | if(tag){ |
| 1031 | Chat.setHashtagFilter( |
| 1032 | tag===Chat.filter.hashtag.activeTag |
| @@ -1051,18 +1051,18 @@ | |
| 1051 | const rc = window.history.pushState(state, ""); |
| 1052 | //console.debug("Pushing history for msgid", state); |
| 1053 | //console.debug("Chat.numtagHistoryStack =",Chat.numtagHistoryStack); |
| 1054 | } |
| 1055 | }else{ |
| 1056 | Chat.submitSearch('#'+tag); |
| 1057 | } |
| 1058 | } |
| 1059 | }; |
| 1060 | } |
| 1061 | elem.querySelectorAll('[data-hashtag]').forEach(function(e){ |
| 1062 | e.dataset.hashtag = e.dataset.hashtag.toLowerCase(); |
| 1063 | e.addEventListener('click', f.$clickTag, false); |
| 1064 | }) |
| 1065 | elem.querySelectorAll('[data-numtag]').forEach( |
| 1066 | (e)=>e.addEventListener('click', f.$clickNum, false) |
| 1067 | ) |
| 1068 | }/*setupHashtags()*/; |
| @@ -1483,11 +1483,11 @@ | |
| 1483 | }/*_handleLegendClicked()*/ |
| 1484 | }/*MessageWidget.prototype*/; |
| 1485 | /** Assumes that e is a MessageWidget element, ensures that |
| 1486 | Chat.e.viewMessages is visible, scrolls the message, |
| 1487 | and animates it a bit to make it more visible. */ |
| 1488 | ctor.scrollToMessageElem = function(e){ |
| 1489 | if(e.firstElementChild){ |
| 1490 | Chat.setCurrentView(Chat.e.viewMessages); |
| 1491 | e.scrollIntoView(false); |
| 1492 | Chat.animate(e, 'anim-fade-out-in'); |
| 1493 | } |
| @@ -2569,15 +2569,16 @@ | |
| 2569 | } |
| 2570 | return e; |
| 2571 | }; |
| 2572 | Chat.clearSearch(true); |
| 2573 | /** |
| 2574 | Submits a history search using either its argument or the the |
| 2575 | main input field's current text. |
| 2576 | */ |
| 2577 | Chat.submitSearch = function(term){ |
| 2578 | Chat.setCurrentView(Chat.e.viewSearch); |
| 2579 | if(!arguments.length) term = this.inputValue(true); |
| 2580 | const eMsgTgt = this.clearSearch(true); |
| 2581 | if( !term ) return; |
| 2582 | D.append( eMsgTgt, "Searching for ",term," ..."); |
| 2583 | const fd = new FormData(); |
| 2584 | fd.set('q', term); |
| 2585 |