Team Ai
Apppublic

hamzaou/text2code

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
script.js31 linesDownload Raw Back to root
1function app() {2    return {3        open: false,4        loading: false,5        selectedPrompt: null,6        init() {7 8        },9        async generateCode() {10            this.open = !this.open;11            this.loading = !this.loading;12            const prompt = document.getElementById('prompt-input').value;13            console.log('Prompt:', prompt);14            // try {15            // 	const prompt = document.getElementById('prompt-input').value;16            // } catch (error) {17            // 	console.error('Error generating code:', error);18            // } finally {19            // 	// Update the loading state20            // 	this.loading = !this.loading;21            // }22        },23        updateContent(prompt) {24            document.getElementById('prompt-input').value = prompt;25        },26        copyGeneratedCode() {27            const generatedCodeElement = document.getElementById('generated-code');28            const codeToCopy = generatedCodeElement.textContent;29        },30    };31}