53 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html lang="en">
 | 
						|
<head>
 | 
						|
    <meta charset="UTF-8">
 | 
						|
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
						|
    <title>HeroModels Project Rhai WASM Test</title>
 | 
						|
    <style>
 | 
						|
        body { font-family: sans-serif; margin: 20px; background-color: #f4f4f4; color: #333; }
 | 
						|
        #output { margin-top: 20px; padding: 10px; border: 1px solid #ccc; background-color: #fff; white-space: pre-wrap; }
 | 
						|
        button { padding: 10px 15px; font-size: 16px; cursor: pointer; background-color: #007bff; color: white; border: none; border-radius: 5px; }
 | 
						|
        button:hover { background-color: #0056b3; }
 | 
						|
        h1 { color: #0056b3; }
 | 
						|
    </style>
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
    <h1>HeroModels Project Rhai WASM Test</h1>
 | 
						|
    <p>Open your browser's developer console to see detailed logs from the Rhai script.</p>
 | 
						|
    <button id="runScriptButton">Run Rhai Script in WASM</button>
 | 
						|
    
 | 
						|
    <script type="module">
 | 
						|
        // Import the WASM module
 | 
						|
        import init, { run_project_script_wasm } from './pkg/project_rhai_wasm_example.js';
 | 
						|
 | 
						|
        async function main() {
 | 
						|
            // Initialize the WASM module
 | 
						|
            await init();
 | 
						|
            console.log("WASM module initialized.");
 | 
						|
 | 
						|
            const runButton = document.getElementById('runScriptButton');
 | 
						|
            runButton.onclick = () => {
 | 
						|
                console.log("Button clicked, attempting to run script...");
 | 
						|
                try {
 | 
						|
                    run_project_script_wasm();
 | 
						|
                    console.log("run_project_script_wasm called.");
 | 
						|
                } catch (e) {
 | 
						|
                    console.error("Error calling run_project_script_wasm:", e);
 | 
						|
                }
 | 
						|
            };
 | 
						|
             // Automatically run the script on load if desired
 | 
						|
            // console.log("Attempting to run script on load...");
 | 
						|
            // try {
 | 
						|
            //     run_project_script_wasm();
 | 
						|
            //     console.log("run_project_script_wasm called on load.");
 | 
						|
            // } catch (e) {
 | 
						|
            //     console.error("Error calling run_project_script_wasm on load:", e);
 | 
						|
            // }
 | 
						|
        }
 | 
						|
 | 
						|
        main().catch(console.error);
 | 
						|
    </script>
 | 
						|
</body>
 | 
						|
</html>
 |