diff --git a/index.html b/index.html
index e69de29..b6f5ea2 100644
--- a/index.html
+++ b/index.html
@@ -0,0 +1,14 @@
+
+
+
+ LocalChat
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/js/models/chat.js b/js/models/chat.js
new file mode 100644
index 0000000..1456092
--- /dev/null
+++ b/js/models/chat.js
@@ -0,0 +1,19 @@
+class Chat{
+ constructor(userId1,userId2){
+ this.id=Chat.generateChatId();
+ this.user1Typing=false;
+ this.user2Typing=false;
+ this.messages=[];
+ }
+
+ static generateChatId(userId1,userId2){
+ if(userId1>userId2){
+ return userId1+'-'+userId2;
+ }
+ else{
+ return userId1+'-'+userId2;
+ }
+ }
+}
+
+export default Chat;
\ No newline at end of file
diff --git a/js/models/group.js b/js/models/group.js
new file mode 100644
index 0000000..e69de29
diff --git a/js/models/message.js b/js/models/message.js
new file mode 100644
index 0000000..a3891e3
--- /dev/null
+++ b/js/models/message.js
@@ -0,0 +1,9 @@
+class Message{
+ constructor(content,senderId,replyTo){
+ this.id=Math.floor(Math.random()*99999);
+ this.content=content;
+ this.senderId=senderId;
+ this.replyTo=replyTo;
+ this.timestamp=Date.now();
+ }
+}
\ No newline at end of file
diff --git a/js/models/user.js b/js/models/user.js
new file mode 100644
index 0000000..62258b0
--- /dev/null
+++ b/js/models/user.js
@@ -0,0 +1,23 @@
+import LocalStorageService from "../services/local-storage.js";
+
+class User{
+ constructor(username,password){
+
+ this.id=User.generateUserId();
+ this.username=username;
+ this.password=password;
+ this.isLoggedIn=false;
+ this.isOnline=false;
+ }
+
+ static isUserNameUnique(username){
+ let users=LocalStorageService.getUsers();
+ return !(users.find(user=>user.username===username));
+ }
+
+ static generateUserId(){
+ return LocalStorageService.getUsers().length+1;
+ }
+}
+
+export default User;
\ No newline at end of file
diff --git a/js/services/local-storage.js b/js/services/local-storage.js
index e1b3771..4bed3e5 100644
--- a/js/services/local-storage.js
+++ b/js/services/local-storage.js
@@ -7,18 +7,25 @@ class LocalStorageService{
let users=JSON.parse(localStorage.getItem('users'))||[];
const user=new User(username,password);
users.push(user);
- localStorage.setItem(JSON.stringify(users));
+ localStorage.setItem('users',JSON.stringify(users));
}
static createChat(userId1,userId2){
let chats=JSON.parse(localStorage.getItem('chats'));
let chat=new Chat(userId1,userId2);
chats.push(chat);
- localStorage.setItem(JSON.stringify(chats));
+ localStorage.setItem('chats',JSON.stringify(chats));
}
static createGroup(){
}
-}
\ No newline at end of file
+ static getUsers(){
+ return JSON.parse(localStorage.getItem('users'))||[];
+ }
+
+}
+
+
+export default LocalStorageService;
\ No newline at end of file
diff --git a/js/services/session-manager.js b/js/services/session-manager.js
new file mode 100644
index 0000000..21d8efb
--- /dev/null
+++ b/js/services/session-manager.js
@@ -0,0 +1,37 @@
+import LocalStorageService from "./local-storage.js";
+
+class SessionManager{
+
+ static Login(username,password){
+ let users=LocalStorageService.getUsers();
+ user=users.find(user=>(user.username===username && user.password===password));
+ if(user){
+ user.isLoggedIn=true;
+ user.isOnline=true;
+
+ sessionStorage.setItem('user',JSON.stringify(user));
+ return user;
+ }
+
+ return false;
+ }
+
+
+ static Logout(user){
+ user.isLoggedIn=false;
+ user.isOnline=false;
+ sessionStorage.removeItem('user');
+ }
+
+
+ static setTestValue(){
+ sessionStorage.setItem('test','test value');
+ }
+
+ static getTestValue(){
+ console.log(sessionStorage.getItem('test'));
+ }
+}
+
+
+export default SessionManager;
\ No newline at end of file