Fossil SCM

Updated changelog for chat preview. Hyperlinks in preview mode now have target=_blank. Removed extraneous FORM element around chat input area, as it caused only grief with regards to Enter key handling (always activating the first button in the list, which is now the preview button).

stephan 2021-09-21 15:02 trunk
Commit 60ed1ff9511306a902128adf6b8b789d4b2b265d5e7f9fe2002b651dbe1a0a44
-2
--- src/chat.c
+++ src/chat.c
@@ -152,11 +152,10 @@
152152
zAlert = mprintf("%s/builtin/%s", g.zBaseURL,
153153
db_get("chat-alert-sound","alerts/plunk.wav"));
154154
zProjectName = db_get("project-name","Unnamed project");
155155
style_set_current_feature("chat");
156156
style_header("Chat");
157
- @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
158157
@ <div id='chat-input-area'>
159158
@ <div id='chat-input-line' class='single-line'>
160159
@ <input type="text" name="msg" id="chat-input-single" \
161160
@ placeholder="Type markdown-formatted message for %h(zProjectName)." \
162161
@ autocomplete="off">
@@ -182,11 +181,10 @@
182181
@ <input type="file" name="file" id="chat-input-file">
183182
@ </div>
184183
@ <div id="chat-drop-details"></div>
185184
@ </div>
186185
@ </div>
187
- @ </form>
188186
@ <div id='chat-preview' class='hidden'>
189187
@ <header>Preview: (<a href='%R/md_rules' target='_blank'>markdown reference</a>)</header>
190188
@ <div id='chat-preview-content' class='message-widget-content'></div>
191189
@ <div id='chat-preview-buttons'><button id='chat-preview-close'>Close Preview</button></div>
192190
@ </div>
193191
--- src/chat.c
+++ src/chat.c
@@ -152,11 +152,10 @@
152 zAlert = mprintf("%s/builtin/%s", g.zBaseURL,
153 db_get("chat-alert-sound","alerts/plunk.wav"));
154 zProjectName = db_get("project-name","Unnamed project");
155 style_set_current_feature("chat");
156 style_header("Chat");
157 @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
158 @ <div id='chat-input-area'>
159 @ <div id='chat-input-line' class='single-line'>
160 @ <input type="text" name="msg" id="chat-input-single" \
161 @ placeholder="Type markdown-formatted message for %h(zProjectName)." \
162 @ autocomplete="off">
@@ -182,11 +181,10 @@
182 @ <input type="file" name="file" id="chat-input-file">
183 @ </div>
184 @ <div id="chat-drop-details"></div>
185 @ </div>
186 @ </div>
187 @ </form>
188 @ <div id='chat-preview' class='hidden'>
189 @ <header>Preview: (<a href='%R/md_rules' target='_blank'>markdown reference</a>)</header>
190 @ <div id='chat-preview-content' class='message-widget-content'></div>
191 @ <div id='chat-preview-buttons'><button id='chat-preview-close'>Close Preview</button></div>
192 @ </div>
193
--- src/chat.c
+++ src/chat.c
@@ -152,11 +152,10 @@
152 zAlert = mprintf("%s/builtin/%s", g.zBaseURL,
153 db_get("chat-alert-sound","alerts/plunk.wav"));
154 zProjectName = db_get("project-name","Unnamed project");
155 style_set_current_feature("chat");
156 style_header("Chat");
 
157 @ <div id='chat-input-area'>
158 @ <div id='chat-input-line' class='single-line'>
159 @ <input type="text" name="msg" id="chat-input-single" \
160 @ placeholder="Type markdown-formatted message for %h(zProjectName)." \
161 @ autocomplete="off">
@@ -182,11 +181,10 @@
181 @ <input type="file" name="file" id="chat-input-file">
182 @ </div>
183 @ <div id="chat-drop-details"></div>
184 @ </div>
185 @ </div>
 
186 @ <div id='chat-preview' class='hidden'>
187 @ <header>Preview: (<a href='%R/md_rules' target='_blank'>markdown reference</a>)</header>
188 @ <div id='chat-preview-content' class='message-widget-content'></div>
189 @ <div id='chat-preview-buttons'><button id='chat-preview-close'>Close Preview</button></div>
190 @ </div>
191
+5 -6
--- src/chat.js
+++ src/chat.js
@@ -33,10 +33,12 @@
3333
if(r1.top<=r2.bottom && r1.top>=r2.top) return true;
3434
else if(r1.bottom<=r2.bottom && r1.bottom>=r2.top) return true;
3535
return false;
3636
};
3737
38
+ const addAnchorTargetBlank = (e)=>D.attr(e, 'target','_blank');
39
+
3840
(function(){
3941
let dbg = document.querySelector('#debugMsg');
4042
if(dbg){
4143
/* This can inadvertently influence our flexbox layouts, so move
4244
it out of the way. */
@@ -104,11 +106,10 @@
104106
loadOlderToolbar: undefined /* the load-posts toolbar (dynamically created) */,
105107
inputWrapper: E1("#chat-input-area"),
106108
inputLine: E1('#chat-input-line'),
107109
fileSelectWrapper: E1('#chat-input-file-area'),
108110
messagesWrapper: E1('#chat-messages-wrapper'),
109
- inputForm: E1('#chat-form'),
110111
btnSubmit: E1('#chat-message-submit'),
111112
inputSingle: E1('#chat-input-single'),
112113
inputMulti: E1('#chat-input-multi'),
113114
inputCurrent: undefined/*one of inputSingle or inputMulti*/,
114115
inputFile: E1('#chat-input-file'),
@@ -668,11 +669,10 @@
668669
'-',pad2(d.getDate()),
669670
' ',pad2(d.getHours()),':',pad2(d.getMinutes()),
670671
':',pad2(d.getSeconds())
671672
].join('');
672673
};
673
- const addAnchorTargetBlank = (e)=>D.attr(e, 'target','_blank');
674674
cf.prototype = {
675675
scrollIntoView: function(){
676676
this.e.content.scrollIntoView();
677677
},
678678
setMessage: function(m){
@@ -956,14 +956,11 @@
956956
Chat.submitMessage = function f(){
957957
if(!f.spaces){
958958
f.spaces = /\s+$/;
959959
}
960960
this.revealPreview(false);
961
- const fd = new FormData(this.e.inputForm)
962
- /* ^^^^ we don't really want/need the FORM element, but when
963
- FormData() is default-constructed here then the server
964
- segfaults, and i have no clue why! */;
961
+ const fd = new FormData();
965962
var msg = this.inputValue().trim();
966963
if(msg && (msg.indexOf('\n')>0 || f.spaces.test(msg))){
967964
/* Cosmetic: trim whitespace from the ends of lines to try to
968965
keep copy/paste from terminals, especially wide ones, from
969966
forcing a horizontal scrollbar on all clients. */
@@ -1149,10 +1146,12 @@
11491146
11501147
(function(){/*set up message preview*/
11511148
const btnPreview = Chat.e.btnPreview;
11521149
Chat.setPreviewText = function(t){
11531150
this.revealPreview(true).e.previewContent.innerHTML = t;
1151
+ this.e.previewArea.querySelectorAll('a').forEach(addAnchorTargetBlank);
1152
+ this.e.inputCurrent.focus();
11541153
};
11551154
/**
11561155
Reveals preview area if showIt is true, else hides it.
11571156
This also shows/hides other elements, "as appropriate."
11581157
*/
11591158
--- src/chat.js
+++ src/chat.js
@@ -33,10 +33,12 @@
33 if(r1.top<=r2.bottom && r1.top>=r2.top) return true;
34 else if(r1.bottom<=r2.bottom && r1.bottom>=r2.top) return true;
35 return false;
36 };
37
 
 
38 (function(){
39 let dbg = document.querySelector('#debugMsg');
40 if(dbg){
41 /* This can inadvertently influence our flexbox layouts, so move
42 it out of the way. */
@@ -104,11 +106,10 @@
104 loadOlderToolbar: undefined /* the load-posts toolbar (dynamically created) */,
105 inputWrapper: E1("#chat-input-area"),
106 inputLine: E1('#chat-input-line'),
107 fileSelectWrapper: E1('#chat-input-file-area'),
108 messagesWrapper: E1('#chat-messages-wrapper'),
109 inputForm: E1('#chat-form'),
110 btnSubmit: E1('#chat-message-submit'),
111 inputSingle: E1('#chat-input-single'),
112 inputMulti: E1('#chat-input-multi'),
113 inputCurrent: undefined/*one of inputSingle or inputMulti*/,
114 inputFile: E1('#chat-input-file'),
@@ -668,11 +669,10 @@
668 '-',pad2(d.getDate()),
669 ' ',pad2(d.getHours()),':',pad2(d.getMinutes()),
670 ':',pad2(d.getSeconds())
671 ].join('');
672 };
673 const addAnchorTargetBlank = (e)=>D.attr(e, 'target','_blank');
674 cf.prototype = {
675 scrollIntoView: function(){
676 this.e.content.scrollIntoView();
677 },
678 setMessage: function(m){
@@ -956,14 +956,11 @@
956 Chat.submitMessage = function f(){
957 if(!f.spaces){
958 f.spaces = /\s+$/;
959 }
960 this.revealPreview(false);
961 const fd = new FormData(this.e.inputForm)
962 /* ^^^^ we don't really want/need the FORM element, but when
963 FormData() is default-constructed here then the server
964 segfaults, and i have no clue why! */;
965 var msg = this.inputValue().trim();
966 if(msg && (msg.indexOf('\n')>0 || f.spaces.test(msg))){
967 /* Cosmetic: trim whitespace from the ends of lines to try to
968 keep copy/paste from terminals, especially wide ones, from
969 forcing a horizontal scrollbar on all clients. */
@@ -1149,10 +1146,12 @@
1149
1150 (function(){/*set up message preview*/
1151 const btnPreview = Chat.e.btnPreview;
1152 Chat.setPreviewText = function(t){
1153 this.revealPreview(true).e.previewContent.innerHTML = t;
 
 
1154 };
1155 /**
1156 Reveals preview area if showIt is true, else hides it.
1157 This also shows/hides other elements, "as appropriate."
1158 */
1159
--- src/chat.js
+++ src/chat.js
@@ -33,10 +33,12 @@
33 if(r1.top<=r2.bottom && r1.top>=r2.top) return true;
34 else if(r1.bottom<=r2.bottom && r1.bottom>=r2.top) return true;
35 return false;
36 };
37
38 const addAnchorTargetBlank = (e)=>D.attr(e, 'target','_blank');
39
40 (function(){
41 let dbg = document.querySelector('#debugMsg');
42 if(dbg){
43 /* This can inadvertently influence our flexbox layouts, so move
44 it out of the way. */
@@ -104,11 +106,10 @@
106 loadOlderToolbar: undefined /* the load-posts toolbar (dynamically created) */,
107 inputWrapper: E1("#chat-input-area"),
108 inputLine: E1('#chat-input-line'),
109 fileSelectWrapper: E1('#chat-input-file-area'),
110 messagesWrapper: E1('#chat-messages-wrapper'),
 
111 btnSubmit: E1('#chat-message-submit'),
112 inputSingle: E1('#chat-input-single'),
113 inputMulti: E1('#chat-input-multi'),
114 inputCurrent: undefined/*one of inputSingle or inputMulti*/,
115 inputFile: E1('#chat-input-file'),
@@ -668,11 +669,10 @@
669 '-',pad2(d.getDate()),
670 ' ',pad2(d.getHours()),':',pad2(d.getMinutes()),
671 ':',pad2(d.getSeconds())
672 ].join('');
673 };
 
674 cf.prototype = {
675 scrollIntoView: function(){
676 this.e.content.scrollIntoView();
677 },
678 setMessage: function(m){
@@ -956,14 +956,11 @@
956 Chat.submitMessage = function f(){
957 if(!f.spaces){
958 f.spaces = /\s+$/;
959 }
960 this.revealPreview(false);
961 const fd = new FormData();
 
 
 
962 var msg = this.inputValue().trim();
963 if(msg && (msg.indexOf('\n')>0 || f.spaces.test(msg))){
964 /* Cosmetic: trim whitespace from the ends of lines to try to
965 keep copy/paste from terminals, especially wide ones, from
966 forcing a horizontal scrollbar on all clients. */
@@ -1149,10 +1146,12 @@
1146
1147 (function(){/*set up message preview*/
1148 const btnPreview = Chat.e.btnPreview;
1149 Chat.setPreviewText = function(t){
1150 this.revealPreview(true).e.previewContent.innerHTML = t;
1151 this.e.previewArea.querySelectorAll('a').forEach(addAnchorTargetBlank);
1152 this.e.inputCurrent.focus();
1153 };
1154 /**
1155 Reveals preview area if showIt is true, else hides it.
1156 This also shows/hides other elements, "as appropriate."
1157 */
1158
--- www/changes.wiki
+++ www/changes.wiki
@@ -43,11 +43,12 @@
4343
selection of notification sounds via unversioned files].
4444
* The [/help?cmd=/chat|/chat] messages now use fossil's full complement of
4545
markdown features, instead of the prior small subset of markup it
4646
previously supported. This retroactively applies to all chat messages,
4747
as they are markdown-processed when they are sent instead of when they
48
- are saved. See [./chat.md#usage|the chat docs] for more details.
48
+ are saved. Added a preview mode so messages can be previewed before
49
+ being sent. See [./chat.md#usage|the chat docs] for more details.
4950
5051
<h2 id='v2_16'>Changes for Version 2.16 (2021-07-02)</h2>
5152
* <b>Security:</b> Fix the client-side TLS so that it verifies that the
5253
server hostname matches its certificate.
5354
* The default "ssh" command on Windows is changed to "ssh" instead of the
5455
--- www/changes.wiki
+++ www/changes.wiki
@@ -43,11 +43,12 @@
43 selection of notification sounds via unversioned files].
44 * The [/help?cmd=/chat|/chat] messages now use fossil's full complement of
45 markdown features, instead of the prior small subset of markup it
46 previously supported. This retroactively applies to all chat messages,
47 as they are markdown-processed when they are sent instead of when they
48 are saved. See [./chat.md#usage|the chat docs] for more details.
 
49
50 <h2 id='v2_16'>Changes for Version 2.16 (2021-07-02)</h2>
51 * <b>Security:</b> Fix the client-side TLS so that it verifies that the
52 server hostname matches its certificate.
53 * The default "ssh" command on Windows is changed to "ssh" instead of the
54
--- www/changes.wiki
+++ www/changes.wiki
@@ -43,11 +43,12 @@
43 selection of notification sounds via unversioned files].
44 * The [/help?cmd=/chat|/chat] messages now use fossil's full complement of
45 markdown features, instead of the prior small subset of markup it
46 previously supported. This retroactively applies to all chat messages,
47 as they are markdown-processed when they are sent instead of when they
48 are saved. Added a preview mode so messages can be previewed before
49 being sent. See [./chat.md#usage|the chat docs] for more details.
50
51 <h2 id='v2_16'>Changes for Version 2.16 (2021-07-02)</h2>
52 * <b>Security:</b> Fix the client-side TLS so that it verifies that the
53 server hostname matches its certificate.
54 * The default "ssh" command on Windows is changed to "ssh" instead of the
55

Keyboard Shortcuts

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