mod-build 3.7.32 → 3.7.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/gulp-tasks/templates.js +65 -38
- package/package.json +1 -1
- package/package-loc1k copy.json +0 -35281
package/CHANGELOG.md
CHANGED
package/gulp-tasks/templates.js
CHANGED
|
@@ -27,52 +27,79 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
27
27
|
const CENTRAL_AC = 'Central AC';
|
|
28
28
|
const CENTRAL_HEATING = 'Central Heating';
|
|
29
29
|
siteData.isWarmWeather = false; // will use this variable in site level to update the hero title/subtitle wherever required
|
|
30
|
-
if (activeSeason.length !== 0) {
|
|
31
|
-
if (activeSeason.includes(SEASON)) {
|
|
32
|
-
siteData.isWarmWeather = true;
|
|
33
|
-
const data = JSON.stringify(siteData, null, 4);
|
|
34
|
-
const heating = '(Heating|heating|calentadores|Calentadores|calefactores|Calefactores)';
|
|
35
|
-
const and = '(\\s&\\s|\\sand\\s|and|\\sy\\s)'; // eslint-disable-line no-useless-escape
|
|
36
|
-
const ac = '(AC|Cooling|cooling|aires.*?acondicionados|Aires.*?Acondicionados)';
|
|
37
|
-
const spaces = '.*?';
|
|
38
|
-
|
|
39
|
-
const regex = new RegExp(`${heating}${spaces}${and}${spaces}${ac}`, 'gm');
|
|
40
|
-
// Find and reverse the required words in the string using regex group capture
|
|
41
|
-
const processedData = data.replaceAll(regex, '$3 $2 $1');
|
|
42
|
-
// Convert data into JSON
|
|
43
|
-
siteData = JSON.parse(processedData);
|
|
44
|
-
// Find the HVACInterest step and reverse the options array
|
|
45
|
-
if (siteData.steps && (siteData.steps.items && siteData.steps.items.length)) {
|
|
46
|
-
siteData.steps.items.forEach(function(step) {
|
|
47
|
-
const isHvacInterestStep = step && (step.stepName && step.stepName === HVAC_INTEREST) || (step.attributes && step.attributes.data && step.attributes.data['step-name'] === HVAC_INTEREST);
|
|
48
|
-
if (isHvacInterestStep) {
|
|
49
|
-
const stepFields = step.fields || step.stepContent.fields;
|
|
50
|
-
if (stepFields && stepFields.length) {
|
|
51
|
-
stepFields.forEach(function(field) {
|
|
52
|
-
const firstOption = field.options[0];
|
|
53
|
-
const lastOption = field.options[field.options.length - 1];
|
|
54
|
-
const firstOptionIsCentralHeating = (firstOption.attributes && firstOption.attributes.value === CENTRAL_HEATING) || firstOption.value === CENTRAL_HEATING;
|
|
55
|
-
const lastOptionIsCentralAC = (lastOption.attributes && lastOption.attributes.value === CENTRAL_AC) || lastOption.value === CENTRAL_AC;
|
|
56
|
-
// if the first option is central heating & last option is central ac then only swap those options
|
|
57
|
-
if (firstOptionIsCentralHeating && lastOptionIsCentralAC) {
|
|
58
|
-
field.options[0] = lastOption;
|
|
59
|
-
field.options[field.options.length - 1] = firstOption;
|
|
60
|
-
}
|
|
61
30
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
31
|
+
var processStepsOptions = async function(steps, HVAC_INTEREST, CENTRAL_AC, CENTRAL_HEATING) {
|
|
32
|
+
if (steps && steps.items && steps.items.length) {
|
|
33
|
+
for (const step of steps.items) {
|
|
34
|
+
const isHvacInterestStep = step && (step.stepName && step.stepName === HVAC_INTEREST) || (step.attributes && step.attributes.data && step.attributes.data['step-name'] === HVAC_INTEREST);
|
|
35
|
+
if (isHvacInterestStep) {
|
|
36
|
+
const stepFields = step.fields || step.stepContent.fields;
|
|
37
|
+
if (stepFields && stepFields.length) {
|
|
38
|
+
for (const field of stepFields) {
|
|
39
|
+
const firstOption = field.options[0];
|
|
40
|
+
const lastOption = field.options[field.options.length - 1];
|
|
41
|
+
const firstOptionIsCentralHeating = (firstOption.attributes && firstOption.attributes.value === CENTRAL_HEATING) || firstOption.value === CENTRAL_HEATING;
|
|
42
|
+
const lastOptionIsCentralAC = (lastOption.attributes && lastOption.attributes.value === CENTRAL_AC) || lastOption.value === CENTRAL_AC;
|
|
43
|
+
// if the first option is central heating & last option is central ac then only swap those options
|
|
44
|
+
if (firstOptionIsCentralHeating && lastOptionIsCentralAC) {
|
|
45
|
+
field.options[0] = lastOption;
|
|
46
|
+
field.options[field.options.length - 1] = firstOption;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
field.options.some(function(option) {
|
|
50
|
+
if (option.checked) {
|
|
51
|
+
option.checked = false;
|
|
52
|
+
field.options[0].checked = true;
|
|
53
|
+
}
|
|
68
54
|
});
|
|
69
55
|
}
|
|
70
56
|
}
|
|
71
|
-
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var applySeasonalChangesToAllSteps = async function(data, HVAC_INTEREST, CENTRAL_AC, CENTRAL_HEATING) {
|
|
63
|
+
if (!data || typeof data !== 'object') {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (data.steps && typeof data.steps === 'object') {
|
|
68
|
+
await processStepsOptions(data.steps, HVAC_INTEREST, CENTRAL_AC, CENTRAL_HEATING);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (const key of Object.keys(data)) {
|
|
72
|
+
const value = data[key];
|
|
73
|
+
if (typeof value === 'object' && value !== null) {
|
|
74
|
+
await applySeasonalChangesToAllSteps(value, HVAC_INTEREST, CENTRAL_AC, CENTRAL_HEATING);
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|
|
79
|
+
var applySeasonalUpdates = async function() {
|
|
80
|
+
if (activeSeason.length !== 0) {
|
|
81
|
+
if (activeSeason.includes(SEASON)) {
|
|
82
|
+
siteData.isWarmWeather = true;
|
|
83
|
+
const data = JSON.stringify(siteData, null, 4);
|
|
84
|
+
const heating = '(Heating|heating|calentadores|Calentadores|calefactores|Calefactores)';
|
|
85
|
+
const and = '(\\s&\\s|\\sand\\s|and|\\sy\\s)'; // eslint-disable-line no-useless-escape
|
|
86
|
+
const ac = '(AC|Cooling|cooling|aires.*?acondicionados|Aires.*?Acondicionados)';
|
|
87
|
+
const spaces = '.*?';
|
|
88
|
+
|
|
89
|
+
const regex = new RegExp(`${heating}${spaces}${and}${spaces}${ac}`, 'gm');
|
|
90
|
+
// Find and reverse the required words in the string using regex group capture
|
|
91
|
+
const processedData = data.replaceAll(regex, '$3 $2 $1');
|
|
92
|
+
// Convert data into JSON
|
|
93
|
+
siteData = JSON.parse(processedData);
|
|
94
|
+
// Apply seasonal changes to all steps objects recursively
|
|
95
|
+
await applySeasonalChangesToAllSteps(siteData, HVAC_INTEREST, CENTRAL_AC, CENTRAL_HEATING);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Apply seasonal updates
|
|
101
|
+
applySeasonalUpdates();
|
|
102
|
+
|
|
76
103
|
var templatesData = Object.assign(commonData(), qsFooterData(siteData), quoteFooterData(siteData), siteData, { isLocal, nodeEnv, assetsPath, buildPath });
|
|
77
104
|
|
|
78
105
|
// This is helper function to evaluate JS expressions
|