Compare commits
1 Commits
6589d76d5f
...
a81da7e2ee
Author | SHA1 | Date | |
---|---|---|---|
a81da7e2ee |
39
main.js
39
main.js
@ -5,7 +5,7 @@ var conversation = null;
|
|||||||
class Conversation {
|
class Conversation {
|
||||||
constructor(name) {
|
constructor(name) {
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
this.name = name;
|
this.name = romanize(name);
|
||||||
this.score = 1.0;
|
this.score = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,26 +27,20 @@ class Conversation {
|
|||||||
sendUserMessage(text) {
|
sendUserMessage(text) {
|
||||||
|
|
||||||
const message = new UserMessage(text);
|
const message = new UserMessage(text);
|
||||||
message.updateStatus("envoyé");
|
message.updateStatus("envoyé");
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
message.updateStatus("livré");
|
message.updateStatus("livré");
|
||||||
this.render();
|
this.render();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
message.updateStatus("lu");
|
message.updateStatus("lu");
|
||||||
this.render();
|
this.render();
|
||||||
setTimeout(()=> {
|
}, 5000);
|
||||||
setTimeout(() => {
|
}, 5000);
|
||||||
this.messages.push(new AgentMessage("merde alors"));
|
|
||||||
this.render();
|
|
||||||
}, 2000);
|
|
||||||
}, 500);
|
|
||||||
}, 3000);
|
|
||||||
}, 1000);
|
|
||||||
//this.messages.push(message);
|
|
||||||
this.messages.push(message);
|
this.messages.push(message);
|
||||||
//this.messages.push(new AgentMessage(messageText));
|
this.messages.push(new AgentMessage(messageText));
|
||||||
this.render();
|
//this.messages.push(new AgentMessage(messageText));
|
||||||
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the current HTML based on messages
|
// update the current HTML based on messages
|
||||||
@ -89,6 +83,13 @@ function getMessageList() {
|
|||||||
return document.getElementById("messages");
|
return document.getElementById("messages");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function romanize(text) {
|
||||||
|
|
||||||
|
text = text.replaceAll('u', 'v');
|
||||||
|
text = text.replaceAll('U', 'V');
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
class AgentMessage {
|
class AgentMessage {
|
||||||
constructor(text, senderName) {
|
constructor(text, senderName) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
@ -109,13 +110,13 @@ class AgentMessage {
|
|||||||
|
|
||||||
if (this.senderName) {
|
if (this.senderName) {
|
||||||
const nameElem = document.createElement("h3");
|
const nameElem = document.createElement("h3");
|
||||||
nameElem.innerHTML = this.senderName;
|
nameElem.innerHTML = romanize(this.senderName);
|
||||||
contentElem.appendChild(nameElem);
|
contentElem.appendChild(nameElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
const textElem = document.createElement("span");
|
const textElem = document.createElement("span");
|
||||||
textElem.className = "message-text";
|
textElem.className = "message-text";
|
||||||
textElem.innerHTML = this.text;
|
textElem.innerHTML = romanize(this.text);
|
||||||
contentElem.appendChild(textElem);
|
contentElem.appendChild(textElem);
|
||||||
|
|
||||||
return liElem;
|
return liElem;
|
||||||
@ -125,7 +126,7 @@ class AgentMessage {
|
|||||||
class UserMessage {
|
class UserMessage {
|
||||||
constructor(text) {
|
constructor(text) {
|
||||||
this.createdTime = Date.now();
|
this.createdTime = Date.now();
|
||||||
this.text = text;
|
this.text = romanize(text);
|
||||||
this.status = "";
|
this.status = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ class UserMessage {
|
|||||||
|
|
||||||
class SystemMessage {
|
class SystemMessage {
|
||||||
constructor(text) {
|
constructor(text) {
|
||||||
this.text = text;
|
this.text = romanize(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIsOurs() {
|
getIsOurs() {
|
||||||
@ -228,7 +229,7 @@ function pressSendButton() {
|
|||||||
|
|
||||||
if (event.type == "keydown" && event.key != "Enter")
|
if (event.type == "keydown" && event.key != "Enter")
|
||||||
{
|
{
|
||||||
textBox.value = text;
|
textBox.value = romanize(text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"title": "SNCF Conrad",
|
"title": "SNCF billetier",
|
||||||
"interactive": true,
|
"interactive": true,
|
||||||
"characters": [
|
"characters": [
|
||||||
"you",
|
"you",
|
||||||
"SNCF Conrad"
|
"SNCF billetier"
|
||||||
],
|
],
|
||||||
"messages":
|
"messages":
|
||||||
[
|
[
|
||||||
|
49
styles.css
49
styles.css
@ -6,12 +6,7 @@
|
|||||||
--bleu: #0055a4;
|
--bleu: #0055a4;
|
||||||
--rouge: #e1000f;
|
--rouge: #e1000f;
|
||||||
|
|
||||||
--rose-de-l-erreur: #f0f;
|
--rose-de-l-erreur: #f0f
|
||||||
|
|
||||||
--navy: #0b131f;
|
|
||||||
--bluegrey: #232b35;
|
|
||||||
--sky: #7bbffd;
|
|
||||||
--bluewhite: #ebebec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
@ -23,7 +18,7 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
background-color: var(--navy);
|
background-color: var(--blanc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#side-panel {
|
#side-panel {
|
||||||
@ -87,7 +82,7 @@ body {
|
|||||||
#header {
|
#header {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
border-bottom: none var(--navy) 3px;
|
border-bottom: solid var(--blanc) 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-panel {
|
#main-panel {
|
||||||
@ -103,7 +98,7 @@ body {
|
|||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
color: var(--bluewhite);
|
color: var(--noir);
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +106,9 @@ h1 {
|
|||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
border: black;
|
border: black;
|
||||||
border-style: none;
|
border-style: none;
|
||||||
border-radius: 1.5em;
|
border-radius: 1em;
|
||||||
|
|
||||||
padding: 1em 1.5em;
|
padding: .6em .8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-content {
|
.message-content {
|
||||||
@ -122,12 +117,10 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.message-content.theirs {
|
.message-content.theirs {
|
||||||
background-color: var(--bluegrey);
|
background-color: var(--bleu);
|
||||||
color: var(--bluewhite);
|
color: var(--blanc);
|
||||||
|
|
||||||
float: left;
|
float: left;
|
||||||
|
|
||||||
border-bottom-left-radius: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-content.theirs h3 {
|
.message-content.theirs h3 {
|
||||||
@ -143,16 +136,14 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.message-content.ours {
|
.message-content.ours {
|
||||||
background-color: var(--sky);
|
background-color: var(--rouge);
|
||||||
|
|
||||||
right: 0;
|
right: 0;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
|
|
||||||
border-bottom-right-radius: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ours .message-text {
|
.ours .message-text {
|
||||||
color: var(--bluegrey);
|
color: var(--blanc);
|
||||||
}
|
}
|
||||||
|
|
||||||
.system-message {
|
.system-message {
|
||||||
@ -194,7 +185,7 @@ li.message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#typing-indicator {
|
#typing-indicator {
|
||||||
color: var(--bluewhite);
|
color: var(--gris);
|
||||||
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
@ -207,9 +198,9 @@ li.message {
|
|||||||
#textbox input {
|
#textbox input {
|
||||||
flex-grow: 4;
|
flex-grow: 4;
|
||||||
|
|
||||||
color: var(--bluewhite);
|
color: var(--noir);
|
||||||
background-color: var(--bluegrey);
|
background-color: var(--blanc);
|
||||||
border-color: var(--bluegrey);
|
border-color: var(--gris);
|
||||||
border-width: 3px;
|
border-width: 3px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
|
|
||||||
@ -222,8 +213,8 @@ li.message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
background-color: var(--sky);
|
background-color: var(--rouge);
|
||||||
color: var(--bluegrey);
|
color: var(--blanc);
|
||||||
|
|
||||||
margin: 0.5em;
|
margin: 0.5em;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -235,16 +226,16 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
button:hover {
|
button:hover {
|
||||||
color: var(--bluewhite);
|
color: var(--rouge);
|
||||||
background-color: var(--bluegrey);
|
background-color: var(--blanc);
|
||||||
border-color: var(--bluegrey);
|
border-color: var(--rouge);
|
||||||
border-width: 3px;
|
border-width: 3px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-status {
|
.message-status {
|
||||||
color: var(--bluewhite);
|
color: var(--gris);
|
||||||
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: -1.75em;
|
bottom: -1.75em;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user