A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.9 KiB

  1. import { Controller } from "./controller/AbstractController";
  2. import { UserModel } from "./model/UserModel"
  3. import { Model } from "./model/AbstractModel";
  4. import { View } from "./view/AbstractView";
  5. import { UserView } from "./view/UserView";
  6. import { UserController } from "./controller/UserController";
  7. import { ModelFactory } from "./model/ModelFactory";
  8. import { ActiveUserViewModel } from "./viewmodel/ActiveUserViewModel";
  9. import { ChatMessageViewModel } from "./viewmodel/ChatMessageViewModel";
  10. import * as Handlebars from "handlebars";
  11. import markdownit = require('markdown-it');
  12. import { ChatModel } from "./model/ChatModel";
  13. import { ChatView } from "./view/ChatView";
  14. import { ChatController } from "./controller/ChatController";
  15. import { JsonAPI } from "./singleton/JsonAPI";
  16. // import log = require('loglevel')
  17. import * as log from 'loglevel';
  18. // import log from 'loglevel';
  19. import { EncryptionService } from "./service/EncryptionService";
  20. import { SJCLEncryptionService } from "./service/SJCLEncryptionService";
  21. // var markdownit = require('markdown-it');
  22. var md = new markdownit();
  23. const userBox = document.getElementById('contacts-box');
  24. log.setLevel("TRACE")
  25. const chatModel = new ChatModel();
  26. const userModel = new UserModel();
  27. // const userModel = ModelFactory.createModel("USER");
  28. // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
  29. const userView = new UserView(userModel, chatModel, userBox);
  30. // console.log(userBox);
  31. userModel.attach(userView);
  32. // userView.model
  33. const userController = new UserController(userModel, userView);
  34. // userController.test();
  35. // userModel.someBusinessMethod(activeUsersMock);
  36. log.info("hello");
  37. const chatArea = document.getElementById('chat-area-new');
  38. // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
  39. const chatView = new ChatView(chatModel, chatArea);
  40. chatModel.attach(chatView);
  41. const chatController = new ChatController(chatModel, chatView);
  42. function someFunc(vm: ActiveUserViewModel): void {
  43. // log.info(vm);
  44. // logger.info(vm)
  45. }
  46. userController.getActiveUsers();
  47. log.info("test");
  48. // someFunc(activeUserViewModelMock);
  49. // @ts-ignore: Object is possibly 'null'.
  50. var source = document.getElementById("msg_container_template").innerHTML;
  51. var msgContainerTemplate = Handlebars.compile(source);
  52. JsonAPI.ACTIVE_USERS_GET + 'aef';
  53. const encryptionService: EncryptionService = new SJCLEncryptionService();
  54. let ct = encryptionService.encrypt("password","data");
  55. console.log(encryptionService.decrypt("password", JSON.parse(ct as string)));
  56. Handlebars.registerHelper('avatar', function() {
  57. 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>';
  58. });