@ -21,12 +21,20 @@ import { FuseSearchService } from "./service/FuseSearchService";
import { ChatMessageDTO } from "./dto/ChatMessageDTO" ;
import { ChatMessageDTO } from "./dto/ChatMessageDTO" ;
import { NotificationService } from "./service/NotificationService" ;
import { NotificationService } from "./service/NotificationService" ;
import { AlertifyNotificationService } from "./service/AlertifyNotificationService" ;
import { AlertifyNotificationService } from "./service/AlertifyNotificationService" ;
import * as sprintf2 from "sprintf-js" ;
///<reference path="./SprintfTest.d.ts" />
// import "./SprintfTest.d.ts"
// import { sprintf } from "sprintf-js";
// import sprintf = require('sprintf-js');
import { TemplateFactory } from "./template/TemplateFactory" ;
import { UserViewDeps } from "./view/UserViewDeps" ;
import { ChatViewDeps } from "./view/ChatViewDeps" ;
import { MarkDownItMarkDownService } from "./service/MarkDownItMarkDownService" ;
const usersListElement = document . getElementById ( 'contacts-box' ) ;
const usersListElement = document . getElementById ( 'contacts-box' ) ;
const userSearchButton = document . getElementById ( 'user-search' ) ;
const userSearchButton = document . getElementById ( 'user-search' ) ;
const userSearchInputElement = document . getElementById ( 'user-search-term' )
const userSearchCancelButton = document . getElementById ( 'user-search-cancel' )
const userSearchInputElement = document . getElementById ( 'user-search-term' ) as HTMLInputElement ;
const userSearchCancelButton = document . getElementById ( 'user-search-cancel' ) ;
const searchService : SearchService < ActiveUserViewModel > = new FuseSearchService ( [ "userName" ] ) ;
log . setLevel ( "TRACE" )
log . setLevel ( "TRACE" )
@ -34,8 +42,22 @@ const chatModel = new ChatModel();
const userModel = new UserModel ( ) ;
const userModel = new UserModel ( ) ;
// const userModel = ModelFactory.createModel("USER");
// const userModel = ModelFactory.createModel("USER");
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
const userView = new UserView ( userModel , chatModel , usersListElement , userSearchInputElement , userSearchButton , userSearchCancelButton ) ;
const uvDeps : UserViewDeps = {
model : userModel ,
chatModel : chatModel ,
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
usersListElement : usersListElement ,
userSearchInputElement : userSearchInputElement ,
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
userSearchButton : userSearchButton ,
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
userSearchCancelButton : userSearchCancelButton ,
searchService : searchService ,
userContactOnlineTemplate : TemplateFactory.getTemplate ( 'user-contact-online-template' ) ,
userContactOfflineTemplate : TemplateFactory.getTemplate ( 'user-contact-offline-template' )
}
const userView = new UserView ( uvDeps ) ;
// console.log(userBox);
// console.log(userBox);
@ -53,7 +75,17 @@ log.info("hello");
const chatArea = document . getElementById ( 'chat-area-new' ) ;
const chatArea = document . getElementById ( 'chat-area-new' ) ;
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
const chatView = new ChatView ( chatModel , chatArea ) ;
const cvDeps : ChatViewDeps = {
chatModel : chatModel ,
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
messageContainer : chatArea ,
messageSendTemplate : TemplateFactory.getTemplate ( 'msg_container_send_template' ) ,
messageReceiveTemplate : TemplateFactory.getTemplate ( 'msg_container_template' ) ,
markdownService : new MarkDownItMarkDownService ,
encryptionService : new SJCLEncryptionService
}
const chatView = new ChatView ( cvDeps ) ;
chatModel . attach ( chatView ) ;
chatModel . attach ( chatView ) ;
const chatController = new ChatController ( chatModel , chatView ) ;
const chatController = new ChatController ( chatModel , chatView ) ;
@ -76,18 +108,20 @@ var msgContainerTemplate = Handlebars.compile(source);
JsonAPI . ACTIVE_USERS_GET + 'aef' ;
JsonAPI . ACTIVE_USERS_GET + 'aef' ;
const encryptionService : EncryptionService = new SJCLEncryptionService ( ) ;
const encryptionService : EncryptionService = new SJCLEncryptionService ( ) ;
let messageCipherDTO : MessageCipherDTO = encryptionService . encrypt ( "password" , "data" ) ;
let messageCipherDTO : MessageCipherDTO = encryptionService . encrypt ( "password" , "data" ) ;
console . log ( encryptionService . decrypt ( "password" , messageCipherDTO ) ) ;
console . log ( encryptionService . decrypt ( "password" , messageCipherDTO ) ) ;
Handlebars . registerHelper ( 'avatar' , function ( ) {
Handlebars . registerHelper ( 'avatar' , function ( ) {
return '<div class="img_cont_msg"> <img src="https://static.turbosquid.com/Preview/001292/481/WV/_D.jpg" class="rounded-circle user_img_msg"> </div>' ;
return '<div class="img_cont_msg"> <img src="https://static.turbosquid.com/Preview/001292/481/WV/_D.jpg" class="rounded-circle user_img_msg"> </div>' ;
} ) ;
} ) ;
const testList : ChatMessageDTO [ ] = [ ] ;
const testList : ChatMessageDTO [ ] = [ ] ;
const cmSearchService : SearchService < ChatMessageDTO > = new FuseSearchService ( [ "userName" ] ) ;
// @ts-ignore
console . log ( )
// @ts-ignore
// @ts-ignore
log . info ( sprintf ( "test sprintf" ) )
log . info ( sprintf2 . sprintf ( "test sprintf" ) )
log . info ( S printf( "test sprintf" ) )
// log.info(sprintf2.sprintf("test sprintf"))
const ns : NotificationService = new AlertifyNotificationService ( ) ;
const ns : NotificationService = new AlertifyNotificationService ( ) ;
ns . success ( "Welcome" ) ;
ns . success ( "Welcome" ) ;
// ns.errorWithDelay("Hmm very long error notif", 10);
// ns.errorWithDelay("Hmm very long error notif", 10);