Create base call window

This commit is contained in:
2020-04-10 13:18:26 +02:00
parent a59b9b6441
commit 119a6f1626
5 changed files with 75 additions and 1 deletions

View File

@ -4,6 +4,11 @@
* @author Pierre Hubert
*/
/**
* @type {Map<number, CallWindow>}
*/
let OpenConversations = new Map();
class CallsController {
/**
@ -12,7 +17,14 @@ class CallsController {
* @param {Conversation} conv Information about the target conversation
*/
static Open(conv) {
alert("Open call for conversation " + conv.ID);
if(OpenConversations.has(conv.ID))
return;
console.info("Open call for conversation " + conv.ID);
// Create a new window for the conversation
const window = new CallWindow(conv);
OpenConversations.set(conv.ID, window)
}
}

View File

@ -0,0 +1,55 @@
/**
* Calls window
*
* @author Pierre Hubert
*/
class CallWindow {
/**
* Create a new call window
*
* @param {Conversation} conv Information about the target conversation
*/
constructor(conv) {
this.construct(conv);
}
async construct(conv) {
// Check if calls target exists or not
if(!byId("callsTarget"))
createElem2({
appendTo: byId("wrapper"),
type: "div",
id: "callsTarget",
})
this.conv = conv;
this.rootEl = createElem2({
appendTo: byId("callsTarget"),
type: "div",
class: "call-window"
})
// Construct head
const windowHead = createElem2({
appendTo: this.rootEl,
type: "div",
class: "head",
innerHTML: "<i class='fa fa-phone'></i>" +
await getConvName(conv) +
" <span class='pull-right'></span>"
})
// Close button
this.closeButton = createElem2({
appendTo: windowHead.querySelector(".pull-right"),
type: "a",
innerHTML: "<i class='fa fa-cross'></i>"
})
}
}

6
assets/js/jsconfig.json Normal file
View File

@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
}
}

39
assets/js/typings/Utils.d.ts vendored Normal file
View File

@ -0,0 +1,39 @@
/**
* Typescript typing rules for Utils
*
* @author Pierre HUBERT
*/
declare interface CreateElem2Args {
type : string,
appendTo ?: HTMLElement,
insertBefore ?: HTMLElement,
insertAsFirstChild ?: HTMLElement,
class ?: string,
id ?: string,
title ?: string,
src ?: string,
href ?: string,
internalHref ?: string,
name ?: string,
elemType ?: string,
value ?: string,
placeholder ?: string,
innerHTML ?: string,
innerLang ?: string,
innerHTMLprefix ?: string,
disabled ?: boolean,
children ?: HTMLElement[],
onclick ?: Function,
ondblclick ?: Function
}
declare function createElem(nodeType : string, appendTo : string) : HTMLElement;
declare function createElem2(infos : CreateElem2Args) : HTMLElement;
declare function byId(id : string) : HTMLElement;
declare function emptyElem(target : HTMLElement) : void;
declare function checkMail(emailAddress : string) : boolean;