actions.js

来自「一个页面界面的邮件程序」· JavaScript 代码 · 共 154 行

JS
154
字号
/* * GContact / PAUL Grégory * * In this file are functions to interact with actions (PHP) *//* * Request PHP with searched terms * @param terms to search */function askSearch(terms) {	var req = newXMLHttpRequest(), param = '';	var handlerFunction = getReadyStateHandler(req, showResult);	req.onreadystatechange = handlerFunction;  	req.open("POST", "actions/search.php", true);	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	if (terms.value.length > 0)		param = "terms="+terms.value;	document.getElementById("content").innerHTML = msgWaiting;	req.send(param);	if (debug) trace("POST search.php terms="+terms.value);	return true;}/* * Verify if the 2 passwords fields are identical and then, ask PHP to change the password. * The password is hashed in database (MD5). */function changePassword () {	if (!verifyNotEmpty(new Array('password1', 'password2')))		return false;			var password1 = document.getElementById("password1"),		password2 = document.getElementById("password2");	if(password1.value != password2.value) {		alert(lbl_passwords_not_equals);		return false;	}	var req = newXMLHttpRequest(), param = '';	var handlerFunction = getReadyStateHandler(req, getPasswordChanged);	req.onreadystatechange = handlerFunction;	req.open("POST", "actions/changePassword.php", true);	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	param = "&password=" + password1.value;	document.getElementById("content").innerHTML = msgWaiting;	req.send(param);	if (debug) trace("POST changePassword.php param="+param);	return true;}/* * Request PHP for persons in requested group * @param group id */function showGroup(id) {	var req = newXMLHttpRequest(), param = '';	var handlerFunction = getReadyStateHandler(req, showResult);	req.onreadystatechange = handlerFunction;  	req.open("POST", "actions/showPersonsFromGroup.php", true);	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	param = "idgroup="+id;	document.getElementById("content").innerHTML = msgWaiting;	req.send(param);	if (debug) trace("POST showPersonsFromGroup.php param="+param);	return true;}/* * Request PHP to get birthdays (birthdays are sorted by next ones first) */function getBirthdays() {	var req = newXMLHttpRequest();	var handlerFunction = getReadyStateHandler(req, showBirthdays);	req.onreadystatechange = handlerFunction;  	req.open("POST", "actions/getBirthdays.php", true);	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	document.getElementById("anniversaires").innerHTML = msgWaiting;	req.send('');	if (debug) trace("POST getBirthdays.php");	return true;}/* * Request PHP to get birthdays to print them (birthdays are sorted from january to december) */function getBirthdaysToPrint() {	var req = newXMLHttpRequest();	var handlerFunction = getReadyStateHandler(req, showBirthdaystoPrint);	req.onreadystatechange = handlerFunction;  	req.open("POST", "actions/getBirthdaysToPrint.php", true);	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	document.getElementById("content").innerHTML = msgWaiting;	req.send('');	if (debug) trace("POST getBirthdaysToPrint.php");	return true;}/* * Request PHP to get user preferences */function getPreferencesForm() {	var req = newXMLHttpRequest();	var handlerFunction = getReadyStateHandler(req, showPreferences);	req.onreadystatechange = handlerFunction;  	req.open("POST", "actions/getPreferences.php", true);	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	document.getElementById("content").innerHTML = msgWaiting;	req.send('');	if (debug) trace("POST getPreferences.php");	return true;}/* * Request PHP to update preferences */function changePreferences(nbField) {	var req = newXMLHttpRequest(), param = null, value = 0;	var handlerFunction = getReadyStateHandler(req, getPreferencesChanged);	req.onreadystatechange = handlerFunction;	for (var i = 0; i < 10; i++) {		var field = null;		if ((field = document.getElementById('daysBefore' + i)) == null) {			break;		} else {			if (field.checked == true)				value += Number(field.value);		}	}	req.open("POST", "actions/setPreferences.php", true);	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	param = "&value=" + value;	document.getElementById("content").innerHTML = msgWaiting;	req.send(param);	if (debug) trace("POST setPreferences.php param="+param);	return true;}

⌨️ 快捷键说明

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