67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
-
+
-
+
-
+
-
+
-
+
|
].join('');
};
/* Returns an almost-ISO8601 form of Date object d. */
const iso8601ish = function(d){
return d.toISOString()
.replace('T',' ').replace(/\.\d+/,'').replace('Z', ' GMT');
};
/* Event handler for clicking .message-user elements to show their
timestamps. */
const handleLegendClicked = function f(ev){
if(!f.popup){
/* Timestampt popup widget */
const tsPopup = new F.PopupWidget({
cssClass: ['fossil-tooltip', 'chat-timestamp'],
refresh:function(){
const D = F.dom;
D.clearElement(this.e);
const d = new Date(this._timestamp+"Z");
if(d.getMinutes().toString()!=="NaN"){
// Date works, render informative timestamps
D.append(this.e, localTimeString(d)," client-local", D.br(),
iso8601ish(d));
}else{
// Date doesn't work, so dumb it down...
D.append(this.e, this._timestamp," GMT");
}
}
});
const hidePopup = ()=>tsPopup.hide();
/* Timestamp popup widget */
f.popup = new F.PopupWidget({
cssClass: ['fossil-tooltip', 'chat-timestamp'],
refresh:function(){
const D = F.dom;
D.clearElement(this.e);
const d = new Date(this._timestamp+"Z");
if(d.getMinutes().toString()!=="NaN"){
// Date works, render informative timestamps
D.append(this.e, localTimeString(d)," client-local", D.br(),
iso8601ish(d));
}else{
// Date doesn't work, so dumb it down...
D.append(this.e, this._timestamp," GMT");
}
}
});
const hidePopup = ()=>f.popup.hide();
tsPopup.e.addEventListener('click', hidePopup, false);
document.body.addEventListener('click', hidePopup, true);
document.body.addEventListener('keydown', function(ev){
if(tsPopup.isShown() && 27===ev.which) tsPopup.hide();
f.popup.installClickToHide();
}, true);
/* Event handler for clicking .message-user elements to show their
timestamps. */
const handleLegendClicked = function(ev){
}
const rect = ev.target.getBoundingClientRect();
tsPopup._timestamp = ev.target.dataset.timestamp;
f.popup._timestamp = ev.target.dataset.timestamp;
let x = rect.left, y = rect.top - 10;
tsPopup.show(ev.target)/*so we can get its computed size*/;
f.popup.show(ev.target)/*so we can get its computed size*/;
// Shift to the left for right-aligned messages
if('right'===ev.target.getAttribute('align')){
const pRect = tsPopup.e.getBoundingClientRect();
const pRect = f.popup.e.getBoundingClientRect();
x -= pRect.width/3*2;
}
tsPopup.show(x, y);
f.popup.show(x, y);
};
function newcontent(jx){
var i;
for(i=0; i<jx.msgs.length; ++i){
let m = jx.msgs[i];
let row = document.createElement("fieldset");
|