mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Tidy
- Move some scripts to their own js files - Move some duplicate code blocks to functions - General tidy & spacing cleanups (#538)
This commit is contained in:
9
js/client_delete_confirm.js
Normal file
9
js/client_delete_confirm.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// Force the user to correctly type the client name to be deleted before activating the button to delete a client
|
||||
function validateClientNameDelete(client_id) {
|
||||
if (document.getElementById("clientNameProvided" + client_id).value === document.getElementById("clientName" + client_id).value) {
|
||||
document.getElementById("clientDeleteButton" + client_id).className = "btn btn-danger btn-lg px-5";
|
||||
}
|
||||
else{
|
||||
document.getElementById("clientDeleteButton" + client_id).className = "btn btn-danger btn-lg px-5 disabled";
|
||||
}
|
||||
}
|
||||
74
js/domain_edit_modal.js
Normal file
74
js/domain_edit_modal.js
Normal file
@@ -0,0 +1,74 @@
|
||||
function populateDomainEditModal(client_id, domain_id) {
|
||||
|
||||
// Send a GET request to post.php as post.php?domain_get_json_details=true&client_id=NUM&domain_id=NUM
|
||||
jQuery.get(
|
||||
"ajax.php",
|
||||
{domain_get_json_details: 'true', client_id: client_id, domain_id: domain_id},
|
||||
function(data) {
|
||||
|
||||
// If we get a response from post.php, parse it as JSON
|
||||
const response = JSON.parse(data);
|
||||
|
||||
// Access the domain info (one), registrars (multiple) and webhosts (multiple)
|
||||
const domain = response.domain[0];
|
||||
const vendors = response.vendors;
|
||||
|
||||
// Populate the domain modal fields
|
||||
document.getElementById("editHeader").innerText = domain.domain_name;
|
||||
document.getElementById("editDomainId").value = domain_id;
|
||||
document.getElementById("editDomainName").value = domain.domain_name;
|
||||
document.getElementById("editExpire").value = domain.domain_expire;
|
||||
document.getElementById("editDomainIP").value = domain.domain_ip;
|
||||
document.getElementById("editNameServers").value = domain.domain_name_servers;
|
||||
document.getElementById("editMailServers").value = domain.domain_mail_servers;
|
||||
document.getElementById("editTxtRecords").value = domain.domain_txt;
|
||||
document.getElementById("editRawWhois").value = domain.domain_raw_whois;
|
||||
|
||||
/* DROPDOWNS */
|
||||
|
||||
// Registrar dropdown
|
||||
var registrarDropdown = document.getElementById("editRegistrarId");
|
||||
|
||||
// Clear registrar dropdown
|
||||
var i, L = registrarDropdown.options.length -1;
|
||||
for(i = L; i >= 0; i--) {
|
||||
registrarDropdown.remove(i);
|
||||
}
|
||||
registrarDropdown[registrarDropdown.length] = new Option('- Vendor -', '0');
|
||||
|
||||
// Populate dropdown
|
||||
vendors.forEach(vendor => {
|
||||
if (parseInt(vendor.vendor_id) == parseInt(domain.domain_registrar)) {
|
||||
// Selected domain
|
||||
registrarDropdown[registrarDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id, true, true);
|
||||
}
|
||||
else{
|
||||
registrarDropdown[registrarDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id);
|
||||
}
|
||||
});
|
||||
|
||||
// Webhost dropdown
|
||||
var webhostDropdown = document.getElementById("editWebhostId");
|
||||
|
||||
// Clear registrar dropdown
|
||||
var i, L = webhostDropdown.options.length -1;
|
||||
for(i = L; i >= 0; i--) {
|
||||
webhostDropdown.remove(i);
|
||||
}
|
||||
webhostDropdown[webhostDropdown.length] = new Option('- Vendor -', '0');
|
||||
|
||||
// Populate dropdown
|
||||
vendors.forEach(vendor => {
|
||||
if (parseInt(vendor.vendor_id) == parseInt(domain.domain_webhost)) {
|
||||
// Selected domain
|
||||
webhostDropdown[webhostDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id, true, true);
|
||||
}
|
||||
else{
|
||||
webhostDropdown[webhostDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user