Inital Commit
This commit is contained in:
72
html/rechner/debug.js
Normal file
72
html/rechner/debug.js
Normal file
@@ -0,0 +1,72 @@
|
||||
// Debug script to check form fields
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
console.log("Debug script loaded");
|
||||
|
||||
// Add a direct button click handler that bypasses the main script
|
||||
setTimeout(() => {
|
||||
// Take over the click event for the button
|
||||
const button = document.getElementById('executeConversion');
|
||||
if (button) {
|
||||
console.log("Found button for direct handling:", button);
|
||||
|
||||
// Replace all click event listeners
|
||||
button.replaceWith(button.cloneNode(true));
|
||||
const newButton = document.getElementById('executeConversion');
|
||||
|
||||
newButton.addEventListener('click', function(e) {
|
||||
// Prevent any other handlers from running
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
console.log("DIRECT HANDLER: Button clicked");
|
||||
|
||||
// Check all form fields
|
||||
const fromAsset = document.getElementById('fromAsset').value;
|
||||
const conversionAmount = document.getElementById('conversionAmount').value;
|
||||
const conversionType = document.getElementById('conversionType').value;
|
||||
const toAsset = document.getElementById('toAsset').value;
|
||||
|
||||
console.log("Form values:", {
|
||||
fromAsset,
|
||||
conversionAmount: conversionAmount,
|
||||
conversionType,
|
||||
toAsset
|
||||
});
|
||||
|
||||
// Try to do the conversion directly
|
||||
try {
|
||||
// Find the tracker elements directly
|
||||
const fromTracker = document.getElementById(fromAsset);
|
||||
const toTracker = document.getElementById(toAsset);
|
||||
|
||||
console.log("Tracker elements directly:", {
|
||||
fromTracker: fromTracker ? "Found" : "Not found",
|
||||
toTracker: toTracker ? "Found" : "Not found"
|
||||
});
|
||||
|
||||
if (!fromTracker || !toTracker || !conversionAmount) {
|
||||
alert("Please fill in all fields with valid values (direct handler).");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get coin names for logging
|
||||
const fromName = fromTracker.querySelector(".coin-tracker-header input.coin-name-input").value;
|
||||
const toName = toTracker.querySelector(".coin-tracker-header input.coin-name-input").value;
|
||||
|
||||
console.log("Got names:", {fromName, toName});
|
||||
|
||||
// Simple check - show that we found them
|
||||
alert(`Direct handler found: From ${fromName} to ${toName} - Amount: $${conversionAmount}`);
|
||||
} catch (err) {
|
||||
console.error("Direct handler error:", err);
|
||||
alert("Error in direct handler: " + err.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.error("Button not found for direct handling");
|
||||
}
|
||||
}, 1000); // Wait for everything else to be set up
|
||||
} else {
|
||||
console.error("Button not found");
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user