Browse Source

Comment author display

CrazyDoctor 7 months ago
parent
commit
593891cec0

+ 1 - 0
node_scripts/uglifyStatics.mjs

@@ -100,6 +100,7 @@ class Minifier {
 					'inherited',
 					'overridden',
 					'dynamic',
+					'author',
 					// <<< Server data
 
 					// >>> WebSocket

+ 1 - 3
src/routes/PostInheritedComments.ts

@@ -31,9 +31,7 @@ class PostInheritedComments extends Route {
 				const commentsObj: any = {};
 
 				result.comments?.forEach((comment) => {
-					result.comments?.forEach((comment) => {
-						commentsObj[comment.propertyName] = comment;
-					});
+					commentsObj[comment.propertyName] = comment;
 				});
 
 				inheritedComments[className] = commentsObj;

+ 6 - 6
static/page/class/script.js

@@ -487,7 +487,7 @@ class ClassPage {
 			}
 
 			if(hasComment)
-				itemCommentCn.push(this.createCommentDateElement(loadedComment.timestamp));
+				itemCommentCn.push(this.createCommentDateElement(loadedComment.timestamp, loadedComment.author));
 
 			DOM.create({ tag: DOM.Tags.Div, cls: 'property-item-comment', cn: itemCommentCn }, propertyItem);
 		}
@@ -498,8 +498,8 @@ class ClassPage {
 		});
 	}
 
-	createCommentDateElement(date) {
-		const commentDateText = DOM.create({ tag: DOM.Tags.Span, cls: 'property-item-comment-date-text', innerHTML: 'Commented on: ' });
+	createCommentDateElement(date, author) {
+		const commentDateText = DOM.create({ tag: DOM.Tags.Span, cls: 'property-item-comment-date-text', innerHTML: `Commented by <b>${author}</b> on: ` });
 		const commentDateDate = DOM.create({ tag: DOM.Tags.Span, cls: 'property-item-comment-date-date', innerHTML: CDUtils.dateFormatUTC(date, 3, 'D.M.Y, H:I:S') });
 		return DOM.create({ tag: DOM.Tags.Div, cls: 'property-item-comment-date', cn: [commentDateText, commentDateDate] });
 	}
@@ -524,7 +524,7 @@ class ClassPage {
 					if(element) {
 						element.setInnerHTML(props[prop].text);
 						element.removeClass(ClassPage.StyleClasses.Empty);
-						element.getParent().append(this.createCommentDateElement(props[prop].timestamp));
+						element.getParent().append(this.createCommentDateElement(props[prop].timestamp, props[prop].author));
 					}
 				}
 			}
@@ -986,7 +986,7 @@ class ClassPage {
 
 			Comments[changedComment.propertyName] = changedComment;
 
-			propertyItem.getFirstChild('.property-item-comment').append(this.createCommentDateElement(changedComment.timestamp));
+			propertyItem.getFirstChild('.property-item-comment').append(this.createCommentDateElement(changedComment.timestamp, changedComment.author));
 			break;
 		case 'update':
 			if(Comments[changedComment.propertyName].text.length === 0) {
@@ -1000,7 +1000,7 @@ class ClassPage {
 			if(dateElement) {
 				dateElement.setInnerHTML(CDUtils.dateFormatUTC(changedComment.timestamp, 3, 'D.M.Y, H:I:S'));
 			} else {
-				propertyItem.getFirstChild('.property-item-comment').append(this.createCommentDateElement(changedComment.timestamp));
+				propertyItem.getFirstChild('.property-item-comment').append(this.createCommentDateElement(changedComment.timestamp, changedComment.author));
 			}
 			break;
 		case 'remove':