From 29b3ea07e08e84e9574d079beecbebd35d8123cb Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Fri, 23 Jan 2015 14:01:44 +0200 Subject: [PATCH] Removes util.js. Fixes prezi. --- index.html | 1 - libs/modules/UI.bundle.js | 450 ++++++++++++++++-- libs/modules/xmpp.bundle.js | 19 +- modules/UI/prezi/Prezi.js | 3 +- modules/UI/prezi/PreziPlayer.js | 2 + modules/UI/side_pannels/chat/Chat.js | 23 +- modules/UI/side_pannels/chat/Commands.js | 4 +- .../UI/side_pannels/settings/SettingsMenu.js | 5 +- modules/UI/toolbars/Toolbar.js | 4 +- modules/UI/util/UIUtil.js | 58 +++ modules/UI/videolayout/VideoLayout.js | 12 +- modules/xmpp/moderator.js | 19 +- util.js | 91 ---- 13 files changed, 526 insertions(+), 165 deletions(-) delete mode 100644 util.js diff --git a/index.html b/index.html index 10703d5e5..699757a06 100644 --- a/index.html +++ b/index.html @@ -31,7 +31,6 @@ - diff --git a/libs/modules/UI.bundle.js b/libs/modules/UI.bundle.js index d47ca49a1..13fe2a7c9 100644 --- a/libs/modules/UI.bundle.js +++ b/libs/modules/UI.bundle.js @@ -702,7 +702,7 @@ UI.clickOnVideo = function (videoNumber) { module.exports = UI; -},{"./audio_levels/AudioLevels.js":2,"./authentication/Authentication":4,"./avatar/Avatar":5,"./etherpad/Etherpad.js":6,"./prezi/Prezi.js":7,"./side_pannels/SidePanelToggler":8,"./side_pannels/chat/Chat.js":9,"./side_pannels/contactlist/ContactList":13,"./side_pannels/settings/Settings":14,"./side_pannels/settings/SettingsMenu":15,"./toolbars/BottomToolbar":16,"./toolbars/Toolbar":17,"./toolbars/ToolbarToggler":18,"./util/MessageHandler":20,"./util/NicknameHandler":21,"./util/UIUtil":22,"./videolayout/VideoLayout.js":24,"./welcome_page/RoomnameGenerator":25,"./welcome_page/WelcomePage":26,"events":27}],2:[function(require,module,exports){ +},{"./audio_levels/AudioLevels.js":2,"./authentication/Authentication":4,"./avatar/Avatar":5,"./etherpad/Etherpad.js":6,"./prezi/Prezi.js":7,"./side_pannels/SidePanelToggler":9,"./side_pannels/chat/Chat.js":10,"./side_pannels/contactlist/ContactList":14,"./side_pannels/settings/Settings":15,"./side_pannels/settings/SettingsMenu":16,"./toolbars/BottomToolbar":17,"./toolbars/Toolbar":18,"./toolbars/ToolbarToggler":19,"./util/MessageHandler":21,"./util/NicknameHandler":22,"./util/UIUtil":23,"./videolayout/VideoLayout.js":25,"./welcome_page/RoomnameGenerator":26,"./welcome_page/WelcomePage":27,"events":28}],2:[function(require,module,exports){ var CanvasUtil = require("./CanvasUtils"); /** @@ -1319,7 +1319,7 @@ var Avatar = { module.exports = Avatar; -},{"../side_pannels/settings/Settings":14,"../videolayout/VideoLayout":24}],6:[function(require,module,exports){ +},{"../side_pannels/settings/Settings":15,"../videolayout/VideoLayout":25}],6:[function(require,module,exports){ /* global $, config, dockToolbar, setLargeVideoVisible, Util */ @@ -1515,11 +1515,12 @@ var Etherpad = { module.exports = Etherpad; -},{"../prezi/Prezi":7,"../util/UIUtil":22,"../videolayout/VideoLayout":24}],7:[function(require,module,exports){ +},{"../prezi/Prezi":7,"../util/UIUtil":23,"../videolayout/VideoLayout":25}],7:[function(require,module,exports){ var ToolbarToggler = require("../toolbars/ToolbarToggler"); var UIUtil = require("../util/UIUtil"); var VideoLayout = require("../videolayout/VideoLayout"); var messageHandler = require("../util/MessageHandler"); +var PreziPlayer = require("./PreziPlayer"); var preziPlayer = null; @@ -1591,7 +1592,7 @@ var Prezi = { if (preziUrl.value) { var urlValue - = encodeURI(Util.escapeHtml(preziUrl.value)); + = encodeURI(UIUtil.escapeHtml(preziUrl.value)); if (urlValue.indexOf('http://prezi.com/') != 0 && urlValue.indexOf('https://prezi.com/') != 0) @@ -1867,7 +1868,302 @@ $(window).resize(function () { module.exports = Prezi; -},{"../toolbars/ToolbarToggler":18,"../util/MessageHandler":20,"../util/UIUtil":22,"../videolayout/VideoLayout":24}],8:[function(require,module,exports){ +},{"../toolbars/ToolbarToggler":19,"../util/MessageHandler":21,"../util/UIUtil":23,"../videolayout/VideoLayout":25,"./PreziPlayer":8}],8:[function(require,module,exports){ +(function() { + "use strict"; + var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + + window.PreziPlayer = (function() { + + PreziPlayer.API_VERSION = 1; + PreziPlayer.CURRENT_STEP = 'currentStep'; + PreziPlayer.CURRENT_ANIMATION_STEP = 'currentAnimationStep'; + PreziPlayer.CURRENT_OBJECT = 'currentObject'; + PreziPlayer.STATUS_LOADING = 'loading'; + PreziPlayer.STATUS_READY = 'ready'; + PreziPlayer.STATUS_CONTENT_READY = 'contentready'; + PreziPlayer.EVENT_CURRENT_STEP = "currentStepChange"; + PreziPlayer.EVENT_CURRENT_ANIMATION_STEP = "currentAnimationStepChange"; + PreziPlayer.EVENT_CURRENT_OBJECT = "currentObjectChange"; + PreziPlayer.EVENT_STATUS = "statusChange"; + PreziPlayer.EVENT_PLAYING = "isAutoPlayingChange"; + PreziPlayer.EVENT_IS_MOVING = "isMovingChange"; + PreziPlayer.domain = "https://prezi.com"; + PreziPlayer.path = "/player/"; + PreziPlayer.players = {}; + PreziPlayer.binded_methods = ['changesHandler']; + + PreziPlayer.createMultiplePlayers = function(optionArray){ + for(var i=0; i 0 && + obj.values.animationCountOnSteps && + obj.values.animationCountOnSteps[step] <= animation_step) { + animation_step = obj.values.animationCountOnSteps[step]; + } + // jump to animation steps by calling flyToNextStep() + function doAnimationSteps() { + if (obj.values.isMoving == true) { + setTimeout(doAnimationSteps, 100); // wait until the flight ends + return; + } + while (animation_step-- > 0) { + obj.flyToNextStep(); // do the animation steps + } + } + setTimeout(doAnimationSteps, 200); // 200ms is the internal "reporting" time + // jump to the step + return this.sendMessage({ + 'action': 'present', + 'data': ['moveToStep', step] + }); + }; + + PreziPlayer.prototype.toObject = /* toObject is DEPRECATED */ + PreziPlayer.prototype.flyToObject = function(objectId) { + return this.sendMessage({ + 'action': 'present', + 'data': ['moveToObject', objectId] + }); + }; + + PreziPlayer.prototype.play = function(defaultDelay) { + return this.sendMessage({ + 'action': 'present', + 'data': ['startAutoPlay', defaultDelay] + }); + }; + + PreziPlayer.prototype.stop = function() { + return this.sendMessage({ + 'action': 'present', + 'data': ['stopAutoPlay'] + }); + }; + + PreziPlayer.prototype.pause = function(defaultDelay) { + return this.sendMessage({ + 'action': 'present', + 'data': ['pauseAutoPlay', defaultDelay] + }); + }; + + PreziPlayer.prototype.getCurrentStep = function() { + return this.values.currentStep; + }; + + PreziPlayer.prototype.getCurrentAnimationStep = function() { + return this.values.currentAnimationStep; + }; + + PreziPlayer.prototype.getCurrentObject = function() { + return this.values.currentObject; + }; + + PreziPlayer.prototype.getStatus = function() { + return this.values.status; + }; + + PreziPlayer.prototype.isPlaying = function() { + return this.values.isAutoPlaying; + }; + + PreziPlayer.prototype.getStepCount = function() { + return this.values.stepCount; + }; + + PreziPlayer.prototype.getAnimationCountOnSteps = function() { + return this.values.animationCountOnSteps; + }; + + PreziPlayer.prototype.getTitle = function() { + return this.values.title; + }; + + PreziPlayer.prototype.setDimensions = function(dims) { + for (var parameter in dims) { + this.iframe[parameter] = dims[parameter]; + } + } + + PreziPlayer.prototype.getDimensions = function() { + return { + width: parseInt(this.iframe.width, 10), + height: parseInt(this.iframe.height, 10) + } + } + + PreziPlayer.prototype.on = function(event, callback) { + this.callbacks.push({ + event: event, + callback: callback + }); + }; + + PreziPlayer.prototype.off = function(event, callback) { + var j, item; + if (event === undefined) { + this.callbacks = []; + } + j = this.callbacks.length; + while (j--) { + item = this.callbacks[j]; + if (item && item.event === event && (callback === undefined || item.callback === callback)){ + this.callbacks.splice(j, 1); + } + } + }; + + if (window.addEventListener) { + window.addEventListener('message', PreziPlayer.messageReceived, false); + } else { + window.attachEvent('onmessage', PreziPlayer.messageReceived); + } + + return PreziPlayer; + + })(); + +})(); + +module.exports = PreziPlayer; + +},{}],9:[function(require,module,exports){ var Chat = require("./chat/Chat"); var ContactList = require("./contactlist/ContactList"); var Settings = require("./settings/Settings"); @@ -2124,13 +2420,14 @@ var PanelToggler = (function(my) { }(PanelToggler || {})); module.exports = PanelToggler; -},{"../toolbars/ToolbarToggler":18,"../util/UIUtil":22,"../videolayout/VideoLayout":24,"./chat/Chat":9,"./contactlist/ContactList":13,"./settings/Settings":14,"./settings/SettingsMenu":15}],9:[function(require,module,exports){ +},{"../toolbars/ToolbarToggler":19,"../util/UIUtil":23,"../videolayout/VideoLayout":25,"./chat/Chat":10,"./contactlist/ContactList":14,"./settings/Settings":15,"./settings/SettingsMenu":16}],10:[function(require,module,exports){ /* global $, Util, nickname:true, showToolbar */ var Replacement = require("./Replacement"); var CommandsProcessor = require("./Commands"); var ToolbarToggler = require("../../toolbars/ToolbarToggler"); var smileys = require("./smileys.json").smileys; var NicknameHandler = require("../../util/NicknameHandler"); +var UIUtil = require("../../util/UIUtil"); var notificationInterval = false; var unreadMessages = 0; @@ -2155,10 +2452,10 @@ function setVisualNotification(show) { var chatButtonElement = document.getElementById('chatButton').parentNode; - var leftIndent = (Util.getTextWidth(chatButtonElement) - - Util.getTextWidth(unreadMsgElement)) / 2; - var topIndent = (Util.getTextHeight(chatButtonElement) - - Util.getTextHeight(unreadMsgElement)) / 2 - 3; + var leftIndent = (UIUtil.getTextWidth(chatButtonElement) - + UIUtil.getTextWidth(unreadMsgElement)) / 2; + var topIndent = (UIUtil.getTextHeight(chatButtonElement) - + UIUtil.getTextHeight(unreadMsgElement)) / 2 - 3; unreadMsgElement.setAttribute( 'style', @@ -2306,7 +2603,7 @@ var Chat = (function (my) { $('#nickinput').keydown(function (event) { if (event.keyCode === 13) { event.preventDefault(); - var val = Util.escapeHtml(this.value); + var val = UIUtil.escapeHtml(this.value); this.value = ''; if (!NicknameHandler.getNickname()) { NicknameHandler.setNickname(val); @@ -2329,7 +2626,7 @@ var Chat = (function (my) { } else { - var message = Util.escapeHtml(value); + var message = UIUtil.escapeHtml(value); xmpp.sendChatMessage(message, NicknameHandler.getNickname()); } } @@ -2364,7 +2661,7 @@ var Chat = (function (my) { if (!Chat.isVisible()) { unreadMessages++; - Util.playSoundNotification('chatNotification'); + UIUtil.playSoundNotification('chatNotification'); setVisualNotification(true); } } @@ -2374,7 +2671,7 @@ var Chat = (function (my) { // so we escape here only tags to avoid double & var escMessage = message.replace(//g, '>').replace(/\n/g, '
'); - var escDisplayName = Util.escapeHtml(displayName); + var escDisplayName = UIUtil.escapeHtml(displayName); message = Replacement.processReplacements(escMessage); var messageContainer = @@ -2397,8 +2694,8 @@ var Chat = (function (my) { */ my.chatAddError = function(errorMessage, originalText) { - errorMessage = Util.escapeHtml(errorMessage); - originalText = Util.escapeHtml(originalText); + errorMessage = UIUtil.escapeHtml(errorMessage); + originalText = UIUtil.escapeHtml(originalText); $('#chatconversation').append( '
Error: ' + 'Your message' + @@ -2417,7 +2714,7 @@ var Chat = (function (my) { { if(subject) subject = subject.trim(); - $('#subject').html(Replacement.linkify(Util.escapeHtml(subject))); + $('#subject').html(Replacement.linkify(UIUtil.escapeHtml(subject))); if(subject === "") { $("#subject").css({display: "none"}); @@ -2480,7 +2777,9 @@ var Chat = (function (my) { return my; }(Chat || {})); module.exports = Chat; -},{"../../toolbars/ToolbarToggler":18,"../../util/NicknameHandler":21,"../SidePanelToggler":8,"./Commands":10,"./Replacement":11,"./smileys.json":12}],10:[function(require,module,exports){ +},{"../../toolbars/ToolbarToggler":19,"../../util/NicknameHandler":22,"../../util/UIUtil":23,"../SidePanelToggler":9,"./Commands":11,"./Replacement":12,"./smileys.json":13}],11:[function(require,module,exports){ +var UIUtil = require("../../util/UIUtil"); + /** * List with supported commands. The keys are the names of the commands and * the value is the function that processes the message. @@ -2514,7 +2813,7 @@ function getCommand(message) */ function processTopic(commandArguments) { - var topic = Util.escapeHtml(commandArguments); + var topic = UIUtil.escapeHtml(commandArguments); xmpp.setSubject(topic); } @@ -2576,7 +2875,7 @@ CommandsProcessor.prototype.processCommand = function() }; module.exports = CommandsProcessor; -},{}],11:[function(require,module,exports){ +},{"../../util/UIUtil":23}],12:[function(require,module,exports){ var Smileys = require("./smileys.json"); /** * Processes links and smileys in "body" @@ -2640,7 +2939,7 @@ module.exports = { linkify: linkify }; -},{"./smileys.json":12}],12:[function(require,module,exports){ +},{"./smileys.json":13}],13:[function(require,module,exports){ module.exports={ "smileys": { "smiley1": ":)", @@ -2690,7 +2989,7 @@ module.exports={ } } -},{}],13:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ var numberOfContacts = 0; var notificationInterval; @@ -2874,7 +3173,7 @@ var ContactList = { }; module.exports = ContactList; -},{}],14:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ var email = ''; var displayName = ''; var userId; @@ -2934,16 +3233,17 @@ var Settings = module.exports = Settings; -},{}],15:[function(require,module,exports){ +},{}],16:[function(require,module,exports){ var Avatar = require("../../avatar/Avatar"); var Settings = require("./Settings"); +var UIUtil = require("../../util/UIUtil"); var SettingsMenu = { update: function() { - var newDisplayName = Util.escapeHtml($('#setDisplayName').get(0).value); - var newEmail = Util.escapeHtml($('#setEmail').get(0).value); + var newDisplayName = UIUtil.escapeHtml($('#setDisplayName').get(0).value); + var newEmail = UIUtil.escapeHtml($('#setEmail').get(0).value); if(newDisplayName) { var displayName = Settings.setDisplayName(newDisplayName); @@ -2977,7 +3277,7 @@ var SettingsMenu = { module.exports = SettingsMenu; -},{"../../avatar/Avatar":5,"./Settings":14}],16:[function(require,module,exports){ +},{"../../avatar/Avatar":5,"../../util/UIUtil":23,"./Settings":15}],17:[function(require,module,exports){ var PanelToggler = require("../side_pannels/SidePanelToggler"); var buttonHandlers = { @@ -3022,7 +3322,7 @@ var BottomToolbar = (function (my) { module.exports = BottomToolbar; -},{"../side_pannels/SidePanelToggler":8}],17:[function(require,module,exports){ +},{"../side_pannels/SidePanelToggler":9}],18:[function(require,module,exports){ /* global $, buttonClick, config, lockRoom, setSharedKey, Util */ var messageHandler = require("../util/MessageHandler"); @@ -3127,7 +3427,7 @@ function toggleRecording() { var token = document.getElementById('recordingToken'); if (token.value) { - callback(Util.escapeHtml(token.value)); + callback(UIUtil.escapeHtml(token.value)); } } }, @@ -3346,7 +3646,7 @@ var Toolbar = (function (my) { var lockKey = document.getElementById('lockKey'); if (lockKey.value) { - Toolbar.setSharedKey(Util.escapeHtml(lockKey.value)); + Toolbar.setSharedKey(UIUtil.escapeHtml(lockKey.value)); lockRoom(true); } } @@ -3541,7 +3841,7 @@ var Toolbar = (function (my) { }(Toolbar || {})); module.exports = Toolbar; -},{"../authentication/Authentication":4,"../etherpad/Etherpad":6,"../prezi/Prezi":7,"../side_pannels/SidePanelToggler":8,"../util/MessageHandler":20,"../util/UIUtil":22,"./BottomToolbar":16}],18:[function(require,module,exports){ +},{"../authentication/Authentication":4,"../etherpad/Etherpad":6,"../prezi/Prezi":7,"../side_pannels/SidePanelToggler":9,"../util/MessageHandler":21,"../util/UIUtil":23,"./BottomToolbar":17}],19:[function(require,module,exports){ /* global $, interfaceConfig, Moderator, DesktopStreaming.showDesktopSharingButton */ var toolbarTimeoutObject, @@ -3656,7 +3956,7 @@ var ToolbarToggler = { }; module.exports = ToolbarToggler; -},{}],19:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ var JitsiPopover = (function () { /** * Constructs new JitsiPopover and attaches it to the element @@ -3780,7 +4080,7 @@ var JitsiPopover = (function () { })(); module.exports = JitsiPopover; -},{}],20:[function(require,module,exports){ +},{}],21:[function(require,module,exports){ /* global $, jQuery */ var messageHandler = (function(my) { @@ -3949,7 +4249,7 @@ module.exports = messageHandler; -},{}],21:[function(require,module,exports){ +},{}],22:[function(require,module,exports){ var nickname = null; var eventEmitter = null; @@ -3978,7 +4278,7 @@ var NickanameHandler = { }; module.exports = NickanameHandler; -},{}],22:[function(require,module,exports){ +},{}],23:[function(require,module,exports){ /** * Created by hristo on 12/22/14. */ @@ -3998,11 +4298,69 @@ module.exports = { */ buttonClick: function(id, classname) { $(id).toggleClass(classname); // add the class to the clicked element + }, + /** + * Returns the text width for the given element. + * + * @param el the element + */ + getTextWidth: function (el) { + return (el.clientWidth + 1); + }, + + /** + * Returns the text height for the given element. + * + * @param el the element + */ + getTextHeight: function (el) { + return (el.clientHeight + 1); + }, + + /** + * Plays the sound given by id. + * + * @param id the identifier of the audio element. + */ + playSoundNotification: function (id) { + document.getElementById(id).play(); + }, + + /** + * Escapes the given text. + */ + escapeHtml: function (unsafeText) { + return $('
').text(unsafeText).html(); + }, + + imageToGrayScale: function (canvas) { + var context = canvas.getContext('2d'); + var imgData = context.getImageData(0, 0, canvas.width, canvas.height); + var pixels = imgData.data; + + for (var i = 0, n = pixels.length; i < n; i += 4) { + var grayscale + = pixels[i] * .3 + pixels[i+1] * .59 + pixels[i+2] * .11; + pixels[i ] = grayscale; // red + pixels[i+1] = grayscale; // green + pixels[i+2] = grayscale; // blue + // pixels[i+3] is alpha + } + // redraw the image in black & white + context.putImageData(imgData, 0, 0); + }, + + setTooltip: function (element, tooltipText, position) { + element.setAttribute("data-content", tooltipText); + element.setAttribute("data-toggle", "popover"); + element.setAttribute("data-placement", position); + element.setAttribute("data-html", true); + element.setAttribute("data-container", "body"); } }; -},{"../side_pannels/SidePanelToggler":8}],23:[function(require,module,exports){ +},{"../side_pannels/SidePanelToggler":9}],24:[function(require,module,exports){ var JitsiPopover = require("../util/JitsiPopover"); /** @@ -4413,7 +4771,7 @@ ConnectionIndicator.prototype.hideIndicator = function () { }; module.exports = ConnectionIndicator; -},{"../util/JitsiPopover":19}],24:[function(require,module,exports){ +},{"../util/JitsiPopover":20}],25:[function(require,module,exports){ var AudioLevels = require("../audio_levels/AudioLevels"); var Avatar = require("../avatar/Avatar"); var Chat = require("../side_pannels/chat/Chat"); @@ -4880,7 +5238,7 @@ function getDesktopVideoSize(videoWidth, function createEditDisplayNameButton() { var editButton = document.createElement('a'); editButton.className = 'displayname'; - Util.setTooltip(editButton, + UIUtil.setTooltip(editButton, 'Click to edit your
display name', "top"); editButton.innerHTML = ''; @@ -4899,7 +5257,7 @@ function createModeratorIndicatorElement(parentElement) { moderatorIndicator.className = 'fa fa-star'; parentElement.appendChild(moderatorIndicator); - Util.setTooltip(parentElement, + UIUtil.setTooltip(parentElement, "The owner of
this conference", "top"); } @@ -5095,7 +5453,7 @@ var VideoLayout = (function (my) { container.id = 'mixedstream'; container.className = 'videocontainer'; remotes.appendChild(container); - Util.playSoundNotification('userJoined'); + UIUtil.playSoundNotification('userJoined'); } if (container) { @@ -5617,7 +5975,7 @@ var VideoLayout = (function (my) { // Remove whole container container.remove(); - Util.playSoundNotification('userLeft'); + UIUtil.playSoundNotification('userLeft'); VideoLayout.resizeThumbnails(); } @@ -5822,7 +6180,7 @@ var VideoLayout = (function (my) { var mutedIndicator = document.createElement('i'); mutedIndicator.className = 'icon-camera-disabled'; - Util.setTooltip(mutedIndicator, + UIUtil.setTooltip(mutedIndicator, "Participant has
stopped the camera.", "top"); videoMutedSpan.appendChild(mutedIndicator); @@ -5865,7 +6223,7 @@ var VideoLayout = (function (my) { if(audioMutedSpan.length == 0 ) { audioMutedSpan = document.createElement('span'); audioMutedSpan.className = 'audioMuted'; - Util.setTooltip(audioMutedSpan, + UIUtil.setTooltip(audioMutedSpan, "Participant is muted", "top"); @@ -6610,7 +6968,7 @@ var VideoLayout = (function (my) { }(VideoLayout || {})); module.exports = VideoLayout; -},{"../audio_levels/AudioLevels":2,"../avatar/Avatar":5,"../etherpad/Etherpad":6,"../prezi/Prezi":7,"../side_pannels/chat/Chat":9,"../side_pannels/contactlist/ContactList":13,"../util/NicknameHandler":21,"../util/UIUtil":22,"./ConnectionIndicator":23}],25:[function(require,module,exports){ +},{"../audio_levels/AudioLevels":2,"../avatar/Avatar":5,"../etherpad/Etherpad":6,"../prezi/Prezi":7,"../side_pannels/chat/Chat":10,"../side_pannels/contactlist/ContactList":14,"../util/NicknameHandler":22,"../util/UIUtil":23,"./ConnectionIndicator":24}],26:[function(require,module,exports){ //var nouns = [ //]; var pluralNouns = [ @@ -6791,7 +7149,7 @@ var RoomNameGenerator = { module.exports = RoomNameGenerator; -},{}],26:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ var animateTimeout, updateTimeout; var RoomNameGenerator = require("./RoomnameGenerator"); @@ -6895,7 +7253,7 @@ function setupWelcomePage() } module.exports = setupWelcomePage; -},{"./RoomnameGenerator":25}],27:[function(require,module,exports){ +},{"./RoomnameGenerator":26}],28:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a diff --git a/libs/modules/xmpp.bundle.js b/libs/modules/xmpp.bundle.js index c7ca1d1e4..8b91a4906 100644 --- a/libs/modules/xmpp.bundle.js +++ b/libs/modules/xmpp.bundle.js @@ -2807,8 +2807,23 @@ module.exports = TraceablePeerConnection; */ var connection = null; var focusUserJid; -var getNextTimeout = Util.createExpBackoffTimer(1000); -var getNextErrorTimeout = Util.createExpBackoffTimer(1000); +function createExpBackoffTimer(step) { + var count = 1; + return function (reset) { + // Reset call + if (reset) { + count = 1; + return; + } + // Calculate next timeout + var timeout = Math.pow(2, count - 1); + count += 1; + return timeout * step; + }; +} + +var getNextTimeout = createExpBackoffTimer(1000); +var getNextErrorTimeout = createExpBackoffTimer(1000); // External authentication stuff var externalAuthEnabled = false; // Sip gateway can be enabled by configuring Jigasi host in config.js or diff --git a/modules/UI/prezi/Prezi.js b/modules/UI/prezi/Prezi.js index 7ceb70c2e..aef8df62e 100644 --- a/modules/UI/prezi/Prezi.js +++ b/modules/UI/prezi/Prezi.js @@ -2,6 +2,7 @@ var ToolbarToggler = require("../toolbars/ToolbarToggler"); var UIUtil = require("../util/UIUtil"); var VideoLayout = require("../videolayout/VideoLayout"); var messageHandler = require("../util/MessageHandler"); +var PreziPlayer = require("./PreziPlayer"); var preziPlayer = null; @@ -73,7 +74,7 @@ var Prezi = { if (preziUrl.value) { var urlValue - = encodeURI(Util.escapeHtml(preziUrl.value)); + = encodeURI(UIUtil.escapeHtml(preziUrl.value)); if (urlValue.indexOf('http://prezi.com/') != 0 && urlValue.indexOf('https://prezi.com/') != 0) diff --git a/modules/UI/prezi/PreziPlayer.js b/modules/UI/prezi/PreziPlayer.js index ba34a18c3..e454ad7a2 100644 --- a/modules/UI/prezi/PreziPlayer.js +++ b/modules/UI/prezi/PreziPlayer.js @@ -289,3 +289,5 @@ })(); })(); + +module.exports = PreziPlayer; diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js index 026769330..d768d0df6 100644 --- a/modules/UI/side_pannels/chat/Chat.js +++ b/modules/UI/side_pannels/chat/Chat.js @@ -4,6 +4,7 @@ var CommandsProcessor = require("./Commands"); var ToolbarToggler = require("../../toolbars/ToolbarToggler"); var smileys = require("./smileys.json").smileys; var NicknameHandler = require("../../util/NicknameHandler"); +var UIUtil = require("../../util/UIUtil"); var notificationInterval = false; var unreadMessages = 0; @@ -28,10 +29,10 @@ function setVisualNotification(show) { var chatButtonElement = document.getElementById('chatButton').parentNode; - var leftIndent = (Util.getTextWidth(chatButtonElement) - - Util.getTextWidth(unreadMsgElement)) / 2; - var topIndent = (Util.getTextHeight(chatButtonElement) - - Util.getTextHeight(unreadMsgElement)) / 2 - 3; + var leftIndent = (UIUtil.getTextWidth(chatButtonElement) - + UIUtil.getTextWidth(unreadMsgElement)) / 2; + var topIndent = (UIUtil.getTextHeight(chatButtonElement) - + UIUtil.getTextHeight(unreadMsgElement)) / 2 - 3; unreadMsgElement.setAttribute( 'style', @@ -179,7 +180,7 @@ var Chat = (function (my) { $('#nickinput').keydown(function (event) { if (event.keyCode === 13) { event.preventDefault(); - var val = Util.escapeHtml(this.value); + var val = UIUtil.escapeHtml(this.value); this.value = ''; if (!NicknameHandler.getNickname()) { NicknameHandler.setNickname(val); @@ -202,7 +203,7 @@ var Chat = (function (my) { } else { - var message = Util.escapeHtml(value); + var message = UIUtil.escapeHtml(value); xmpp.sendChatMessage(message, NicknameHandler.getNickname()); } } @@ -237,7 +238,7 @@ var Chat = (function (my) { if (!Chat.isVisible()) { unreadMessages++; - Util.playSoundNotification('chatNotification'); + UIUtil.playSoundNotification('chatNotification'); setVisualNotification(true); } } @@ -247,7 +248,7 @@ var Chat = (function (my) { // so we escape here only tags to avoid double & var escMessage = message.replace(//g, '>').replace(/\n/g, '
'); - var escDisplayName = Util.escapeHtml(displayName); + var escDisplayName = UIUtil.escapeHtml(displayName); message = Replacement.processReplacements(escMessage); var messageContainer = @@ -270,8 +271,8 @@ var Chat = (function (my) { */ my.chatAddError = function(errorMessage, originalText) { - errorMessage = Util.escapeHtml(errorMessage); - originalText = Util.escapeHtml(originalText); + errorMessage = UIUtil.escapeHtml(errorMessage); + originalText = UIUtil.escapeHtml(originalText); $('#chatconversation').append( '
Error: ' + 'Your message' + @@ -290,7 +291,7 @@ var Chat = (function (my) { { if(subject) subject = subject.trim(); - $('#subject').html(Replacement.linkify(Util.escapeHtml(subject))); + $('#subject').html(Replacement.linkify(UIUtil.escapeHtml(subject))); if(subject === "") { $("#subject").css({display: "none"}); diff --git a/modules/UI/side_pannels/chat/Commands.js b/modules/UI/side_pannels/chat/Commands.js index 6883268c3..56ed95110 100644 --- a/modules/UI/side_pannels/chat/Commands.js +++ b/modules/UI/side_pannels/chat/Commands.js @@ -1,3 +1,5 @@ +var UIUtil = require("../../util/UIUtil"); + /** * List with supported commands. The keys are the names of the commands and * the value is the function that processes the message. @@ -31,7 +33,7 @@ function getCommand(message) */ function processTopic(commandArguments) { - var topic = Util.escapeHtml(commandArguments); + var topic = UIUtil.escapeHtml(commandArguments); xmpp.setSubject(topic); } diff --git a/modules/UI/side_pannels/settings/SettingsMenu.js b/modules/UI/side_pannels/settings/SettingsMenu.js index 25fca6145..d8f163c26 100644 --- a/modules/UI/side_pannels/settings/SettingsMenu.js +++ b/modules/UI/side_pannels/settings/SettingsMenu.js @@ -1,12 +1,13 @@ var Avatar = require("../../avatar/Avatar"); var Settings = require("./Settings"); +var UIUtil = require("../../util/UIUtil"); var SettingsMenu = { update: function() { - var newDisplayName = Util.escapeHtml($('#setDisplayName').get(0).value); - var newEmail = Util.escapeHtml($('#setEmail').get(0).value); + var newDisplayName = UIUtil.escapeHtml($('#setDisplayName').get(0).value); + var newEmail = UIUtil.escapeHtml($('#setEmail').get(0).value); if(newDisplayName) { var displayName = Settings.setDisplayName(newDisplayName); diff --git a/modules/UI/toolbars/Toolbar.js b/modules/UI/toolbars/Toolbar.js index 55ba8949f..ab2642719 100644 --- a/modules/UI/toolbars/Toolbar.js +++ b/modules/UI/toolbars/Toolbar.js @@ -102,7 +102,7 @@ function toggleRecording() { var token = document.getElementById('recordingToken'); if (token.value) { - callback(Util.escapeHtml(token.value)); + callback(UIUtil.escapeHtml(token.value)); } } }, @@ -321,7 +321,7 @@ var Toolbar = (function (my) { var lockKey = document.getElementById('lockKey'); if (lockKey.value) { - Toolbar.setSharedKey(Util.escapeHtml(lockKey.value)); + Toolbar.setSharedKey(UIUtil.escapeHtml(lockKey.value)); lockRoom(true); } } diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js index efb8a2b7b..c0f99e86d 100644 --- a/modules/UI/util/UIUtil.js +++ b/modules/UI/util/UIUtil.js @@ -17,6 +17,64 @@ module.exports = { */ buttonClick: function(id, classname) { $(id).toggleClass(classname); // add the class to the clicked element + }, + /** + * Returns the text width for the given element. + * + * @param el the element + */ + getTextWidth: function (el) { + return (el.clientWidth + 1); + }, + + /** + * Returns the text height for the given element. + * + * @param el the element + */ + getTextHeight: function (el) { + return (el.clientHeight + 1); + }, + + /** + * Plays the sound given by id. + * + * @param id the identifier of the audio element. + */ + playSoundNotification: function (id) { + document.getElementById(id).play(); + }, + + /** + * Escapes the given text. + */ + escapeHtml: function (unsafeText) { + return $('
').text(unsafeText).html(); + }, + + imageToGrayScale: function (canvas) { + var context = canvas.getContext('2d'); + var imgData = context.getImageData(0, 0, canvas.width, canvas.height); + var pixels = imgData.data; + + for (var i = 0, n = pixels.length; i < n; i += 4) { + var grayscale + = pixels[i] * .3 + pixels[i+1] * .59 + pixels[i+2] * .11; + pixels[i ] = grayscale; // red + pixels[i+1] = grayscale; // green + pixels[i+2] = grayscale; // blue + // pixels[i+3] is alpha + } + // redraw the image in black & white + context.putImageData(imgData, 0, 0); + }, + + setTooltip: function (element, tooltipText, position) { + element.setAttribute("data-content", tooltipText); + element.setAttribute("data-toggle", "popover"); + element.setAttribute("data-placement", position); + element.setAttribute("data-html", true); + element.setAttribute("data-container", "body"); } diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js index 67114be4f..a24c485d9 100644 --- a/modules/UI/videolayout/VideoLayout.js +++ b/modules/UI/videolayout/VideoLayout.js @@ -464,7 +464,7 @@ function getDesktopVideoSize(videoWidth, function createEditDisplayNameButton() { var editButton = document.createElement('a'); editButton.className = 'displayname'; - Util.setTooltip(editButton, + UIUtil.setTooltip(editButton, 'Click to edit your
display name', "top"); editButton.innerHTML = ''; @@ -483,7 +483,7 @@ function createModeratorIndicatorElement(parentElement) { moderatorIndicator.className = 'fa fa-star'; parentElement.appendChild(moderatorIndicator); - Util.setTooltip(parentElement, + UIUtil.setTooltip(parentElement, "The owner of
this conference", "top"); } @@ -679,7 +679,7 @@ var VideoLayout = (function (my) { container.id = 'mixedstream'; container.className = 'videocontainer'; remotes.appendChild(container); - Util.playSoundNotification('userJoined'); + UIUtil.playSoundNotification('userJoined'); } if (container) { @@ -1201,7 +1201,7 @@ var VideoLayout = (function (my) { // Remove whole container container.remove(); - Util.playSoundNotification('userLeft'); + UIUtil.playSoundNotification('userLeft'); VideoLayout.resizeThumbnails(); } @@ -1406,7 +1406,7 @@ var VideoLayout = (function (my) { var mutedIndicator = document.createElement('i'); mutedIndicator.className = 'icon-camera-disabled'; - Util.setTooltip(mutedIndicator, + UIUtil.setTooltip(mutedIndicator, "Participant has
stopped the camera.", "top"); videoMutedSpan.appendChild(mutedIndicator); @@ -1449,7 +1449,7 @@ var VideoLayout = (function (my) { if(audioMutedSpan.length == 0 ) { audioMutedSpan = document.createElement('span'); audioMutedSpan.className = 'audioMuted'; - Util.setTooltip(audioMutedSpan, + UIUtil.setTooltip(audioMutedSpan, "Participant is muted", "top"); diff --git a/modules/xmpp/moderator.js b/modules/xmpp/moderator.js index 780370350..4d589a6ae 100644 --- a/modules/xmpp/moderator.js +++ b/modules/xmpp/moderator.js @@ -6,8 +6,23 @@ */ var connection = null; var focusUserJid; -var getNextTimeout = Util.createExpBackoffTimer(1000); -var getNextErrorTimeout = Util.createExpBackoffTimer(1000); +function createExpBackoffTimer(step) { + var count = 1; + return function (reset) { + // Reset call + if (reset) { + count = 1; + return; + } + // Calculate next timeout + var timeout = Math.pow(2, count - 1); + count += 1; + return timeout * step; + }; +} + +var getNextTimeout = createExpBackoffTimer(1000); +var getNextErrorTimeout = createExpBackoffTimer(1000); // External authentication stuff var externalAuthEnabled = false; // Sip gateway can be enabled by configuring Jigasi host in config.js or diff --git a/util.js b/util.js deleted file mode 100644 index 0199c6769..000000000 --- a/util.js +++ /dev/null @@ -1,91 +0,0 @@ -/* global $ */ -/** - * Utility functions. - */ -var Util = (function (my) { - - /** - * Returns the text width for the given element. - * - * @param el the element - */ - my.getTextWidth = function (el) { - return (el.clientWidth + 1); - }; - - /** - * Returns the text height for the given element. - * - * @param el the element - */ - my.getTextHeight = function (el) { - return (el.clientHeight + 1); - }; - - /** - * Casts the given number to integer. - * - * @param number the number to cast - */ - my.toInteger = function (number) { - return Math.round(Number(number)); - }; - - /** - * Plays the sound given by id. - * - * @param id the identifier of the audio element. - */ - my.playSoundNotification = function (id) { - document.getElementById(id).play(); - }; - - /** - * Escapes the given text. - */ - my.escapeHtml = function (unsafeText) { - return $('
').text(unsafeText).html(); - }; - - my.imageToGrayScale = function (canvas) { - var context = canvas.getContext('2d'); - var imgData = context.getImageData(0, 0, canvas.width, canvas.height); - var pixels = imgData.data; - - for (var i = 0, n = pixels.length; i < n; i += 4) { - var grayscale - = pixels[i] * .3 + pixels[i+1] * .59 + pixels[i+2] * .11; - pixels[i ] = grayscale; // red - pixels[i+1] = grayscale; // green - pixels[i+2] = grayscale; // blue - // pixels[i+3] is alpha - } - // redraw the image in black & white - context.putImageData(imgData, 0, 0); - }; - - my.setTooltip = function (element, tooltipText, position) { - element.setAttribute("data-content", tooltipText); - element.setAttribute("data-toggle", "popover"); - element.setAttribute("data-placement", position); - element.setAttribute("data-html", true); - element.setAttribute("data-container", "body"); - }; - - my.createExpBackoffTimer = function (step) { - var count = 1; - return function (reset) { - // Reset call - if (reset) { - count = 1; - return; - } - // Calculate next timeout - var timeout = Math.pow(2, count - 1); - count += 1; - return timeout * step; - }; - }; - - return my; -}(Util || {}));