robustness review of price calc js
This commit is contained in:
parent
e7c6a53a17
commit
27c41a6187
7 changed files with 143 additions and 24 deletions
|
|
@ -9,7 +9,49 @@
|
|||
{% block extra_js %}
|
||||
{% if debug %}
|
||||
<!-- Development: Load individual modules for easier debugging -->
|
||||
<script defer src="{% static 'js/price-calculator.js' %}"></script>
|
||||
{% compress js inline %}
|
||||
<script src="{% static 'js/price-calculator/dom-manager.js' %}"></script>
|
||||
<script src="{% static 'js/price-calculator/pricing-data-manager.js' %}"></script>
|
||||
<script src="{% static 'js/price-calculator/plan-manager.js' %}"></script>
|
||||
<script src="{% static 'js/price-calculator/addon-manager.js' %}"></script>
|
||||
<script src="{% static 'js/price-calculator/ui-manager.js' %}"></script>
|
||||
<script src="{% static 'js/price-calculator/order-manager.js' %}"></script>
|
||||
<script src="{% static 'js/price-calculator/price-calculator.js' %}"></script>
|
||||
<script>
|
||||
// Initialize calculator when DOM is loaded
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Check if we're on a page that needs the price calculator
|
||||
if (document.getElementById('cpuRange')) {
|
||||
try {
|
||||
window.priceCalculator = new PriceCalculator();
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize price calculator:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Global function for traditional plan selection (used by template buttons)
|
||||
function selectPlan(element) {
|
||||
if (!element) return;
|
||||
|
||||
const planId = element.getAttribute('data-plan-id');
|
||||
const planName = element.getAttribute('data-plan-name');
|
||||
|
||||
// Find the plan dropdown in the contact form
|
||||
const planDropdown = document.getElementById('id_choice');
|
||||
if (planDropdown) {
|
||||
// Find the option with matching plan id and select it
|
||||
for (let i = 0; i < planDropdown.options.length; i++) {
|
||||
const optionValue = planDropdown.options[i].value;
|
||||
if (optionValue.startsWith(planId + '|')) {
|
||||
planDropdown.selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endcompress %}
|
||||
{% else %}
|
||||
<!-- Production: Load compressed bundle -->
|
||||
{% compress js %}
|
||||
|
|
@ -25,12 +67,18 @@
|
|||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Check if we're on a page that needs the price calculator
|
||||
if (document.getElementById('cpuRange')) {
|
||||
window.priceCalculator = new PriceCalculator();
|
||||
try {
|
||||
window.priceCalculator = new PriceCalculator();
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize price calculator:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Global function for traditional plan selection (used by template buttons)
|
||||
function selectPlan(element) {
|
||||
if (!element) return;
|
||||
|
||||
const planId = element.getAttribute('data-plan-id');
|
||||
const planName = element.getAttribute('data-plan-name');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue