Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: chat: add blinking title on new message #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions static/html/joinchat.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/md5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/js/materialize.min.js"></script>
<script src="/js/lib/PageTitleNotification.js"></script>
<script src="/js/chat/chat.js"></script>
</body>
</html>
13 changes: 12 additions & 1 deletion static/js/chat/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const EventConnInitOk = 0;
const EventConnInitNoSuchChat = 1;
const EventConnInitMaxUsrsReached = 2;

const NewMsgTitle = "New message!";

window.onfocus = function() {
pageTitleNotification.off();
}

new Vue({
el: '#app',

Expand All @@ -16,6 +22,8 @@ new Vue({
okconnected: true, // True if email and username have been filled in
fail: false,
name: '',
onPage: false,
newMessagesNum: 0,
},
created: function() {
var self = this;
Expand Down Expand Up @@ -46,6 +54,9 @@ new Vue({
},
methods: {
addmsg: function(msg){
if (document.hidden) {
pageTitleNotification.on(NewMsgTitle);
}
this.chatContent += '<div class="chip" >'
+ '<img src="' + this.roboHash(msg.username) + '">' // Avatar
+ msg.username
Expand Down Expand Up @@ -80,4 +91,4 @@ function getParameterByName(name, url) {
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
}
1 change: 1 addition & 0 deletions static/js/lib/PageTitleNotification.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.