Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Simplified some JSON quoting in chat.c. Bypass the paste-from-clipboard handling if the paste target is the input text field, to avoid a console-level error when the text cannot be parsed as an image. TODO: figure out how to handle the paste-image case properly when the event target is the text input field. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | chatroom-dev |
| Files: | files | file ages | folders |
| SHA3-256: |
2fe8d7c4b1d271c58c756aa9a801c979 |
| User & Date: | stephan 2020-12-23 07:45:31.522 |
Context
|
2020-12-23
| ||
| 07:59 | Rescoped the chat timestamp popup widget into a deeper scope (less visible/leaky). Moved the duplicated click-somewhere-to-close-popup handlers into PopupWidget.installClickToHide() method. ... (check-in: 6bccbc20ea user: stephan tags: chatroom-dev) | |
| 07:45 | Simplified some JSON quoting in chat.c. Bypass the paste-from-clipboard handling if the paste target is the input text field, to avoid a console-level error when the text cannot be parsed as an image. TODO: figure out how to handle the paste-image case properly when the event target is the text input field. ... (check-in: 2fe8d7c4b1 user: stephan tags: chatroom-dev) | |
| 07:12 | Seem to have resolved the broken download names for chat-posted files. ... (check-in: b604154c38 user: stephan tags: chatroom-dev) | |
Changes
Changes to src/chat.c.
| ︙ | ︙ | |||
104 105 106 107 108 109 110 | @ placeholder="Type message here."> @ <input type="submit" value="Send"> @ </div> @ <div id='chat-input-file'> @ <span>File:</span> @ <input type="file" name="file"> @ <div id='chat-pasted-image'> | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | @ placeholder="Type message here."> @ <input type="submit" value="Send"> @ </div> @ <div id='chat-input-file'> @ <span>File:</span> @ <input type="file" name="file"> @ <div id='chat-pasted-image'> @ Or paste an image from the clipboard, if supported by your @ environment.<br><img> @ </div> @ </div> @ </div> @ </form> @ <hr> |
| ︙ | ︙ | |||
260 261 262 263 264 265 266 |
int nByte = db_column_bytes(&q1, 4);
const char *zFName = db_column_text(&q1, 5);
const char *zFMime = db_column_text(&q1, 6);
char *zMsg;
cnt++;
blob_append(&json, zSep, -1);
zSep = ",\n";
| | | | | | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
int nByte = db_column_bytes(&q1, 4);
const char *zFName = db_column_text(&q1, 5);
const char *zFMime = db_column_text(&q1, 6);
char *zMsg;
cnt++;
blob_append(&json, zSep, -1);
zSep = ",\n";
blob_appendf(&json, "{\"msgid\":%d,\"mtime\":%!j,", id, zDate);
blob_appendf(&json, "\"xfrom\":%!j,", zFrom);
blob_appendf(&json, "\"uclr\":%!j,", hash_color(zFrom));
/* TBD: Convert the raw message into HTML, perhaps by running it
** through a text formatter, or putting markup on @name phrases,
** etc. */
zMsg = mprintf("%h", zRawMsg);
blob_appendf(&json, "\"xmsg\":%!j,", zMsg);
fossil_free(zMsg);
if( nByte==0 ){
blob_appendf(&json, "\"fsize\":0}");
}else{
blob_appendf(&json, "\"fsize\":%d,\"fname\":%!j,\"fmime\":%!j}",
nByte, zFName, zFMime);
}
}
if( cnt ){
blob_append(&json, "\n]}", 3);
cgi_set_content(&json);
break;
|
| ︙ | ︙ |
Changes to src/chat.js.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
form.file.value = "";
form.msg.focus();
});
/* Handle image paste from clipboard. TODO: confirm that we only
paste images here (silently ignore non-image data), or change the
related code to support non-image pasting/posting. */
document.onpaste = function(event){
const items = event.clipboardData.items;
ImagePasteState.blob = items[0].getAsFile();
const reader = new FileReader();
reader.onload = function(event){
ImagePasteState.imgTag.setAttribute('src', event.target.result);
};
reader.readAsDataURL(ImagePasteState.blob);
| > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
form.file.value = "";
form.msg.focus();
});
/* Handle image paste from clipboard. TODO: confirm that we only
paste images here (silently ignore non-image data), or change the
related code to support non-image pasting/posting. */
document.onpaste = function(event){
if(form.msg === event.target) return;
const items = event.clipboardData.items;
ImagePasteState.blob = items[0].getAsFile();
const reader = new FileReader();
reader.onload = function(event){
ImagePasteState.imgTag.setAttribute('src', event.target.result);
};
reader.readAsDataURL(ImagePasteState.blob);
|
| ︙ | ︙ | |||
175 176 177 178 179 180 181 182 183 184 185 186 |
}
async function poll(){
if(poll.running) return;
poll.running = true;
fetch("chat-poll/" + mxMsg)
.then(x=>x.json())
.then(y=>newcontent(y))
.finally(()=>poll.running=false)
}
poll();
setInterval(poll, 1000);
})();
| > | 176 177 178 179 180 181 182 183 184 185 186 187 188 |
}
async function poll(){
if(poll.running) return;
poll.running = true;
fetch("chat-poll/" + mxMsg)
.then(x=>x.json())
.then(y=>newcontent(y))
.catch(e=>console.error(e))
.finally(()=>poll.running=false)
}
poll();
setInterval(poll, 1000);
})();
|