var App = function () { this.init = function (rootElement) { this.rootElement = $(rootElement); this.storage = window.localStorage; this.difference = appConfig.countdownEndUTC - new Date().getTime(); // this.difference = new Date().getTime() + 68000 - new Date().getTime(); this.render(); } this.render = function () { if (this.difference > 0) { this.renderCountdown() } else { location.href = 'live.html'; }/* else if (this.storage.getItem('authenticated')) { this.renderLanguageChoice(); } else { this.localStorage.clear(); this.renderLoginForm() }*/ } this.renderCountdown = function () { $(document.body).attr('class', 'countdown'); this.rootElement.empty(); var title = $('
', {'class': 'content-main-title title-countdown'}).html('Event starts in'); var self = this; $('#main-content').append([title, $('', {id: 'countdown-widget'})]) var clock = $('#countdown-widget').FlipClock(this.difference/1000, { // clockFace: 'DailyCounter', countdown: true, showSeconds: false, showDay: false, stop: function () { location.href='live.html'; // self.renderLoginForm(); } }); } this.renderLoginForm = function () { var self = this; $(document.body).attr('class', 'login-form'); this.rootElement.empty(); var title = $('', {'class': 'content-main-title title-login-form'}).html('Sign in'); var loginError = $('', {'class': 'login-form-error'}).html('Wrong username and/or password'); var usernameField = $('', {'class': 'input-username-wrapper'}).append( $('', {'class': 'input-username', placeholder: 'Username'}) ); var passwordField = $('', {'class': 'input-password-wrapper'}).append( $('', {'class': 'input-password', type: 'password', placeholder: 'Password'}) ); var submitField = $('', {'class': 'input-submit', type: 'button', value: 'Submit'}).on('click', function () { var res = self.checkLogin($('.input-username').val(), $('.input-password').val()); if (res) { loginError.removeClass('force-display'); self.storage.setItem('authenticated', true); self.renderLanguageChoice(); } else { loginError.addClass('force-display'); } }); $('#main-content').append([ title, loginError, usernameField, passwordField, submitField ]) } this.renderLanguageChoice = function () { $(document.body).attr('class', 'language-choice'); this.rootElement.empty(); var title = $('', {'class': 'content-main-title title-language-choice'}).html('Choose your language'); var list = $('