Вход Регистрация
Файл: js/al/invite.js
Строк: 507
<?php
var inviter = {
  
toggle: function(block) {
    
toggle(block '_link');
    
toggle(block '_info');
  },
  
slideShow: function(elemspeed) {
    if (!
isVisible(elem)) slideDown(elemspeed || 150);
  },
  
slideHide: function(elemspeed) {
    if (
isVisible(elem)) slideUp(elemspeed || 150);
  },

  
checkLang: function() {
    var 
fname trim(ge('inv_fname').value);
    var 
lname trim(ge('inv_lname').value);
    var 
hasrus true;
    if (
fname && !fname.match(/[а-яА-ЯёЁ]/) && lname && !lname.match(/[а-яА-ЯёЁ]/)) {
      
hasrus false;
    }
    (
hasrus hide show)('inv_lang_row');
    if (
fname && lname) {
      
ajax.plainpost('invite.php', {act'get_sex'fnamefnamelnamelname}, function(sex) {
        (
intval(sex) ? hide show)('inv_sex_row');
      });
    }
  },

  
getLastDay: function(yearmonth) {
    if (
month == 2) {
      if (
year == 0) {
        return 
29;
      } else {
        return 
28;
      }
    } else if (
month && ((month && month == 0) || (month && month == 1))) {
      return 
30;
    }
    return 
31;
  },
  
genDays: function(yearmonth) {
    var 
result = [[0cur.lang.profileEdit_main_sel_bday+':']], last inviter.getLastDay(yearmonth);
    for (var 
1<= last; ++i) {
      
result.push([i'']);
    }
    return 
result;
  },

  
init: function(opts) {
    
cur.lang extend(cur.lang || {}, opts.lang || {});
    
cur.invHash opts.hash;
    
cur.module 'invite';

    if (!
opts.selData) return;

    var 
selData opts.selData;

    
selectsData.setCountries(selData.countries_list);
    for (var 
i in selData.countries) {
      
selectsData.setCountryInfo(iselData.countries[i]);
    }
    for (var 
i in selData.cities) {
      
selectsData.setCityInfo(iselData.cities[i]);
    }
    for (var 
i in selData.universities) {
      
selectsData.setUniversityInfo(iselData.universities[i]);
    }
    for (var 
i in selData.faculties) {
      
selectsData.setFacultyInfo(iselData.faculties[i]);
    }

    var 
uiBDayuiBMonthuiBYearuiCountryuiCity;

    var 
uiChairuiFacultyuiUniversityuiUCityuiUCountry;
    var 
uiEducationFormuiEducationStatusuiGrad;

    var 
uiSchooluiSCityuiSCountry;
    var 
uiClassuiSchoolStartYearuiSchoolFinishYearuiSchoolGradYear;

    var 
slideShow inviter.slideShowslideHide inviter.slideHide;

    var 
uiLang = new Dropdown(ge('inv_lang'), [[0'Русский'], [1'English']], {
      
width178,
      
multiselectfalse,
      
selectedItems: (vk.lang 3) ? 1
    
});

    
cur.uiSex = new Dropdown(ge('inv_sex'), selData.sexes, {
      
width178,
      
multiselectfalse,
      
onChange: function(val) {
        
val intval(val);
        if (
val) {
          
ge('birth_date_label').innerHTML langSex(valcur.lang.birth_date_label);
        }
      }
    });

    var 
updDays = function(yearmonth) {
      if (
uiBDay.val() > inviter.getLastDay(yearmonth)) {
        
uiBDay.clear();
      }
      
uiBDay.setData(inviter.getLastDay(yearmonth));
    }

    
uiBDay = new Dropdown(ge('inv_bday'), inviter.genDays(00), {
      
width55,
      
multiselectfalse
    
});

    
uiBMonth = new Dropdown(ge('inv_bmonth'), selData.bmonths, {
      
width95,
      
multiselectfalse,
      
onChange: function(value) {
        
updDays(uiBYear.val(), value);
      }
    });

    
uiBYear = new Dropdown(ge('inv_byear'), selData.byears, {
      
width60,
      
multiselectfalse,
      
onChange: function(value) {
        
updDays(valueuiBMonth.val());
      }
    });

    
uiClass = new ClassSelect(ge('inv_sclass'), ge('inv_sclass_row'), {
      
width178,
      
countryselData.s_country[0],
      
schoolselData.school,
      
school_classselData.s_class
    
});

    
uiSchool = new SchoolSelect(ge('inv_sschool'), ge('inv_sschool_row'),
                                
ge('inv_sschool_type'), ge('inv_sschool_type_row'), {
      
width178,
      
type_width75,
      
with_type_width98,
      
showslideShow,
      
hideslideHide,
      
typesselData.school_types,
      
schoolselData.school,
      
cityselData.s_city[0],
      
classSelectuiClass,
      
onChange: function(value) {
        if (
intval(value)) {
          
slideShow('inv_sdetails'300);
        } else {
          
slideHide('inv_sdetails'300);
        }
        
uiClass.clear();
        
uiSchoolStartYear.clear();
        
uiSchoolFinishYear.clear();
        
uiSchoolGradYear.clear();
      }
    });

    
uiEducationForm = new EducationFormSelect(ge('inv_uedu_form'), ge('inv_uedu_form_row'), {
      
width178,
      
countryselData.u_country[0],
      
universityselData.university,
      
edu_formselData.edu_form
    
});

    
uiEducationStatus = new EducationStatusSelect(ge('inv_uedu_status'), ge('inv_uedu_status_row'), {
      
width178,
      
countryselData.u_country[0],
      
universityselData.university,
      
edu_statusselData.edu_status
    
});

    
uiChair = new ChairSelect(ge('inv_uchair'), ge('inv_uchair_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
chairselData.chair,
      
facultyselData.faculty
    
});

    
uiFaculty = new FacultySelect(ge('inv_ufaculty'), ge('inv_ufaculty_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
progressBarge('uni_progress'),
      
facultyselData.faculty,
      
universityselData.university,
      
chairSelectuiChair
    
});

    
uiUniversity = new UniversitySelect(ge('inv_uuniversity'), ge('inv_uuniversity_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
progressBarge('uni_progress'),
      
universityselData.university,
      
cityselData.u_city[0],
      
facultySelectuiFaculty,
      
eduFormSelectuiEducationForm,
      
eduStatusSelectuiEducationStatus,
      
onChange: function(value) {
        if (
intval(value)) {
          
slideShow('inv_udetails'300);
        } else {
          
slideHide('inv_udetails'300);
        }
        
uiEducationForm.clear();
        
uiEducationStatus.clear();
        
uiGrad.clear();
      }
    });

    
uiUCity = new CitySelect(ge('inv_ucity'), ge('inv_ucity_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
progressBarge('uni_progress'),
      
cityselData.u_city,
      
countryselData.u_country[0],
      
universitySelectuiUniversity
    
});

    
uiSCity = new CitySelect(ge('inv_scity'), ge('inv_scity_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
progressBarge('school_progress'),
      
cityselData.s_city,
      
countryselData.s_country[0],
      
schoolSelectuiSchool
    
});

    
uiCity = new CitySelect(ge('inv_city'), ge('inv_city_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
cityselData.city,
      
countryselData.country[0],
      
onChange: function(value) {
        
value intval(value);
        if (
value) {
          var 
cnfull uiCountry.val_full(), ctfull uiCity.val_full();
          if (!
intval(uiUCity.val()) || !isVisible('inv_uni_info')) {
            
uiUCountry.val(cnfulltrue);
            
uiUCity.val(ctfulltrue);
          }
          if (!
intval(uiSCity.val()) || !isVisible('inv_school_info')) {
            
uiSCountry.val(cnfulltrue);
            
uiSCity.val(ctfulltrue);
          }
        }
      }
    });

    
uiUCountry = new CountrySelect(ge('inv_ucountry'), ge('inv_ucountry_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
progressBarge('uni_progress'),
      
countryselData.u_country,
      
eduFormSelectuiEducationForm,
      
eduStatusSelectuiEducationStatus,
      
citySelectuiUCity
    
});

    
uiSCountry = new CountrySelect(ge('inv_scountry'), ge('inv_scountry_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
progressBarge('school_progress'),
      
countryselData.s_country,
      
classSelectuiClass,
      
citySelectuiSCity
    
});

    
uiCountry = new CountrySelect(ge('inv_country'), ge('inv_country_row'), {
      
width178,
      
showslideShow,
      
hideslideHide,
      
progressBarge('city_progress'),
      
countryselData.country,
      
citySelectuiCity,
      
onChange: function(value) {
        
value intval(value);
        if (
value) {
          var 
full uiCountry.val_full();
          if (!
intval(uiUCountry.val()) || !isVisible('inv_uni_info')) {
            
uiUCountry.val(fulltrue);
          }
          if (!
intval(uiSCountry.val()) || !isVisible('inv_school_info')) {
            
uiSCountry.val(fulltrue);
          }
        }
      }
    });

    
uiGrad = new Dropdown(ge('inv_ugraduation'), selData.graduations, {
      
width178,
      
autocompletetrue,
      
placeholderColor'#000',
      
placeholdercur.lang.select_year_not_selected,
      
noResultcur.lang.select_year_not_found,
      
selectedItemsselData.grad,
      
onChange: function(value) {
        if (!
intval(value)) {
          
uiGrad.clear();
        }
      }
    });

    
uiSchoolStartYear = new Dropdown(ge('inv_sstart'), selData.start_years, {
      
width178,
      
autocompletetrue,
      
placeholderColor'#000',
      
placeholdercur.lang.select_year_not_selected,
      
noResultcur.lang.select_year_not_found,
      
selectedItemsselData.s_start,
      
onChange: function(value) {
        if (!
intval(value)) {
          
uiSchoolStartYear.clear();
        }
      }
    });

    
uiSchoolFinishYear = new Dropdown(ge('inv_sfinish'), selData.finish_years, {
      
width178,
      
autocompletetrue,
      
placeholderColor'#000',
      
placeholdercur.lang.select_year_not_selected,
      
noResultcur.lang.select_year_not_found,
      
selectedItemsselData.s_finish,
      
onChange: function(value) {
        if (!
intval(value)) {
          
uiSchoolFinishYear.clear();
        }
      }
    });

    
uiSchoolGradYear = new Dropdown(ge('inv_sgraduation'), selData.finish_years, {
      
width178,
      
autocompletetrue,
      
placeholderColor'#000',
      
placeholdercur.lang.select_year_not_selected,
      
noResultcur.lang.select_year_not_found,
      
selectedItemsselData.s_grad,
      
onChange: function(value) {
        if (!
intval(value)) {
          
uiSchoolGradYear.clear();
        }
      }
    });

  },

  
send: function(force) {
    if (!
force && isVisible('invite_progress')) return;

    var 
fnameRaw trim(ge('inv_fname').value), lnameRaw trim(ge('inv_lname').value);
    var 
name cleanName(fnameRawlnameRaw);
    
fname name[0];
    
lname name[1];

    var 
sex isVisible('inv_sex_row') ? intval(ge('inv_sex').value) : -1phone ge('inv_mobile').value;
    if (!
fname || fname.length fnameRaw.length) {
      
scrollToTop(0);
      return 
notaBene('inv_fname');
    }
    if (!
lname || lname.length lnameRaw.length) {
      
scrollToTop(0);
      return 
notaBene('inv_lname');
    }
    if (!
sex) {
      return 
cur.uiSex.showDefaultList();
    }
    if (
phone.replace(/[^0-9]/g'').length 5) {
      
scrollToTop(0);
      return 
notaBene('inv_mobile');
    }
    var 
params = {act'invite'hashcur.invHashfnamefnamelnamelnamesexsexphonephonelangisVisible('inv_lang_row') ? ge('inv_lang').value 0};
    if (
isVisible('inv_base_info')) {
      
extend(params, {
        
bdayge('inv_bday').value,
        
bmonthge('inv_bmonth').value,
        
byearge('inv_byear').value,
        
countryge('inv_country').value,
        
cityge('inv_city').value
      
});
    }
    if (
isVisible('inv_school_info')) {
      
extend(params, {
        
scountryge('inv_scountry').value,
        
scityge('inv_scity').value,
        
sschoolge('inv_sschool').value,
        
sschool_customge('inv_sschool_custom').value,
        
sschool_typege('inv_sschool_type').value
      
});
      if (
isVisible('inv_sdetails')) {
        
extend(params, {
          
sclassge('inv_sclass').value,
          
sstartge('inv_sstart').value,
          
sfinishge('inv_sfinish').value,
          
sgraduationge('inv_sgraduation').value
        
});
      }
    }
    if (
isVisible('inv_uni_info')) {
      
extend(params, {
        
ucountryge('inv_ucountry').value,
        
ucityge('inv_ucity').value,
        
uuniversityge('inv_uuniversity').value,
        
uuniversity_customge('inv_uuniversity_custom').value,
        
ufacultyge('inv_ufaculty').value,
        
ufaculty_customge('inv_ufaculty_custom').value,
        
uchairge('inv_uchair').value,
        
uchair_customge('inv_uchair_custom').value
      
});
      if (
isVisible('inv_udetails')) {
        
extend(params, {
          
ueduformge('inv_uedu_form').value,
          
uedustatusge('inv_uedu_status').value,
          
ugraduationge('inv_ugraduation').value
        
});
      }
    }
    if (
isVisible('inv_error')) {
      
slideUp('inv_error'200);
    }
    
ajax.post('invite.php'params, {progress'invite_progress'onDone: function(res) {
      if (
res) {
        
setTimeout(inviter.send.pbind(true), 1000);
        return;
      }
      
show('inv_sex_row');
      
cur.uiSex.showDefaultList();
    }, 
onFail: function(text) {
      if (!
text) return;

      
ge('inv_error').innerHTML text;
      if (!
isVisible('inv_error')) {
        
slideDown('inv_error'200);
      }
      return 
true;
    }});
  }
}

try{
stManager.done('invite.js');}catch(e){}
?>
Онлайн: 0
Реклама