1111 |
${iconpart}${type} ${subject}
1112 |
${this.getCurrentTimestamp()}
1113 |
1114 | `;
1115 |
1116 | if (this._lastLogEntry !== null && Date.now() - this._lastLogEntry > CHAT_SEPARATOR_DELAY) {
1117 | this.addSeparatorToLog();
1118 | }
1119 |
1120 | return this.addMessageElementToLog(newEntry);
1121 | }
1122 |
1123 | PartyHeader.prototype.addSeparatorToLog = function() {
1124 | let newEntry = document.createElement('div');
1125 | newEntry.className = "chatseparator";
1126 | return this.addMessageElementToLog(newEntry);
1127 | }
1128 |
1129 | PartyHeader.prototype.getCurrentTimestamp = function(now) {
1130 | if (!now) now = new Date();
1131 | return `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
1132 | }
1133 |
1134 | PartyHeader.prototype.addMessageElementToLog = function(element, forceScroll) {
1135 | let container = document.querySelector('.party-sidebar .party-logcontainer');
1136 | let messageLog = document.querySelector('.party-sidebar .party-log');
1137 |
1138 | let atBottom = container.scrollTop > (container.scrollHeight - container.clientHeight) - 30;
1139 |
1140 | messageLog.append(element);
1141 |
1142 | let oldest = [...messageLog.children].slice(0, -100);
1143 | for (let child of oldest) {
1144 | child.remove();
1145 | }
1146 |
1147 | if (atBottom || forceScroll) {
1148 | container.scrollTop = container.scrollHeight;
1149 | }
1150 |
1151 | this._lastLogEntry = Date.now();
1152 | }
1153 |
1154 | PartyHeader.prototype.clearMessageLog = function() {
1155 | let messageLog = document.querySelector('.party-sidebar .party-log');
1156 | messageLog.innerHTML = "";
1157 | }
1158 |
1159 | // ##### Other sidebar control methods #####
1160 |
1161 | PartyHeader.prototype.getSidebarWidth = function() {
1162 | return parseInt(getComputedStyle(document.querySelector(".party-sidebar"), '').width);
1163 | }
1164 |
1165 | PartyHeader.prototype.showSidebar = function(width, saveWidth) {
1166 | if (width < this.getSidebarMinWidth()) width = this.getSidebarMinWidth();
1167 | if (width > this.getSidebarMaxWidth()) width = this.getSidebarMaxWidth();
1168 | let sidebar = document.querySelector(".party-sidebar");
1169 | let appcontainer = document.querySelector(".appcontainer");
1170 | let currentWidth = this.getSidebarWidth();
1171 | let offset = width - currentWidth;
1172 | sidebar.style.display = "block";
1173 | sidebar.style.width = `${width}px`;
1174 | appcontainer.style.right = sidebar.style.width;
1175 | if (this._undocked) {
1176 | this.setUndocked();
1177 | } else {
1178 | this.setDocked();
1179 | }
1180 | document.body.style.setProperty('--party-sidebar-width', this._undocked ? 0 : sidebar.style.width);
1181 | localStorage.setItem(LS_SIDEBAR_STATE, true);
1182 | if (saveWidth) {
1183 | localStorage.setItem(LS_SIDEBAR_WIDTH, width);
1184 | }
1185 | }
1186 |
1187 | PartyHeader.prototype.focusOnChatSend = function() {
1188 | _focusmanager.default.focus(document.querySelector('.party-send textarea'));
1189 | }
1190 |
1191 | PartyHeader.prototype.hideSidebar = function(transient) {
1192 | let sidebar = document.querySelector(".party-sidebar");
1193 | if (!sidebar) return;
1194 | sidebar.style.width = 0;
1195 | sidebar.style.display = "none";
1196 | document.querySelector(".appcontainer").style.right = 0;
1197 | document.body.style.setProperty('--party-sidebar-width', 0);
1198 | if (!transient) {
1199 | localStorage.setItem(LS_SIDEBAR_STATE, false);
1200 | }
1201 | this._focusOnChat = false;
1202 | this._lastLogEntry = null;
1203 | }
1204 |
1205 | PartyHeader.prototype.addAttendeeToList = function(attendee) {
1206 | let container = document.querySelector('.party-sidebar .party-logcontainer');
1207 | let attendeeList = document.querySelector(".party-attendees");
1208 |
1209 | let atBottom = container.scrollTop > (container.scrollHeight - container.clientHeight) - 30;
1210 |
1211 | let newAttendee = document.createElement('div');
1212 | newAttendee.innerHTML = `
1213 | ${this.getProfilePictureHTML(attendee.UserId)}
1214 |