36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import ClientController from '../client-controller';
|
|
import { Message } from '../data-types';
|
|
import Q from '../q-module';
|
|
import createImageResourceMessage from './msg-img-res';
|
|
import createImageResourceMessageContinued from './msg-img-res-cont';
|
|
import createResourceMessage from './msg-res';
|
|
import createResourceMessageContinued from './msg-res-cont';
|
|
import createTextMessage from './msg-txt';
|
|
import createTextMessageContinued from './msg-txt-cont';
|
|
|
|
export default function createMessage(document: Document, q: Q, server: ClientController, message: Message, lastMessage: Message | null): HTMLElement {
|
|
let element: HTMLElement;
|
|
if (message.hasResource()) {
|
|
if (message.isImageResource()) {
|
|
if (message.isContinued(lastMessage)) {
|
|
element = createImageResourceMessageContinued(document, q, server, message);
|
|
} else {
|
|
element = createImageResourceMessage(document, q, server, message);
|
|
}
|
|
} else {
|
|
if (message.isContinued(lastMessage)) {
|
|
element = createResourceMessageContinued(q, server, message);
|
|
} else {
|
|
element = createResourceMessage(q, server, message);
|
|
}
|
|
}
|
|
} else {
|
|
if (message.isContinued(lastMessage)) {
|
|
element = createTextMessageContinued(q, server, message);
|
|
} else {
|
|
element = createTextMessage(q, server, message);
|
|
}
|
|
}
|
|
return element;
|
|
}
|