jQuery(function() {
// Creamos el mapa o diccionario de slider-variable
var mapping = {
"#annualPaymentsProcessingFee": {slider: "#annualPaymentsProcessingFee-slider", variable: "annualPaymentsProcessingFee"},
"#averageOrderValue": {slider: "#averageOrderValue-slider", variable: "averageOrderValue"},
"#percentageTransactionsFHEligible": {slider: "#percentageTransactionsFHEligible-slider", variable: "percentageTransactionsFHEligible"},
"#processingFeePercentage": {variable: "processingFeePercentage"},
"#processingFeePerTransaction": {variable: "processingFeePerTransaction"}
};
// Manejador del evento, ya solo lo relacionas al mapa anterior
$(document).on("change keyup", Object.keys(mapping).join(", "), function() {
var id = "#" + $(this).attr('id');
window[mapping[id].variable] = +$(this).val(); // Asigna el valor a la variable
if(mapping[id].slider) {
$(mapping[id].slider).slider("value", window[mapping[id].variable]);
}
recount();
});
});