2014-04-13 12:30:47 +00:00
|
|
|
/* global $ */
|
2014-02-18 19:11:27 +00:00
|
|
|
/**
|
|
|
|
* Utility functions.
|
|
|
|
*/
|
|
|
|
var Util = (function (my) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the text width for the given element.
|
|
|
|
*
|
|
|
|
* @param el the element
|
|
|
|
*/
|
2014-04-13 12:30:47 +00:00
|
|
|
my.getTextWidth = function (el) {
|
2014-02-18 19:11:27 +00:00
|
|
|
return (el.clientWidth + 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the text height for the given element.
|
|
|
|
*
|
|
|
|
* @param el the element
|
|
|
|
*/
|
2014-04-13 12:30:47 +00:00
|
|
|
my.getTextHeight = function (el) {
|
2014-02-18 19:11:27 +00:00
|
|
|
return (el.clientHeight + 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Casts the given number to integer.
|
|
|
|
*
|
|
|
|
* @param number the number to cast
|
|
|
|
*/
|
2014-04-13 12:30:47 +00:00
|
|
|
my.toInteger = function (number) {
|
2014-02-18 19:11:27 +00:00
|
|
|
return Math.round(Number(number));
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays the sound given by id.
|
|
|
|
*
|
|
|
|
* @param id the identifier of the audio element.
|
|
|
|
*/
|
2014-04-13 12:30:47 +00:00
|
|
|
my.playSoundNotification = function (id) {
|
2014-02-18 19:11:27 +00:00
|
|
|
document.getElementById(id).play();
|
|
|
|
};
|
|
|
|
|
2014-02-26 15:19:39 +00:00
|
|
|
/**
|
|
|
|
* Escapes the given text.
|
|
|
|
*/
|
2014-04-13 12:30:47 +00:00
|
|
|
my.escapeHtml = function (unsafeText) {
|
2014-02-26 15:19:39 +00:00
|
|
|
return $('<div/>').text(unsafeText).html();
|
|
|
|
};
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Returns the available video width.
|
|
|
|
*/
|
2014-04-13 12:30:47 +00:00
|
|
|
my.getAvailableVideoWidth = function () {
|
|
|
|
var chatspaceWidth = $('#chatspace').is(":visible") ? $('#chatspace').width() : 0;
|
2014-03-26 10:33:46 +00:00
|
|
|
|
|
|
|
return window.innerWidth - chatspaceWidth;
|
|
|
|
};
|
|
|
|
|
2014-02-18 19:11:27 +00:00
|
|
|
return my;
|
2014-04-13 12:30:47 +00:00
|
|
|
}(Util || {}));
|