jiti-meet/modules/UI/welcome_page/WelcomePage.js

96 lines
2.9 KiB
JavaScript
Raw Normal View History

/* global $, interfaceConfig */
2015-01-07 14:54:03 +00:00
var animateTimeout, updateTimeout;
var RoomNameGenerator = require("./RoomnameGenerator");
function enter_room() {
2015-01-07 14:54:03 +00:00
var val = $("#enter_room_field").val();
if(!val) {
val = $("#enter_room_field").attr("room_name");
}
if (val) {
window.location.pathname = "/" + val;
}
}
function animate(word) {
var currentVal = $("#enter_room_field").attr("placeholder");
$("#enter_room_field").attr("placeholder", currentVal + word.substr(0, 1));
animateTimeout = setTimeout(function() {
animate(word.substring(1, word.length));
2015-01-07 14:54:03 +00:00
}, 70);
}
function update_roomname() {
2015-01-07 14:54:03 +00:00
var word = RoomNameGenerator.generateRoomWithoutSeparator();
$("#enter_room_field").attr("room_name", word);
$("#enter_room_field").attr("placeholder", "");
clearTimeout(animateTimeout);
animate(word);
updateTimeout = setTimeout(update_roomname, 10000);
}
function setupWelcomePage() {
2015-01-07 14:54:03 +00:00
$("#videoconference_page").hide();
$("#domain_name").text(
window.location.protocol + "//" + window.location.host + "/");
if (interfaceConfig.SHOW_JITSI_WATERMARK) {
var leftWatermarkDiv =
$("#welcome_page_header div[class='watermark leftwatermark']");
if(leftWatermarkDiv && leftWatermarkDiv.length > 0) {
2015-01-07 14:54:03 +00:00
leftWatermarkDiv.css({display: 'block'});
leftWatermarkDiv.parent().get(0).href =
interfaceConfig.JITSI_WATERMARK_LINK;
2015-01-07 14:54:03 +00:00
}
}
if (interfaceConfig.SHOW_BRAND_WATERMARK) {
var rightWatermarkDiv =
$("#welcome_page_header div[class='watermark rightwatermark']");
2015-01-07 14:54:03 +00:00
if(rightWatermarkDiv && rightWatermarkDiv.length > 0) {
rightWatermarkDiv.css({display: 'block'});
rightWatermarkDiv.parent().get(0).href =
interfaceConfig.BRAND_WATERMARK_LINK;
rightWatermarkDiv.get(0).style.backgroundImage =
"url(images/rightwatermark.png)";
2015-01-07 14:54:03 +00:00
}
}
if (interfaceConfig.SHOW_POWERED_BY) {
$("#welcome_page_header>a[class='poweredby']")
.css({display: 'block'});
}
$("#enter_room_button").click(function() {
2015-01-07 14:54:03 +00:00
enter_room();
});
$("#enter_room_field").keydown(function (event) {
if (event.keyCode === 13 /* enter */) {
enter_room();
}
});
if (interfaceConfig.GENERATE_ROOMNAMES_ON_WELCOME_PAGE !== false) {
2015-01-07 14:54:03 +00:00
var updateTimeout;
var animateTimeout;
var selector = $("#reload_roomname");
selector.click(function () {
2015-01-07 14:54:03 +00:00
clearTimeout(updateTimeout);
clearTimeout(animateTimeout);
update_roomname();
});
selector.show();
2015-01-07 14:54:03 +00:00
update_roomname();
}
$("#disable_welcome").click(function () {
window.localStorage.welcomePageDisabled =
$("#disable_welcome").is(":checked");
2015-01-07 14:54:03 +00:00
});
}
module.exports = setupWelcomePage;