Предмет:
Тип роботи:
Реферат
К-сть сторінок:
31
Мова:
Українська
style="text-align: justify;">'emptyGroup': 'Пусте поле номера залікової книжки',
'badGroup': 'Некоректний номер залікової книжки',
'emptyPass': 'Пусте поле паролю',
'badPass': 'Некоректний пароль',
'difPass': 'Паролі не збігаються',
'emptyMail': 'Пусте поле електронної пошти',
'badMail': 'Некоректна електронна пошта',
'wait': 'Будь ласка зачекайте',
'step1': 'Правила',
'step2': 'Заповнення даних',
'step3': 'Перевірка даних',
'step4': 'Обробка',
'rules': 'ua rules',
'support': 'ua support'
},
'eng': {
'name': 'Name',
'surname': 'Last name',
'group': 'Number of academic records',
'pass': 'Pass',
'pass2': 'Confirm Password',
'mail': 'Email Address',
'emptyName': 'Empty name',
'emptySurName': 'Empty last name',
'emptyGroup': 'Empty number of academic records',
'badGroup': 'Invalid academic record',
'emptyPass': 'Empty pass',
'badPass': 'bad pass',
'difPass': 'Different pass',
'emptyMail': 'Empty email',
'badMail': 'bad mail',
'wait': 'Please wait',
'step1': 'Rules',
'step2': 'Fill data',
'step3': 'Check data',
'step4': 'Processing',
'rules': 'eng rules',
'support': 'eng support'
}
},
language = 'ua',
mode = 'rules',
timerId = 0,
time = 0;
function hide (el) {
el. style. display=«none»;
}
function show (el) {
el. style. display=«block»;
}
function isBadStr () {
for (var key in arguments)
if (arguments[key]) return false
return true;
}
function warningCodeGet (value, flagVal, flag) {
if (flag === undefined)
return (value)? '': flagVal
else {
if (value)
return (flag)? '': flagVal[0]
else return flagVal[1]
}
}
function checkEmail () {
var mail = fields. mail. value
var reg = /^ ([A-Za-z0-9_\-\. ]) +\@ ([A-Za-z0-9_\-\. ]) +\. ([A-Za-z]{2, 4}) $/;
warningCodes. mail = warningCodeGet (mail, [languageData[language]['badMail'],
languageData[language]['emptyMail']], reg. test (mail))
return isBadStr (warningCodes. mail)
}
function checkNames () {
warningCodes. name = warningCodeGet (fields. name. value, languageData[language]['emptyName'])
warningCodes. surname = warningCodeGet (fields. surname. value, languageData[language]['emptySurName'])
return isBadStr (warningCodes. name, warningCodes. surname)
}
function checkPass () {
if (fields. pass. value==fields. pass2. value) {
var reg = /[^A-Za-z0-9! @#\$% \^&\* () _\+-=]/
var flag =! reg. test () && (fields. pass. value. length >= 8)
warningCodes. pass = warningCodeGet (fields. pass. value, [languageData[language]['badPass'], languageData[language]['emptyPass']], flag)
}
else warningCodes. pass = languageData[language]['difPass']
return isBadStr (warningCodes. pass)
}
function checkGroup () {
var group = $ (fieldSelectors. group). value. toLowerCase ()
group = group. replace ('с', 's')
group = group. replace ('п', 'p')
group = group. replace ('і', 'i')
if (group! =fields. group. value)
fields. group. value=group
warningCodes. group = warningCodeGet (group, [languageData[language]['badGroup'],
languageData[language]['emptyGroup']],
(group[0]=='i' && (group[1]=='p' || group[1]=='s') && group. length==6))
return isBadStr (warningCodes. group)
}
function check () {
var r = checkNames () + checkGroup () + checkPass () + checkEmail ()
return (r<4)? false: true
}
function removeToolTip (el) {
removeClass (el. parentNode. parentNode. querySelector ('. tool-tip'), 'tool-tip-show')
addClass (el. parentNode, 'input-correct')
}
function addToolTip (el, str) {
removeClass (el. parentNode, 'input-correct')
addClass (el. parentNode. parentNode. querySelector ('. tool-tip'), 'tool-tip-show')
el. parentNode. parentNode. querySelector ('. tool-tip'). innerHTML = str;
}
function applyLanguage (e) {
if (typeof e! = «string») {
language1 = e. target. getAttribute ('data-lang')
}
else language1 = e
language = language1
if (! language) return;
for (var key in fields)
fields[key]. parentNode. parentNode. querySelector ('span'). innerHTML = languageData[language][key]
check ()
blocks. rules. innerHTML = languageData[language]['rules']
blocks. support. innerHTML = languageData[language]['support']
for (var key in warningCodes)
fields[key]. parentNode. parentNode. querySelector ('. tool-tip'). innerHTML = warningCodes[key]
blocks. stepBar. innerHTML = languageData[language]['step'+ (scroll. posX+1) ]
blocks. wait. innerHTML = languageData[language]['wait']+' '+time
if (mode=='confirm')
{
blocks. confirm. innerHTML = languageData[language]['name'] + ': ' + fields. name. value + '<br>' +
languageData[language]['surname'] + ': ' + fields. surname. value + '<br>' +
languageData[language]['group'] + ': ' + fields. group. value + '<br>' +
languageData[language]['mail'] + ': ' + fields. mail. value + '<br>'
}
}
function fieldChecker (e) {
check ()
for (var key in warningCodes) {
if (e. target == fields[key] || (key=='pass' && e. target == fields['pass2']))
if (warningCodes[key]) {
addToolTip (fields[key], warningCodes[key])
if (key=='pass') removeClass (fields['pass2']. parentNode, 'input-correct')
} else {
removeToolTip (fields[key]) ;
if (key=='pass') removeToolTip (fields['pass2']) ;
}
}
}
function waiterLoop () {
if (time == 0) {
blocks. wait. style. display='none'
blocks. nextBtn. disabled = false
clearInterval (timerId)
} else {