File size: 8,265 Bytes
f7a2d86
 
 
 
 
 
 
08a83f3
 
f7a2d86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08a83f3
 
f7a2d86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0478827
 
 
 
 
 
08a83f3
0478827
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08a83f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0478827
08a83f3
 
 
 
0478827
08a83f3
0478827
08a83f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0478827
 
 
 
 
 
 
 
08a83f3
 
 
 
 
 
 
 
 
 
 
f7a2d86
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AppWizard - Mobile Agentic App Launcher</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <div class="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl">
            <div class="md:flex">
                <div class="p-8 w-full">
                    <div class="flex items-center justify-center mb-6">
                        <i class="fas fa-hat-wizard text-4xl text-purple-600 mr-3"></i>
                        <h1 class="text-3xl font-bold text-gray-800">AppWizard</h1>
                    </div>
                    <p class="mt-2 text-gray-600">Your magical app launcher that responds to voice and text commands!</p>
                    
                    <div class="mt-8">
                        <div class="flex items-center mb-4">
                            <i class="fas fa-microphone text-purple-500 mr-2"></i>
                            <h2 class="text-xl font-semibold">Voice Command</h2>
                        </div>
                        <button class="w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-3 px-4 rounded-lg flex items-center justify-center">
                            <i class="fas fa-microphone mr-2"></i> Tap to Speak
                        </button>
                    </div>
                    
                    <div class="mt-6">
                        <div class="flex items-center mb-4">
                            <i class="fas fa-keyboard text-purple-500 mr-2"></i>
                            <h2 class="text-xl font-semibold">Text Command</h2>
                        </div>
                        <div class="relative">
                    <input type="text" placeholder="Type your command..." class="w-full border border-gray-300 rounded-lg py-3 px-4 pr-12 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" onkeypress="if(event.key === 'Enter') document.querySelector('.fa-paper-plane').click()">
<button class="absolute right-3 top-3 text-purple-600 hover:text-purple-800">
                                <i class="fas fa-paper-plane"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div class="mt-8">
                        <h3 class="text-lg font-medium mb-3">Quick Categories</h3>
                        <div class="grid grid-cols-3 gap-3">
                            <button class="bg-blue-100 text-blue-800 py-2 px-3 rounded-lg flex items-center justify-center">
                                <i class="fas fa-taxi mr-2"></i> Cabs
                            </button>
                            <button class="bg-green-100 text-green-800 py-2 px-3 rounded-lg flex items-center justify-center">
                                <i class="fas fa-utensils mr-2"></i> Food
                            </button>
                            <button class="bg-yellow-100 text-yellow-800 py-2 px-3 rounded-lg flex items-center justify-center">
                                <i class="fas fa-music mr-2"></i> Music
                            </button>
                        </div>
                    </div>
                    
                    <div class="mt-8 pt-4 border-t border-gray-200">
                        <p class="text-sm text-gray-500">
                            <i class="fas fa-info-circle mr-1"></i> AppWizard only opens apps when you ask and cannot access their data.
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        // Check for speech recognition support
        if (!('webkitSpeechRecognition' in window) && !('SpeechRecognition' in window)) {
            document.querySelector('.fa-microphone').parentElement.style.display = 'none';
            alert('Voice commands not supported in your browser. Try Chrome or Edge.');
        }
document.querySelector('.fa-microphone').parentElement.addEventListener('click', async () => {
            try {
                const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
                if (!SpeechRecognition) {
                    alert('Speech recognition not supported in your browser');
                    return;
                }

                const recognition = new SpeechRecognition();
                recognition.lang = 'en-US';
                recognition.interimResults = false;
                recognition.maxAlternatives = 1;

                recognition.start();
                recognition.onresult = async (event) => {
                    const command = event.results[0][0].transcript;
                    const response = await fetch('/api/process-command', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({ command, type: 'voice' })
                    });
const data = await response.json();
                
                if (data.success) {
                    // Process the command and launch appropriate app
                    window.location.href = data.redirectUrl || '#';
                } else {
                    alert('Voice command failed: ' + data.message);
                }
            } catch (error) {
                console.error('Error:', error);
                alert('Failed to process voice command');
            }
        });

        // Text command functionality
        document.querySelector('.fa-paper-plane').addEventListener('click', async () => {
            const input = document.querySelector('input[type="text"]');
            const command = input.value.trim();
            
            if (!command) return;
            
            try {
                const response = await fetch('/api/process-command', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({ command, type: 'text' })
                });
const data = await response.json();
                
                if (data.success) {
                    // Process the command and launch appropriate app
                    window.location.href = data.redirectUrl || '#';
                    input.value = '';
                } else {
                    alert('Command failed: ' + data.message);
                }
            } catch (error) {
                console.error('Error:', error);
                alert('Failed to process command');
            }
        });

        // Quick category buttons
        document.querySelectorAll('.grid button').forEach(button => {
            button.addEventListener('click', async () => {
                const category = button.textContent.trim().split('\n')[0];
                
                try {
                const response = await fetch('/api/process-command', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({ command: category, type: 'quick' })
                });
const data = await response.json();
                    
                    if (data.success) {
                        window.location.href = data.redirectUrl || '#';
                    } else {
                        alert('Failed to launch: ' + data.message);
                    }
                } catch (error) {
                    console.error('Error:', error);
                    alert('Failed to process quick command');
                }
            });
        });
    </script>
</body>
</html>