Adds you're about to leave this page warning.

This commit is contained in:
Yana Stamcheva 2013-12-20 15:19:17 +01:00
parent 979c8b8b12
commit 828fe6afe7
1 changed files with 37 additions and 0 deletions

37
app.js
View File

@ -8,6 +8,8 @@ var nickname = null;
var sharedKey = ''; var sharedKey = '';
var roomUrl = null; var roomUrl = null;
window.onbeforeunload = closePageWarning;
function init() { function init() {
RTC = setupRTC(); RTC = setupRTC();
if (RTC === null) { if (RTC === null) {
@ -329,6 +331,9 @@ $(window).bind('beforeunload', function () {
} }
}); });
/*
* Appends the given message to the chat conversation.
*/
function updateChatConversation(nick, message) function updateChatConversation(nick, message)
{ {
var divClassName = ''; var divClassName = '';
@ -341,10 +346,16 @@ function updateChatConversation(nick, message)
$('#chatconversation').animate({ scrollTop: $('#chatconversation')[0].scrollHeight}, 1000); $('#chatconversation').animate({ scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
} }
/*
* Changes the style class of the element given by id.
*/
function buttonClick(id, classname) { function buttonClick(id, classname) {
$(id).toggleClass(classname); // add the class to the clicked element $(id).toggleClass(classname); // add the class to the clicked element
} }
/*
* Opens the lock room dialog.
*/
function openLockDialog() { function openLockDialog() {
if (sharedKey) if (sharedKey)
$.prompt("Are you sure you would like to remove your secret key?", $.prompt("Are you sure you would like to remove your secret key?",
@ -386,6 +397,9 @@ function openLockDialog() {
}); });
} }
/*
* Opens the invite link dialog.
*/
function openLinkDialog() { function openLinkDialog() {
$.prompt('<input id="inviteLinkRef" type="text" value="' + roomUrl + '" onclick="this.select();">', $.prompt('<input id="inviteLinkRef" type="text" value="' + roomUrl + '" onclick="this.select();">',
{ {
@ -398,12 +412,18 @@ function openLinkDialog() {
}); });
} }
/*
* Locks / unlocks the room.
*/
function lockRoom(lock) { function lockRoom(lock) {
connection.emuc.lockRoom(sharedKey); connection.emuc.lockRoom(sharedKey);
buttonClick("#lockIcon", "fa fa-unlock fa-lg fa fa-lock fa-lg"); buttonClick("#lockIcon", "fa fa-unlock fa-lg fa fa-lock fa-lg");
} }
/*
* Opens / closes the chat area.
*/
function openChat() { function openChat() {
var chatspace = $('#chatspace'); var chatspace = $('#chatspace');
var videospace = $('#videospace'); var videospace = $('#videospace');
@ -427,10 +447,27 @@ function openChat() {
$('#usermsg').focus(); $('#usermsg').focus();
} }
/*
* Shows the call main toolbar.
*/
function showToolbar() { function showToolbar() {
$('#toolbar').css({visibility:"visible"}); $('#toolbar').css({visibility:"visible"});
} }
/*
* Updates the room invite url.
*/
function updateRoomUrl(newRoomUrl) { function updateRoomUrl(newRoomUrl) {
roomUrl = newRoomUrl; roomUrl = newRoomUrl;
} }
/*
* Warning to the user that the conference window is about to be closed.
*/
function closePageWarning() {
if (focus != null)
return "You are the owner of this conference call and you are about to end it.";
else
return "You are about to leave this conversation.";
}