⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 profile.js

📁 LiteBlaster 是一款基于 .NET Framework 原创的 ASP.NET 论坛系统。后台程序库采用 C#/VB.NET 编写
💻 JS
字号:
// profile
// x_core.js, ajax.js, main.js, xwindow.js needed

var profileUserAdvancedInfoRealName, profileUserAdvancedInfoShowRealName, profileUserAdvancedInfoMale, profileUserAdvancedInfoFemale, profileUserAdvancedInfoShowGender, profileUserAdvancedInfoBirthdayYear, profileUserAdvancedInfoBirthdayMonth, profileUserAdvancedInfoBirthdayDay, profileUserAdvancedInfoShowBirthday, profileUserAdvancedInfoEmail, profileUserAdvancedInfoShowEmail, profileUserAdvancedInfoAddress, profileUserAdvancedInfoShowAddress, profileUserAdvancedInfoIM, profileUserAdvancedInfoShowIM, profileUserAdvancedInfoDescription, profileUserAdvancedInfoSubmit;
var profilePostBasicInfoComeFrom, profilePostBasicInfoSignature, profilePostBasicInfoSubmit;
var profileCustomTitleCustomTitle, profileCustomTitleSubmit;
var profileFaceEnabled, profileFaceSystemFacePreview, profileFaceCustomFacePreview, profileFaceCustom, profileFaceSubmit;
var profilePostDisplayInfoTopicCountPerPage, profilePostDisplayInfoPostCountPerPage, profilePostDisplayInfoParentBoardDisplayChildrenTopics, profilePostDisplayInfoSubmit;
var profileTimeSettingsTimeZone, profileTimeSettingsTimeFormat, profileTimeSettingsDSTMode, profileTimeSettingsSubmit;
var profileSecurityProtectionQuestion, profileSecurityProtectionAnswer, profileSecurityProtectionNewQuestion, profileSecurityProtectionNewAnswer, profileSecurityProtectionSubmit;
function initProfileElements(){
	//user advanced info
	profileUserAdvancedInfoRealName = xGetElementById('ProfileUserAdvancedInfoRealName');
	profileUserAdvancedInfoShowRealName = xGetElementById('ProfileUserAdvancedInfoShowRealName');
	profileUserAdvancedInfoMale = xGetElementById('ProfileUserAdvancedInfoMale');
	profileUserAdvancedInfoFemale = xGetElementById('ProfileUserAdvancedInfoFemale');
	profileUserAdvancedInfoShowGender = xGetElementById('ProfileUserAdvancedInfoShowGender');
	profileUserAdvancedInfoBirthdayYear = xGetElementById('ProfileUserAdvancedInfoBirthdayYear');
	profileUserAdvancedInfoBirthdayMonth = xGetElementById('ProfileUserAdvancedInfoBirthdayMonth');
	profileUserAdvancedInfoBirthdayDay = xGetElementById('ProfileUserAdvancedInfoBirthdayDay');
	profileUserAdvancedInfoShowBirthday = xGetElementById('ProfileUserAdvancedInfoShowBirthday');
	profileUserAdvancedInfoEmail = xGetElementById('ProfileUserAdvancedInfoEmail');
	profileUserAdvancedInfoShowEmail = xGetElementById('ProfileUserAdvancedInfoShowEmail');
	profileUserAdvancedInfoAddress = xGetElementById('ProfileUserAdvancedInfoAddress');
	profileUserAdvancedInfoShowAddress = xGetElementById('ProfileUserAdvancedInfoShowAddress');
	profileUserAdvancedInfoIM = xGetElementById('ProfileUserAdvancedInfoIM');
	profileUserAdvancedInfoShowIM = xGetElementById('ProfileUserAdvancedInfoShowIM');
	profileUserAdvancedInfoDescription = xGetElementById('ProfileUserAdvancedInfoDescription');
	profileUserAdvancedInfoSubmit = xGetElementById('ProfileUserAdvancedInfoSubmit');
	//post basic info
	profilePostBasicInfoComeFrom = xGetElementById('ProfilePostBasicInfoComeFrom');
	profilePostBasicInfoSignature = xGetElementById('ProfilePostBasicInfoSignature');
	profilePostBasicInfoSubmit = xGetElementById('ProfilePostBasicInfoSubmit');
	//custom title
	profileCustomTitleCustomTitle = xGetElementById('ProfileCustomTitleCustomTitle');
	profileCustomTitleSubmit = xGetElementById('ProfileCustomTitleSubmit');
	//face
	profileFaceEnabled = xGetElementById('ProfileFaceEnabled');
	profileFaceSystemFacePreview = xGetElementById('ProfileFaceSystemFacePreview');
	profileFaceCustomFacePreview = xGetElementById('ProfileFaceCustomFacePreview');
	profileFaceCustom = xGetElementById('ProfileFaceCustom');
	profileFaceSubmit = xGetElementById('ProfileFaceSubmit');
	//post display info
	profilePostDisplayInfoTopicCountPerPage = xGetElementById('ProfilePostDisplayInfoTopicCountPerPage');
	profilePostDisplayInfoPostCountPerPage = xGetElementById('ProfilePostDisplayInfoPostCountPerPage');
	profilePostDisplayInfoParentBoardDisplayChildrenTopics = xGetElementById('ProfilePostDisplayInfoParentBoardDisplayChildrenTopics');
	profilePostDisplayInfoSubmit = xGetElementById('ProfilePostDisplayInfoSubmit');
	//time settings
	profileTimeSettingsTimeZone = xGetElementById('ProfileTimeSettingsTimeZone');
	profileTimeSettingsTimeFormat = xGetElementById('ProfileTimeSettingsTimeFormat');
	profileTimeSettingsDSTMode = xGetElementById('ProfileTimeSettingsDSTMode');
	profileTimeSettingsSubmit = xGetElementById('ProfileTimeSettingsSubmit');
	//security protection
	profileSecurityProtectionQuestion = xGetElementById('ProfileSecurityProtectionQuestion');
	profileSecurityProtectionAnswer = xGetElementById('ProfileSecurityProtectionAnswer');
	profileSecurityProtectionNewQuestion = xGetElementById('ProfileSecurityProtectionNewQuestion');
	profileSecurityProtectionNewAnswer = xGetElementById('ProfileSecurityProtectionNewAnswer');
	profileSecurityProtectionSubmit = xGetElementById('ProfileSecurityProtectionSubmit');
}

function loadProfile(){
	//disable all buttons
	setInputDisabled(profileUserAdvancedInfoSubmit, true);
	setInputDisabled(profilePostBasicInfoSubmit, true);
	setInputDisabled(profileCustomTitleSubmit, true);
	setInputDisabled(profileFaceSubmit, true);
	setInputDisabled(profilePostDisplayInfoSubmit, true);
	setInputDisabled(profileTimeSettingsSubmit, true);
	setInputDisabled(profileSecurityProtectionSubmit, true);
	//load
	var loader = new ajax.loader('Profile.aspx', 'POST', loadProfile_onload, loadProfile_onerror, 'update=current');
}
function loadProfile_onerror(){
	alert('加载资料和选项时出错。');
}
function loadProfile_onload(){
	var xmlDoc = this.req.responseXML;
	var errInfo = getXmlElementText(xmlDoc, 'Error');
	if(errInfo){
		alert(errInfo);
	}else{
		var fetch = function(tag){
			return getXmlElementText(xmlDoc, tag);
		}
		//user advanced info
		profileUserAdvancedInfoRealName.value = fetch('RealName');
		profileUserAdvancedInfoShowRealName.checked = parseXmlText(fetch('ShowRealName'));
		if(parseXmlText(fetch('Male'))){
			profileUserAdvancedInfoMale.checked = true;
		}else{
			profileUserAdvancedInfoFemale.checked = true;
		}
		profileUserAdvancedInfoShowGender.checked = parseXmlText(fetch('ShowGender'));
		profileUserAdvancedInfoBirthdayYear.value = fetch('BirthdayYear');
		profileUserAdvancedInfoBirthdayMonth.value = fetch('BirthdayMonth');
		profileUserAdvancedInfoBirthdayDay.value = fetch('BirthdayDay');
		profileUserAdvancedInfoShowBirthday.checked = parseXmlText(fetch('ShowBirthday'));
		profileUserAdvancedInfoEmail.value = fetch('Email');
		profileUserAdvancedInfoShowEmail.checked = parseXmlText(fetch('ShowEmail'));
		profileUserAdvancedInfoAddress.value = fetch('Address');
		profileUserAdvancedInfoShowAddress.checked = parseXmlText(fetch('ShowAddress'));
		profileUserAdvancedInfoIM.value = fetch('IM');
		profileUserAdvancedInfoShowIM.checked = parseXmlText(fetch('ShowIM'));
		profileUserAdvancedInfoDescription.value = fetch('Description');
		setInputDisabled(profileUserAdvancedInfoSubmit, false);
		//post basic info
		profilePostBasicInfoComeFrom.value = fetch('ComeFrom');
		profilePostBasicInfoSignature.value = fetch('Signature');
		setInputDisabled(profilePostBasicInfoSubmit, false);
		//custom title
		profileCustomTitleCustomTitle.value = fetch('CustomTitle');
		setInputDisabled(profileCustomTitleSubmit, false);
		//face
		var faceSystem = parseXmlText(fetch('FaceSystem'));
		var faceName = fetch('FaceName');
		setElementVisible(profileFaceSystemFacePreview, false);
		setElementVisible(profileFaceCustomFacePreview, false);
		profileFaceSystemFacePreview.src = '';
		profileFaceCustomFacePreview.src = '';
		if(faceName.length > 0){
			profileFaceEnabled.checked = true;
			if(faceSystem){
				profileFaceSystemFacePreview.src = 'Faces/System/' + faceName;
				setElementVisible(profileFaceSystemFacePreview, true);
			}else{
				profileFaceCustomFacePreview.src = 'Faces/Custom/' + faceName;
				setElementVisible(profileFaceCustomFacePreview, true);
			}
		}else{
			profileFaceEnabled.checked = false;
			faceSystem = true;
		}
		profileFaceCustom.checked = !faceSystem;
		setInputDisabled(profileFaceSubmit, false);
		//post display info
		profilePostDisplayInfoTopicCountPerPage.value = fetch('TopicCountPerPage');
		profilePostDisplayInfoPostCountPerPage.value = fetch('PostCountPerPage');
		profilePostDisplayInfoParentBoardDisplayChildrenTopics.checked = parseXmlText(fetch('ParentBoardDisplayChildrenTopics'));
		setInputDisabled(profilePostDisplayInfoSubmit, false);
		//time settings
		profileTimeSettingsTimeZone.value = fetch('TimeZone');
		profileTimeSettingsTimeFormat.value = fetch('TimeFormat');
		profileTimeSettingsDSTMode.value = fetch('DSTMode');
		setInputDisabled(profileTimeSettingsSubmit, false);
		//security protection
		profileSecurityProtectionQuestion.innerHTML = encodeHtml(fetch('Question'));
		profileSecurityProtectionAnswer.value = '';
		profileSecurityProtectionNewQuestion.value = '';
		profileSecurityProtectionNewAnswer.value = '';
		setInputDisabled(profileSecurityProtectionSubmit, false);
	}
}

function setProfile(submit_btn, params){
	setInputDisabled(submit_btn, true);
	var loader = new ajax.loader('Profile.aspx', 'POST', setProfile_onload, setProfile_onerror, params);
	loader.submit_btn = submit_btn;
}
function setProfile_onload(){
	var xmlDoc = this.req.responseXML;
	var errInfo = getXmlElementText(xmlDoc, 'Error');
	if(errInfo){
		alert(errInfo);
	}else{
		alert('修改设定成功。');
	}
	setInputDisabled(this.submit_btn, false);
	if(this.submit_btn == profileSecurityProtectionSubmit){
		loadProfileQuestionOnly();
	}
}
function setProfile_onerror(){
	alert('请求设定过程中出错。');
	setInputDisabled(this.submit_btn, false);
}

function setProfileUserAdvancedInfo(){
	var params = 'update=advanced';
	params += '&realname=' + encodeURIComponent(profileUserAdvancedInfoRealName.value);
	params += '&showrealname=' + (profileUserAdvancedInfoShowRealName.checked);
	params += '&male=' + (profileUserAdvancedInfoMale.checked);
	params += '&showgender=' + (profileUserAdvancedInfoShowGender.checked);
	params += '&birthdayyear=' + profileUserAdvancedInfoBirthdayYear.value;
	params += '&birthdaymonth=' + profileUserAdvancedInfoBirthdayMonth.value;
	params += '&birthdayday=' + profileUserAdvancedInfoBirthdayDay.value;
	params += '&showbirthday=' + (profileUserAdvancedInfoShowBirthday.checked);
	params += '&email=' + encodeURIComponent(profileUserAdvancedInfoEmail.value);
	params += '&showemail=' + (profileUserAdvancedInfoShowEmail.checked);
	params += '&address=' + encodeURIComponent(profileUserAdvancedInfoAddress.value);
	params += '&showaddress=' + (profileUserAdvancedInfoShowAddress.checked);
	params += '&im=' + encodeURIComponent(profileUserAdvancedInfoIM.value);
	params += '&showim=' + (profileUserAdvancedInfoShowIM.checked);
	params += '&description=' + encodeURIComponent(profileUserAdvancedInfoDescription.value);
	setProfile(profileUserAdvancedInfoSubmit, params);
}
function setProfilePostBasicInfo(){
	var params = 'update=postbasic';
	params += '&comefrom=' + encodeURIComponent(profilePostBasicInfoComeFrom.value);
	params += '&signature=' + encodeURIComponent(profilePostBasicInfoSignature.value);
	setProfile(profilePostBasicInfoSubmit, params);
}
function setProfileCustomTitle(){
	var params = 'update=customtitle';
	params += '&customtitle=' + encodeURIComponent(profileCustomTitleCustomTitle.value);
	setProfile(profileCustomTitleSubmit, params);
}
function setProfileFace(){
	var params = 'update=face';
	var enabled = profileFaceEnabled.checked;
	params += '&enabled=' + enabled;
	if(enabled){
		var system = !profileFaceCustom.checked;
		params += '&system=' + system;
		var faceName;
		if(system){
			var replaceStr = 'Faces/System/';
			faceName = profileFaceSystemFacePreview.src.substring(profileFaceSystemFacePreview.src.lastIndexOf(replaceStr) + replaceStr.length);
			params += '&facename=' + faceName;
		}else{
			alert('现在将弹出上传头像模块。');
			var winChild = new xWindow('FaceUploader', 600, 400, -1, -1, 0, 0, 0, 1, 1, 0);
			winChild.load('Upload.aspx?upload=face');
			return;
		}
		if(faceName.length == 0){
			alert('您已经启用头像,请设定一个头像。');
			return;
		}
	}
	setProfile(profileFaceSubmit, params);
}
function setProfilePostDisplayInfo(){
	var params = 'update=postdisplay';
	params += '&topiccountperpage=' + profilePostDisplayInfoTopicCountPerPage.value;
	params += '&postcountperpage=' + profilePostDisplayInfoPostCountPerPage.value;
	params += '&parentboarddisplaychildrentopics=' + (profilePostDisplayInfoParentBoardDisplayChildrenTopics.checked);
	setProfile(profilePostDisplayInfoSubmit, params);
}
function setProfileTimeSettings(){
	var params = 'update=timesettings';
	params += '&timezone=' + profileTimeSettingsTimeZone.value;
	params += '&timeformat=' + encodeURIComponent(profileTimeSettingsTimeFormat.value);
	params += '&dstmode=' + profileTimeSettingsDSTMode.value;
	setProfile(profileTimeSettingsSubmit, params);
}
function setProfileSecurityProtection(){
	var params = 'update=questionanswer';
	params += '&answer=' + encodeURIComponent(profileSecurityProtectionAnswer.value);
	params += '&newquestion=' + encodeURIComponent(profileSecurityProtectionNewQuestion.value);
	params += '&newanswer=' + encodeURIComponent(profileSecurityProtectionNewAnswer.value);
	setProfile(profileSecurityProtectionSubmit, params);
}

function loadProfileQuestionOnly(){
	setInputDisabled(profileSecurityProtectionSubmit, true);
	var loader = new ajax.loader('Profile.aspx', 'POST', loadProfileQuestionOnly_onload, loadProfileQuestionOnly_onerror, 'update=getquestion');
}
function loadProfileQuestionOnly_onload(){
	var xmlDoc = this.req.responseXML;
	var errInfo = getXmlElementText(xmlDoc, 'Error');
	if(errInfo){
		alert(errInfo);
	}else{
		profileSecurityProtectionQuestion.innerHTML = encodeHtml(getXmlElementText(xmlDoc, 'Question'));
		profileSecurityProtectionAnswer.value = '';
		profileSecurityProtectionNewQuestion.value = '';
		profileSecurityProtectionNewAnswer.value = '';
	}
	setInputDisabled(profileSecurityProtectionSubmit, false);
}
function loadProfileQuestionOnly_onerror(){
	alert('加载提示问题过程中出错。');
	setInputDisabled(profileSecurityProtectionSubmit, false);
}

function browseSystemFaces(){
	var winChild = new xWindow('SystemFacesBrowser', 600, 400, -1, -1, 0, 0, 0, 1, 0, 0);
	winChild.load('SysImgViewer.aspx?type=0&filler=ProfileFaceSystemFacePreview');
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -