Wrap all JS code in IIFE to avoid creating global variables

parent f103eaf1
var noticeTimer, noticeShow = false;
(function() {
var noticeTimer, noticeShow = false;
function getEMail()
{
function getEMail()
{
var emailInput = $('.svcCheckEmail');
var email = emailInput.val();
try {
......@@ -10,18 +11,18 @@ function getEMail()
//
}
return email;
}
}
function closeNotice() {
function closeNotice() {
if(noticeShow === true) {
clearTimeout(noticeTimer);
emailNotice.animate({ marginTop: '-=51px' }, 300);
noticeShow = false;
}
}
}
function showNotice(type, message) {
function showNotice(type, message) {
if(!document.getElementById('svcCheckEmail_notice')) {
var notice = '<div id="svcCheckEmail_notice"><div class="notice_center_auto">';
notice += '<div id="notice_text"></div>';
......@@ -47,10 +48,10 @@ function showNotice(type, message) {
emailNotice.animate({ marginTop: '-=51px' }, 300);
noticeShow = false;
}, 7000);
}
}
function showErrorNotice(error)
{
function showErrorNotice(error)
{
var noticeText;
switch (error) {
case 'dns_records_not_found':
......@@ -71,11 +72,11 @@ function showErrorNotice(error)
break;
}
showNotice('red', noticeText);
}
}
// Добавляем CSS и расставляем вызов
$(function() {
// Добавляем CSS и расставляем вызов
$(function() {
$('<link />').attr({
rel: 'stylesheet',
type: 'text/css',
......@@ -159,8 +160,7 @@ $(function() {
error: function() {
showNotice('red', 'Ошибка связи с сервером, проверка адреса не удалась.');
emailInput.removeClass('bg-loader').addClass('bg-true');
// FIXME
// FIXME
checkDoneStatus = 'true';
},
success: function(response) {
......@@ -185,7 +185,7 @@ $(function() {
checkDoneStatus = 'done';
}
// FIXME
// FIXME
} catch (e) {
showNotice('yellow', 'Не удалось проверить адрес e-mail.');
emailInput.removeClass('bg-loader').addClass('bg-true');
......@@ -194,7 +194,7 @@ $(function() {
}
});
return true;
});
});
});
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment