// Copyright (C) 2020 New Entity Operations Inc.
// P1: cleanValue.js
// https://www.NewEntity.io/section/1/
// cleanValue.js
// Version 0.4 (12/24/2020)
// On top of server side validation which is also in place, values can be stripped of harmful content before posting
var urlFullPathContact = "https://www.newentity.io/contact/";
const buttonContact = document.getElementById("buttonContact");
const enforceHTTPS = 1;
let listCurred = [];
// By field Map
function inputCleanValue (assembledString, a=0, b=0, c=0) {
// Submit here
if (a>0) {
let neededStringA = assembledString;
console.log(neededStringA);
}
if (b>0) {
let neededStringB = assembledString;
console.log(neededStringB);
}
if (c>0) {
let neededStringC = assembledString;
console.log(neededStringC);
}
// console.log("The contact button was pressed. Thank you. I'll be in touch soon.");
}
function moduleContactInstance (fieldValue) {
let counterCure = 0;
// Call stack begins here
var valueCleanInplaceList = new Map([
["<", "\/<\/"],
[">", "\/>\/"],
["?", "\/?\/"],
["/", "\/(/)\/"],
["#", "\/#\/"],
["&", "\/&\/"]
]);
function processTranslation (a=0, b=0, c=0) {
var assessValue = fieldValue[counterCure];
try {
var cureThisValue = valueCleanInplaceList.get(assessValue);
listCurred.push(cureThisValue);
} catch (err) {
listCurred.push(assessValue);
}
}
while (counterCure < fieldValue.length) {
processTranslation();
counterCure++;
}
let assembledString = listCurred.toString();
inputCleanValue(assembledString, a, b, c);
}
try {
buttonContact.addEventListener('click', function () {
// perform the routine for each required field
let retrievalDOMFieldValueA = document.getElementById("name").value;
fieldValueA = [];
function StringA () {
fieldValueA = retrievalDOMFieldValueA.split();
}
StringA(a=1, b=0, c=0);
moduleContactInstance(fieldValue=fieldValueA);
let retrievalDOMFieldValueB = document.getElementById("your_message").value;
fieldValueB = [];
function StringB () {
fieldValueB = retrievalDOMFieldValueB.split();
}
StringB(a=0, b=1, c=0);
moduleContactInstance(fieldValue=fieldValueB);
let retrievalDOMFieldValueC = document.getElementById("contact_here").value;
fieldValueC = [];
function StringC () {
fieldValueC = retrievalDOMFieldValueC.split();
}
StringC(a=0, b=0, c=1);
moduleContactInstance(fieldValue=fieldValueC);
// Finalize the run
listCurred = [];
// Finalize Request
const tokenCSRF = document.getElementById("csrf_token").value;
const fieldType = document.getElementById("type").value;
const ageRange = document.getElementById("age").value;
let objectRequestPOST = {
"csrf_token": tokenCSRF,
"name": neededStringA,
"type": fieldType,
"your_message": neededStringB,
"contact_here": neededStringC,
"age": ageRange
}
makeRequestPOST(objectRequestPOST);
console.log("Token: generated");
})
} catch (error) {
console.log("Token: none");
}