Squash some bugs, reduce complexity

This commit is contained in:
Gabriel Augendre 2020-06-22 21:35:20 +02:00
parent 2944056fc0
commit b98f3b9ee0
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4

View file

@ -8,16 +8,16 @@ const data = {
IncomingMailServerAuthentication: "", IncomingMailServerAuthentication: "",
IncomingMailServerHostName: "", IncomingMailServerHostName: "",
IncomingMailServerPortNumber: null, IncomingMailServerPortNumber: 993,
IncomingMailServerUsername: "", IncomingMailServerUsername: "",
IncomingMailServerUseSSL: null, IncomingMailServerUseSSL: false,
OutgoingMailServerAuthentication: "", OutgoingMailServerAuthentication: "",
OutgoingMailServerHostName: "", OutgoingMailServerHostName: "",
OutgoingMailServerPortNumber: null, OutgoingMailServerPortNumber: 465,
OutgoingMailServerUsername: "", OutgoingMailServerUsername: "",
OutgoingMailServerUseSSL: null, OutgoingMailServerUseSSL: false,
OutgoingPasswordSameAsIncomingPassword: null, OutgoingPasswordSameAsIncomingPassword: false,
PayloadDescription: "", PayloadDescription: "",
PayloadDisplayName: "", PayloadDisplayName: "",
@ -98,31 +98,25 @@ const app = new Vue({
generatedProfile: function () { generatedProfile: function () {
const template = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + const template = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" + "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" +
"<plist version='1.0'><dict></dict></plist>" "<plist version='1.0'><dict><key>PayloadContent</key><array><dict></dict></array></dict></plist>"
const parser = new DOMParser(); const parser = new DOMParser();
const xmlDoc = parser.parseFromString(template, "application/xml"); const xmlDoc = parser.parseFromString(template, "application/xml");
const dict = xmlDoc.getElementsByTagName("dict")[0]; const dict = xmlDoc.getElementsByTagName("dict")[0];
const contentElement = xmlDoc.createElement("key");
contentElement.innerHTML = "PayloadContent";
dict.appendChild(contentElement);
const arrayElement = xmlDoc.createElement("array");
dict.appendChild(arrayElement);
const contentDict = xmlDoc.createElement("dict");
arrayElement.appendChild(contentDict);
for (const [key, value] of Object.entries(this.payload)) {
const [keyElement, valueElement] = convertKeyValueToXml(xmlDoc, key, value);
contentDict.appendChild(keyElement);
contentDict.appendChild(valueElement);
}
for (const [key, value] of Object.entries(this.container)) { for (const [key, value] of Object.entries(this.container)) {
const [keyElement, valueElement] = convertKeyValueToXml(xmlDoc, key, value); const [keyElement, valueElement] = convertKeyValueToXml(xmlDoc, key, value);
dict.appendChild(keyElement); dict.appendChild(keyElement);
dict.appendChild(valueElement); dict.appendChild(valueElement);
} }
const contentDict = xmlDoc.getElementsByTagName("dict")[1];
for (const [key, value] of Object.entries(this.payload)) {
const [keyElement, valueElement] = convertKeyValueToXml(xmlDoc, key, value);
contentDict.appendChild(keyElement);
contentDict.appendChild(valueElement);
}
const serializer = new XMLSerializer(); const serializer = new XMLSerializer();
return serializer.serializeToString(xmlDoc); return serializer.serializeToString(xmlDoc);
}, },