Hansimov commited on
Commit
82b5a4a
1 Parent(s): 4a8deab

:recycle: [Refactor] MessagerViewer: Separate elements creation, and prettify styles

Browse files
Files changed (1) hide show
  1. apps/llm_mixer/js/messager.js +19 -9
apps/llm_mixer/js/messager.js CHANGED
@@ -5,18 +5,32 @@ export class MessagerViewer {
5
  }
6
  create_elements() {
7
  this.container = $("<div>").addClass("row no-gutters message-viewer");
8
- this.role_displayer = $("<div>").addClass("col-auto role-displayer");
 
 
 
 
 
 
 
 
 
 
 
9
  if (this.message.role === "user") {
10
  this.role_displayer.append("You");
11
  } else {
12
  this.role_displayer.append(this.message.model);
13
  }
14
- this.role_displayer.append(this.message.model);
 
15
  this.content_displayer = $("<div>")
16
- .addClass(
17
- `col mb-2 p-2 content-displayer chat-${this.message.role}`
18
- )
19
  .append(this.message.content);
 
 
20
  this.button = $("<button>").addClass(
21
  "col-auto btn btn-primary regenerate-button"
22
  );
@@ -25,10 +39,6 @@ export class MessagerViewer {
25
  } else {
26
  this.button.append("Regenerate");
27
  }
28
- this.container
29
- .append(this.role_displayer)
30
- .append(this.content_displayer)
31
- .append(this.button);
32
  }
33
  }
34
 
 
5
  }
6
  create_elements() {
7
  this.container = $("<div>").addClass("row no-gutters message-viewer");
8
+ this.create_role_displayer();
9
+ this.create_content_displayer();
10
+ this.create_button();
11
+ this.container
12
+ .append(this.role_displayer)
13
+ .append(this.content_displayer)
14
+ .append(this.button);
15
+ }
16
+ create_role_displayer() {
17
+ this.role_displayer = $("<div>")
18
+ .addClass("col-auto mb-2 p-2")
19
+ .addClass("role-displayer");
20
  if (this.message.role === "user") {
21
  this.role_displayer.append("You");
22
  } else {
23
  this.role_displayer.append(this.message.model);
24
  }
25
+ }
26
+ create_content_displayer() {
27
  this.content_displayer = $("<div>")
28
+ .addClass("col mb-2 p-2")
29
+ .addClass("content-displayer")
30
+ .addClass(`chat-${this.message.role}`)
31
  .append(this.message.content);
32
+ }
33
+ create_button() {
34
  this.button = $("<button>").addClass(
35
  "col-auto btn btn-primary regenerate-button"
36
  );
 
39
  } else {
40
  this.button.append("Regenerate");
41
  }
 
 
 
 
42
  }
43
  }
44