File size: 9,680 Bytes
343bf49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SmartLearn - Project Idea Generator</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>

        body {

            font-family: 'Arial', sans-serif;

            color: #333;

            margin: 0;

            padding: 0;

            position: relative;

        }

        #myVideo {

            position: fixed;

            right: 0;

            bottom: 0;

            min-width: 100%;

            min-height: 100%;

            width: auto;

            height: auto;

            z-index: -2;

        }

        .container {

            max-width: 1200px; /* Adjusted for better layout */

            margin: 40px auto;

            padding: 20px;

            background-color: rgba(255, 255, 255, 0.4);

            border-radius: 10px;

            box-shadow: 0 0 10px rgba(0,0,0,0.1);

            position: relative;

            z-index: 1;

            display: flex;

            flex-wrap: wrap; /* Ensure responsiveness */

            gap: 20px; /* Space between elements */

        }

        h1 {

            color: #2c3e50;

            text-align: center;

            margin-bottom: 30px;

            width: 100%; /* Ensure full width for heading */

        }

        .back-button {

            position: absolute;

            top: 20px;

            left: 20px;

            background-color: #3498db;

            color: white;

            border: none;

            padding: 10px 15px;

            border-radius: 50px;

            cursor: pointer;

            transition: all 0.3s ease;

            box-shadow: 0 2px 5px rgba(0,0,0,0.2);

            display: flex;

            align-items: center;

            font-weight: bold;

        }

        .back-button:hover {

            background-color: #2980b9;

            transform: translateY(-2px);

            box-shadow: 0 4px 8px rgba(0,0,0,0.3);

        }

        .back-button i {

            margin-right: 8px;

            transition: transform 0.3s ease;

        }

        .back-button:hover i {

            transform: rotate(-360deg);

        }

        .back-button span {

            opacity: 0;

            width: 0;

            overflow: hidden;

            transition: all 0.3s ease;

        }

        .back-button:hover span {

            opacity: 1;

            width: auto;

            margin-left: 5px;

        }

        .project-form,

        .chat-container {

            flex: 1;

            background-color: #ecf0f1;

            padding: 20px;

            border-radius: 8px;

            box-shadow: 0 0 10px rgba(0,0,0,0.1);

        }

        .project-form {

            margin-bottom: 20px; /* Remove if not needed */

        }

        .form-group {

            margin-bottom: 15px;

        }

        .form-group label {

            display: block;

            margin-bottom: 5px;

            color: #2c3e50;

            font-weight: bold;

        }

        .form-group input, .form-group textarea {

            width: calc(100% - 22px);

            padding: 10px;

            border: 1px solid #bdc3c7;

            border-radius: 4px;

            font-size: 16px;

            box-sizing: border-box;

        }

        .form-group textarea {

            height: 100px;

            resize: vertical;

        }

        button {

            background-color: #2ecc71;

            color: white;

            border: none;

            padding: 10px 20px;

            border-radius: 5px;

            cursor: pointer;

            transition: background-color 0.3s;

            font-size: 16px;

        }

        button:hover {

            background-color: #27ae60;

        }

        .chat-container {

            background-color: #ffffff;

            border-radius: 8px;

            overflow: hidden;

            box-shadow: 0 0 10px rgba(0,0,0,0.1);

        }

        .chat-messages {

            height: 300px;

            overflow-y: auto;

            padding: 20px;

        }

        .message {

            margin-bottom: 15px;

            padding: 10px;

            border-radius: 5px;

            max-width: 80%;

        }

        .user-message {

            background-color: #3498db;

            color: white;

            align-self: flex-end;

            margin-left: auto;

        }

        .ai-message {

            background-color: #ecf0f1;

            color: #333;

        }

        .chat-input {

            display: flex;

            padding: 10px;

            background-color: #ecf0f1;

        }

        .chat-input input {

            flex-grow: 1;

            padding: 10px;

            border: 1px solid #bdc3c7;

            border-radius: 4px;

            margin-right: 10px;

        }

        .fade-in {

            animation: fadeIn 0.5s;

        }

        @keyframes fadeIn {

            from { opacity: 0; }

            to { opacity: 1; }

        }

    </style>
</head>
<body>
    <video autoplay muted loop id="myVideo">
        <source src="../static/AI_video.mp4" type="video/mp4">
        Your browser does not support HTML5 video.
    </video>

    <div class="container">
        <button class="back-button" onclick="goBack()">
            <i class="fas fa-arrow-left"></i>
            <span>Back</span>
        </button>
        <h1><i class="fas fa-lightbulb"></i> Project Idea Generator</h1>
        <div class="project-form">
            <div class="form-group">
                <label for="subject"><i class="fas fa-book"></i> Subject:</label>
                <input type="text" id="subject" placeholder="e.g., Computer Science, Biology, Art">
            </div>
            <div class="form-group">
                <label for="topic"><i class="fas fa-tag"></i> Specific Topic:</label>
                <input type="text" id="topic" placeholder="e.g., Machine Learning, Genetics, Modern Art">
            </div>
            <div class="form-group">
                <label for="plan"><i class="fas fa-tasks"></i> Brief Project Plan:</label>
                <textarea id="plan" placeholder="Outline your initial thoughts or requirements for the project"></textarea>
            </div>
            <button onclick="generateProjectIdea()"><i class="fas fa-magic"></i> Generate Project Idea</button>
        </div>
        <div class="chat-container">
            <div id="chat-messages" class="chat-messages"></div>
            <div class="chat-input">
                <input type="text" id="user-input" placeholder="Ask follow-up questions about the project idea...">
                <button onclick="sendMessage()"><i class="fas fa-paper-plane"></i> Send</button>
            </div>
        </div>
    </div>

    <script>

        const chatMessages = document.getElementById('chat-messages');

        const userInput = document.getElementById('user-input');

        let currentProjectIdea = '';



        function addMessage(content, isUser) {

            const messageDiv = document.createElement('div');

            messageDiv.className = `message ${isUser ? 'user-message' : 'ai-message'} fade-in`;

            messageDiv.innerHTML = content.replace(/\n/g, '<br>');

            chatMessages.appendChild(messageDiv);

            chatMessages.scrollTop = chatMessages.scrollHeight;

        }



        function generateProjectIdea() {

            const subject = document.getElementById('subject').value;

            const topic = document.getElementById('topic').value;

            const plan = document.getElementById('plan').value;



            addMessage(`Generating project idea for ${subject} - ${topic}`, true);



            fetch('/generate_project_idea', {

                method: 'POST',

                headers: {

                    'Content-Type': 'application/json'

                },

                body: JSON.stringify({ subject, topic, plan })

            })

            .then(response => response.json())

            .then(data => {

                currentProjectIdea = data.project_idea;

                addMessage(currentProjectIdea, false);

            })

            .catch(error => {

                console.error('Error:', error);

            });

        }



        function sendMessage() {

            const message = userInput.value.trim();

            if (message) {

                addMessage(message, true);

                userInput.value = '';

                fetch('/ask_followup', {

                    method: 'POST',

                    headers: {

                        'Content-Type': 'application/json'

                    },

                    body: JSON.stringify({ project_idea: currentProjectIdea, query: message })

                })

                .then(response => response.json())

                .then(data => {

                    addMessage(data.response, false);

                })

                .catch(error => {

                    console.error('Error:', error);

                });

            }

        }



        userInput.addEventListener('keypress', function(e) {

            if ( e.key === 'Enter') {

                sendMessage();

            }

        });



        addMessage("Welcome! Use the form above to generate a project idea, then feel free to ask follow-up questions.", false);

        

        function goBack() {

            window.history.back();

        }

    </script>
</body>
</html>