📄 actionscontact.js
字号:
/* * Verify mandatory field and request (or not) PHP to update contacts * This function use, for each contact, the function modifyContact(). */function modifyContacts() { var zoneContact = document.getElementById('contacts'); var inputs = zoneContact.getElementsByTagName('input'); var id = document.getElementById("idperson").value; // Verification for(var i = 0; i < inputs.length; i+=4) { if (inputs[i].type == 'text' && inputs[i].id != 'ctType') { if (!verifyNotEmpty(new Array(inputs[i].id, inputs[i+1].id))) return false; } } for(var i = 0; i < inputs.length; i+=4) { if (inputs[i].type == 'text' && inputs[i].id != 'ctType') { var idContact = inputs[i].id.replace("ctType", ""); modifyContact(idContact); } } document.getElementById("content").innerHTML = msgWaiting; getPersonToModifyWithId(id); return true;}/* * Verify mandatory field and create a new contact */function createContact() { if (!verifyNotEmpty(new Array('ctType', 'ctValue'))) return false; var req = newXMLHttpRequest(), param = ''; var type = document.getElementById("ctType"); var contactValue = document.getElementById("ctValue"); var note = document.getElementById("ctNote"); var handlerFunction = getReadyStateHandler(req, getModifyPersonForm); req.onreadystatechange = handlerFunction; req.open("POST", "actions/createContact.php", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); param = "idperson=" + document.getElementById('idperson').value + "&type=" + type.value + "&value=" + contactValue.value + "¬e=" + note.value; document.getElementById("content").innerHTML = msgWaiting; req.send(param); if (debug) trace("POST createContact.php param="+param); return true;}/* * Request PHP to update a contact * @param id of the contact to update */function modifyContact(id) { var req = newXMLHttpRequest(), param = ''; var type = document.getElementById('ctType' + id); var contact = document.getElementById('ctValue' + id); var note = document.getElementById('ctNote' + id); req.open("POST", "actions/modifyContact.php", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); param = "idperson=" + document.getElementById('idperson').value + "&idcontact=" + id + "&type=" + type.value + "&value=" + contact.value + "¬e=" + note.value; req.send(param); if (debug) trace("POST modifyContact.php param="+param); return true;}/* * Delete a contact * @param contact id to delete */function deleteContact(id) { if (!confirm(lbl_delete_confirm_message)) return false; var req = newXMLHttpRequest(), param = ''; var handlerFunction = getReadyStateHandler(req, getModifyPersonForm); req.onreadystatechange = handlerFunction; req.open("POST", "actions/deleteContact.php", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); param = "idperson=" + document.getElementById('idperson').value + "&idcontact=" + id; document.getElementById("content").innerHTML = msgWaiting; req.send(param); if (debug) trace("POST deleteContact.php param="+param); return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -