Skip to content

Commit c559585

Browse files
authored
signout btn
1 parent 60914d8 commit c559585

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

chat/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -915,10 +915,10 @@ <h2>Live Chat</h2>
915915

916916
<div class="dropdown">
917917
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
918-
Dropdown button
918+
:
919919
</button>
920920
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
921-
<li><a class="dropdown-item" href="#">Action</a></li>
921+
<li><a class="dropdown-item" href="#" id="sign-out">Sign Out</a></li>
922922
<li><a class="dropdown-item" href="#">Another action</a></li>
923923
<li><a class="dropdown-item" href="#">Something else here</a></li>
924924
</ul>

chat/main.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,20 @@ function loginUser(user) {
7575

7676
function open_chat() {
7777
if (window.localStorage.getItem('user')) {
78-
alert('You are ready to start chatting with me.');
78+
// alert('You are ready to start chatting with me.');
7979
$('#login').addClass('d-none');
8080
$('#chat').removeClass('d-none');
8181
}
8282
else {
83-
alert('Please login first.');
83+
// alert('Please login first.');
8484
$('#login').removeClass('d-none');
8585
$('#chat').addClass('d-none');
8686
};
8787
}
88-
open_chat();
88+
open_chat();
89+
90+
$('body').on('click','#sign-out',function(e){
91+
e.preventDefault();
92+
window.localStorage.removeItem('user');
93+
window.location.reload();
94+
})

0 commit comments

Comments
 (0)