From 0226271045b1d79100cb8225af0384d88ae3edef Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 13 May 2014 17:34:11 +0200 Subject: [PATCH] Move getRole to a function Will probably be used elsewhere soon --- public/js/vroom.js | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/public/js/vroom.js b/public/js/vroom.js index 648795e..ea2e8e0 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -91,24 +91,6 @@ function initVroom(room) { dataType: 'json', }); - // get our role (participant or owner) - $.ajax({ - data: { - action: 'getRole', - room: roomName - }, - error: function(data) { - $.notify(locale.ERROR_OCCURED, 'error'); - }, - success: function(data) { - peers.local.role = data.msg; - // Enable owner reserved menu - if (data.msg == 'owner'){ - $('.ownerEl').show(500); - } - } - }); - // Screen sharing is only suported on chrome > 26 if ( !$.browser.webkit || $.browser.versionNumber < 26 ) { $("#shareScreenLabel").addClass('disabled'); @@ -127,6 +109,29 @@ function initVroom(room) { return string; } + // Update our role + function updateRole() { + $.ajax({ + data: { + action: 'getRole', + room: roomName + }, + error: function(data) { + $.notify(locale.ERROR_OCCURED, 'error'); + }, + success: function(data) { + peers.local.role = data.msg; + // Enable owner reserved menu + if (data.msg == 'owner'){ + $('.ownerEl').show(500); + } + else{ + $('.ownerEl').hide(500); + } + } + }); + } + // Select a color (randomly) from this list, used for text chat function chooseColor(){ // Shamelessly taken from http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/ @@ -759,6 +764,9 @@ function initVroom(room) { } }); + // Check if we are the owner of the room + updateRole(); + // Ping the room every minutes // Used to detect inactive rooms setInterval(function pingRoom(){