Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | chat setting: toggle whether 'my' messages are on the right or left, with the default depending on whether the window is wider than it is tall. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
f1e91a200a7582b3481de1d41abd5c96 |
| User & Date: | stephan 2020-12-25 11:32:24.836 |
Context
|
2020-12-25
| ||
| 12:09 | Change /chat-poll so that it times out after 7 minutes. This prevents the server from timing out the request and generating errors in the log. ... (check-in: 08533f9095 user: drh tags: trunk) | |
| 11:32 | chat setting: toggle whether 'my' messages are on the right or left, with the default depending on whether the window is wider than it is tall. ... (check-in: f1e91a200a user: stephan tags: trunk) | |
| 11:06 | Moved chat.c inline CSS style to default.css. Various chat layout tweaks. ... (check-in: 467dbc8fd7 user: stephan tags: trunk) | |
Changes
Changes to src/chat.js.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
mnMsg: undefined/*lowest message ID we've seen so far (for history loading)*/,
pageIsActive: 'visible'===document.visibilityState,
changesSincePageHidden: 0,
notificationBubbleColor: 'white',
totalMessageCount: 0, // total # of inbound messages
//! Number of messages to load for the history buttons
loadMessageCount: Math.abs(F.config.chatInitSize || 20),
ajaxInflight: 0,
/** Enables (if yes is truthy) or disables all elements in
* this.disableDuringAjax. */
enableAjaxComponents: function(yes){
D[yes ? 'enable' : 'disable'](this.disableDuringAjax);
return this;
},
| > > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
mnMsg: undefined/*lowest message ID we've seen so far (for history loading)*/,
pageIsActive: 'visible'===document.visibilityState,
changesSincePageHidden: 0,
notificationBubbleColor: 'white',
totalMessageCount: 0, // total # of inbound messages
//! Number of messages to load for the history buttons
loadMessageCount: Math.abs(F.config.chatInitSize || 20),
/* Alignment of 'my' messages: must be 'left' or 'right'. Note
that 'right' is conventional for mobile chat apps but can be
difficult to read in wide windows (desktop/tablet landscape
mode). Can be toggled via settings popup. */
msgMyAlign: (window.innerWidth<window.innerHeight) ? 'right' : 'left',
ajaxInflight: 0,
/** Enables (if yes is truthy) or disables all elements in
* this.disableDuringAjax. */
enableAjaxComponents: function(yes){
D[yes ? 'enable' : 'disable'](this.disableDuringAjax);
return this;
},
|
| ︙ | ︙ | |||
363 364 365 366 367 368 369 |
cssClass: ['fossil-tooltip', 'chat-settings-popup'],
adjustY: function(y){
const rect = settingsButton.getBoundingClientRect();
return rect.top + rect.height + 2;
}
});
settingsPopup.installClickToHide();
| | > | > | > > > > > > > > > > | | | | | | | | > | | > > | > | | > > | | > > > > > > > > | > | < > | | < | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
cssClass: ['fossil-tooltip', 'chat-settings-popup'],
adjustY: function(y){
const rect = settingsButton.getBoundingClientRect();
return rect.top + rect.height + 2;
}
});
settingsPopup.installClickToHide();
/* Settings menu entries... */
const settingsOps = [{
label: "Toggle page body",
callback: function f(){
if(undefined === f.isHidden){
f.isHidden = false;
f.elemsToToggle = [];
document.body.childNodes.forEach(function(e){
if(!e.classList) return/*TEXT nodes and such*/;
else if(!e.classList.contains('content')){
f.elemsToToggle.push(e);
}
});
}
if(f.isHidden){
D.removeClass(f.elemsToToggle, 'hidden');
D.removeClass(document.body, 'chat-only-mode');
}else{
D.addClass(f.elemsToToggle, 'hidden');
D.addClass(document.body, 'chat-only-mode');
}
f.isHidden = !f.isHidden;
}
},{
label: "Toggle left/right layout",
callback: function f(){
if('right'===Chat.msgMyAlign) Chat.msgMyAlign = 'left';
else Chat.msgMyAlign = 'right';
const msgs = Chat.e.messagesWrapper.querySelectorAll('.message-row');
msgs.forEach(function(row){
if(row.dataset.xfrom!==Chat.me) return;
row.querySelector('legend').setAttribute('align', Chat.msgMyAlign);
if('right'===Chat.msgMyAlign) row.style.justifyContent = "flex-end";
else row.style.justifyContent = "flex-start";
});
}
}];
settingsOps.forEach(function(op){
const btn = D.append(D.span(), op.label);
D.append(settingsPopup.e, btn);
op.callback.button = btn;
if('function'===op.init) op.init();
btn.addEventListener('click', function(ev){
settingsPopup.hide();
op.callback.call(this,ev);
});
});
settingsButton.addEventListener('click',()=>settingsPopup.show(settingsButton), false);
/* Find an ideal X position for the popup, directly under the settings
button, based on the size of the popup... */
settingsPopup.show(document.body);
popupSize = settingsPopup.e.getBoundingClientRect();
settingsPopup.hide();
settingsPopup.options.adjustX = function(x){
const rect = settingsButton.getBoundingClientRect();
|
| ︙ | ︙ | |||
425 426 427 428 429 430 431 |
const eWho = D.create('legend'),
row = D.addClass(D.fieldset(eWho), 'message-row');
row.dataset.msgid = m.msgid;
row.dataset.xfrom = m.xfrom;
row.dataset.timestamp = m.mtime;
Chat.injectMessageElem(row,atEnd);
eWho.addEventListener('click', handleLegendClicked, false);
| | | > | > > > | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
const eWho = D.create('legend'),
row = D.addClass(D.fieldset(eWho), 'message-row');
row.dataset.msgid = m.msgid;
row.dataset.xfrom = m.xfrom;
row.dataset.timestamp = m.mtime;
Chat.injectMessageElem(row,atEnd);
eWho.addEventListener('click', handleLegendClicked, false);
if( m.xfrom==Chat.me ){
eWho.setAttribute('align', Chat.msgMyAlign);
if('right'===Chat.msgMyAlign){
row.style.justifyContent = "flex-end";
}else{
row.style.justifyContent = "flex-start";
}
}else{
eWho.setAttribute('align', 'left');
}
eWho.style.backgroundColor = m.uclr;
eWho.classList.add('message-user');
let whoName = m.xfrom;
var d = new Date(m.mtime + "Z");
|
| ︙ | ︙ |
Changes to src/default.css.
| ︙ | ︙ | |||
1567 1568 1569 1570 1571 1572 1573 |
filter: invert(100%);
}
body.chat #chat-settings-button {
}
body.chat .chat-settings-popup {
font-size: 0.8em;
text-align: left;
| < > > > > > > > > | 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 |
filter: invert(100%);
}
body.chat #chat-settings-button {
}
body.chat .chat-settings-popup {
font-size: 0.8em;
text-align: left;
display: flex;
flex-direction: column;
align-items: stretch;
padding: 0.25em;
}
body.chat .chat-settings-popup > span {
margin: 0.25em 0.2em;
padding: 0.5em;
white-space: nowrap;
cursor: pointer;
border: 1px outset;
border-radius: 0.25em;
}
body.chat #chat-messages-wrapper {
display: flex;
flex-direction: column;
}
body.chat.chat-only-mode{
}
|
| ︙ | ︙ | |||
1615 1616 1617 1618 1619 1620 1621 |
flex-direction: row;
margin-bottom: 0.25em;
align-items: center;
}
body.chat #chat-input-line > input[type=submit] {
flex: 1 5 auto;
max-width: 6em;
| | | 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 |
flex-direction: row;
margin-bottom: 0.25em;
align-items: center;
}
body.chat #chat-input-line > input[type=submit] {
flex: 1 5 auto;
max-width: 6em;
margin: 0 1em;
}
body.chat #chat-input-line > input[type=text] {
flex: 5 1 auto;
}
body.chat #chat-input-file-area {
display: flex;
flex-direction: row;
|
| ︙ | ︙ |