first commit

This commit is contained in:
bolade
2025-11-05 01:03:10 +01:00
commit 5a802e7641
20 changed files with 6161 additions and 0 deletions
+606
View File
@@ -0,0 +1,606 @@
/* ===========================
CSS Reset & Variables
=========================== */
:root {
--primary-color: #667eea;
--primary-dark: #5568d3;
--secondary-color: #764ba2;
--success-color: #4caf50;
--error-color: #f44336;
--warning-color: #ffc107;
--text-primary: #333333;
--text-secondary: #666666;
--text-light: #999999;
--bg-light: #f9f9f9;
--bg-white: #ffffff;
--border-color: #e0e0e0;
--shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
--shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.2);
--transition: all 0.3s ease;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
background: linear-gradient(
135deg,
var(--primary-color) 0%,
var(--secondary-color) 100%
);
min-height: 100vh;
color: var(--text-primary);
line-height: 1.6;
}
/* ===========================
Navigation Bar
=========================== */
.navbar {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
box-shadow: var(--shadow-sm);
position: sticky;
top: 0;
z-index: 1000;
}
.nav-container {
max-width: 1200px;
margin: 0 auto;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-brand {
display: flex;
align-items: center;
gap: 0.5rem;
font-weight: 700;
font-size: 1.25rem;
color: var(--text-primary);
}
.nav-icon {
font-size: 1.5rem;
}
.nav-links {
display: flex;
gap: 2rem;
}
.nav-link {
color: var(--text-secondary);
text-decoration: none;
font-weight: 500;
transition: var(--transition);
}
.nav-link:hover {
color: var(--primary-color);
}
/* ===========================
Main Content
=========================== */
.main-content {
padding: 2rem 1rem;
min-height: calc(100vh - 200px);
}
/* ===========================
Hero Section
=========================== */
.hero {
text-align: center;
padding: 3rem 1rem;
margin-bottom: 2rem;
}
.hero-content {
max-width: 800px;
margin: 0 auto;
}
.hero-title {
font-size: 3rem;
font-weight: 800;
color: white;
margin-bottom: 1rem;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.hero-subtitle {
font-size: 1.25rem;
color: rgba(255, 255, 255, 0.95);
font-weight: 400;
}
/* ===========================
Container
=========================== */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 2rem;
}
/* ===========================
Examples Card
=========================== */
.examples-card {
background: rgba(255, 243, 205, 0.95);
border-left: 4px solid var(--warning-color);
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 2rem;
box-shadow: var(--shadow-sm);
}
.examples-title {
color: #856404;
margin-bottom: 1rem;
font-size: 1.1rem;
font-weight: 600;
}
.examples-list {
list-style: none;
}
.example-item {
padding: 0.75rem 1rem;
margin-bottom: 0.5rem;
background: rgba(255, 255, 255, 0.7);
border-radius: 8px;
color: #856404;
cursor: pointer;
transition: var(--transition);
border-left: 3px solid transparent;
}
.example-item:hover {
background: rgba(255, 255, 255, 0.9);
border-left-color: var(--warning-color);
transform: translateX(5px);
}
/* ===========================
Input Section
=========================== */
.input-section {
background: white;
border-radius: 16px;
padding: 2rem;
margin-bottom: 2rem;
box-shadow: var(--shadow-lg);
}
.input-label {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 1rem;
font-weight: 600;
font-size: 1.1rem;
color: var(--text-primary);
}
.label-icon {
font-size: 1.3rem;
}
.prompt-textarea {
width: 100%;
padding: 1rem;
border: 2px solid var(--border-color);
border-radius: 12px;
font-size: 1rem;
font-family: inherit;
resize: vertical;
transition: var(--transition);
margin-bottom: 1.5rem;
}
.prompt-textarea:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
/* ===========================
Buttons
=========================== */
.button-group {
display: flex;
gap: 1rem;
}
.btn {
flex: 1;
padding: 1rem 2rem;
font-size: 1rem;
font-weight: 600;
border: none;
border-radius: 12px;
cursor: pointer;
transition: var(--transition);
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
}
.btn-icon {
font-size: 1.2rem;
}
.btn-primary {
background: linear-gradient(
135deg,
var(--primary-color) 0%,
var(--secondary-color) 100%
);
color: white;
}
.btn-primary:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}
.btn-secondary {
background: var(--bg-light);
color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) {
background: var(--border-color);
}
.btn:disabled {
opacity: 0.6;
cursor: not-allowed;
}
/* ===========================
Loading Indicator
=========================== */
.loading {
display: none;
text-align: center;
padding: 3rem 2rem;
background: white;
border-radius: 16px;
margin-bottom: 2rem;
box-shadow: var(--shadow-md);
}
.loading.active {
display: block;
}
.spinner {
border: 4px solid var(--bg-light);
border-top: 4px solid var(--primary-color);
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite;
margin: 0 auto 1rem;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loading-text {
font-size: 1.2rem;
color: var(--primary-color);
font-weight: 600;
margin-bottom: 0.5rem;
}
.loading-subtext {
color: var(--text-secondary);
}
/* ===========================
Results Section
=========================== */
.results-section {
display: none;
}
.results-section.active {
display: block;
}
.result-card {
background: white;
border-radius: 16px;
padding: 2rem;
margin-bottom: 2rem;
box-shadow: var(--shadow-md);
}
.result-title {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 1.5rem;
font-size: 1.3rem;
color: var(--text-primary);
}
.result-icon {
font-size: 1.5rem;
}
.result-content {
background: var(--bg-light);
border-radius: 12px;
padding: 1.5rem;
}
.result-text {
white-space: pre-wrap;
word-wrap: break-word;
max-height: 400px;
overflow-y: auto;
color: var(--text-primary);
line-height: 1.8;
font-family: "Monaco", "Menlo", "Courier New", monospace;
font-size: 0.95rem;
}
/* ===========================
Action History
=========================== */
.action-history {
max-height: 300px;
overflow-y: auto;
}
.action-item {
padding: 1rem;
border-left: 3px solid var(--primary-color);
margin-bottom: 0.75rem;
background: white;
border-radius: 8px;
font-size: 0.9rem;
}
.action-item strong {
color: var(--primary-color);
text-transform: uppercase;
font-size: 0.85rem;
letter-spacing: 0.5px;
}
/* ===========================
Screenshot
=========================== */
.screenshot-container {
text-align: center;
}
.screenshot-container img {
width: 100%;
max-width: 100%;
border-radius: 12px;
box-shadow: var(--shadow-md);
transition: var(--transition);
}
.screenshot-container img:hover {
transform: scale(1.02);
box-shadow: var(--shadow-lg);
}
/* ===========================
Stats Section
=========================== */
.stats-section {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin-top: 2rem;
margin-bottom: 3rem;
}
.stat-card {
background: white;
border-radius: 16px;
padding: 2rem;
box-shadow: var(--shadow-md);
display: flex;
align-items: center;
gap: 1.5rem;
transition: var(--transition);
}
.stat-card:hover {
transform: translateY(-5px);
box-shadow: var(--shadow-lg);
}
.stat-icon {
font-size: 3rem;
background: linear-gradient(
135deg,
var(--primary-color),
var(--secondary-color)
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.stat-content {
flex: 1;
}
.stat-value {
font-size: 2rem;
font-weight: 700;
color: var(--text-primary);
line-height: 1;
margin-bottom: 0.25rem;
}
.stat-label {
color: var(--text-secondary);
font-size: 0.9rem;
font-weight: 500;
}
/* ===========================
Footer
=========================== */
.footer {
background: rgba(255, 255, 255, 0.95);
padding: 2rem 1rem;
text-align: center;
margin-top: 4rem;
}
.footer-container {
max-width: 1200px;
margin: 0 auto;
}
.footer p {
color: var(--text-secondary);
margin-bottom: 0.5rem;
}
.footer-links {
display: flex;
justify-content: center;
gap: 1rem;
flex-wrap: wrap;
}
.footer-links a {
color: var(--primary-color);
text-decoration: none;
font-weight: 500;
transition: var(--transition);
}
.footer-links a:hover {
color: var(--secondary-color);
}
/* ===========================
Scrollbar Styling
=========================== */
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
background: var(--bg-light);
border-radius: 5px;
}
::-webkit-scrollbar-thumb {
background: var(--primary-color);
border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--primary-dark);
}
/* ===========================
Responsive Design
=========================== */
@media (max-width: 768px) {
.hero-title {
font-size: 2rem;
}
.hero-subtitle {
font-size: 1rem;
}
.container {
padding: 0 1rem;
}
.nav-container {
flex-direction: column;
gap: 1rem;
}
.nav-links {
gap: 1rem;
}
.button-group {
flex-direction: column;
}
.stats-section {
grid-template-columns: 1fr;
}
.input-section,
.result-card {
padding: 1.5rem;
}
}
/* ===========================
Utility Classes
=========================== */
.success-icon {
color: var(--success-color);
}
.error-icon {
color: var(--error-color);
}
.hidden {
display: none !important;
}
.text-center {
text-align: center;
}
/* ===========================
Animations
=========================== */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.result-card {
animation: fadeIn 0.5s ease;
}
+421
View File
@@ -0,0 +1,421 @@
// ===========================
// State Management
// ===========================
let taskStats = {
total: 0,
successful: 0,
times: [],
};
// Load stats from localStorage
function loadStats() {
const savedStats = localStorage.getItem("taskStats");
if (savedStats) {
taskStats = JSON.parse(savedStats);
updateStatsDisplay();
}
}
// Save stats to localStorage
function saveStats() {
localStorage.setItem("taskStats", JSON.stringify(taskStats));
}
// Update stats display
function updateStatsDisplay() {
document.getElementById("total-tasks").textContent = taskStats.total;
document.getElementById("successful-tasks").textContent =
taskStats.successful;
if (taskStats.times.length > 0) {
const avgTime =
taskStats.times.reduce((a, b) => a + b, 0) / taskStats.times.length;
document.getElementById("avg-time").textContent =
avgTime.toFixed(1) + "s";
}
}
// ===========================
// Main Functions
// ===========================
// Fill prompt textarea with example
function fillPrompt(text) {
document.getElementById("prompt").value = text.trim();
document.getElementById("prompt").focus();
}
// Execute browser automation task
async function executeTask() {
const prompt = document.getElementById("prompt").value.trim();
if (!prompt) {
showNotification("Please enter a task prompt", "error");
return;
}
// Show loading, hide results
showLoading(true);
hideResults();
disableButtons(true);
const startTime = Date.now();
try {
const response = await fetch("/execute", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ prompt }),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
// Update stats
taskStats.total++;
if (data.success) {
taskStats.successful++;
}
taskStats.times.push(parseFloat(duration));
saveStats();
updateStatsDisplay();
// Hide loading
showLoading(false);
disableButtons(false);
// Display results
displayResults(data, duration);
// Show notification
if (data.success) {
showNotification("Task completed successfully!", "success");
} else {
showNotification(
"Task failed. Check the output for details.",
"error"
);
}
} catch (error) {
console.error("Error:", error);
showLoading(false);
disableButtons(false);
displayError(error.message);
showNotification("Failed to execute task", "error");
}
}
// Display results
function displayResults(data, duration) {
const resultsSection = document.getElementById("results");
resultsSection.classList.add("active");
// Result title and output
const resultIcon = document.getElementById("result-icon");
const resultTitleText = document.getElementById("result-title-text");
const resultOutput = document.getElementById("result-output");
if (data.success) {
resultIcon.textContent = "✅";
resultIcon.className = "result-icon success-icon";
resultTitleText.textContent = "Success";
resultOutput.textContent =
data.output || "Task completed successfully!";
} else {
resultIcon.textContent = "❌";
resultIcon.className = "result-icon error-icon";
resultTitleText.textContent = "Error";
resultOutput.textContent = data.error || "An unknown error occurred";
}
// Action history
const actionHistoryBox = document.getElementById("action-history-box");
const actionHistory = document.getElementById("action-history");
if (data.action_history && data.action_history.length > 0) {
actionHistoryBox.style.display = "block";
const historyHtml = data.action_history
.map((action, index) => {
const actionDetails = Object.entries(action)
.filter(([key]) => key !== "action")
.map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
.join(", ");
return `
<div class="action-item">
<strong>${
index + 1
}. ${action.action.toUpperCase()}</strong>
${actionDetails ? "<br>" + actionDetails : ""}
</div>
`;
})
.join("");
actionHistory.innerHTML = historyHtml;
} else {
actionHistoryBox.style.display = "none";
}
// Screenshot
const screenshotBox = document.getElementById("screenshot-box");
const screenshot = document.getElementById("screenshot");
if (data.screenshot) {
screenshotBox.style.display = "block";
screenshot.src = "data:image/png;base64," + data.screenshot;
} else {
screenshotBox.style.display = "none";
}
// Scroll to results
setTimeout(() => {
resultsSection.scrollIntoView({ behavior: "smooth", block: "start" });
}, 100);
}
// Display error
function displayError(errorMessage) {
const resultsSection = document.getElementById("results");
resultsSection.classList.add("active");
const resultIcon = document.getElementById("result-icon");
const resultTitleText = document.getElementById("result-title-text");
const resultOutput = document.getElementById("result-output");
resultIcon.textContent = "❌";
resultIcon.className = "result-icon error-icon";
resultTitleText.textContent = "Error";
resultOutput.textContent = `Failed to communicate with server:\n${errorMessage}`;
// Hide action history and screenshot
document.getElementById("action-history-box").style.display = "none";
document.getElementById("screenshot-box").style.display = "none";
}
// Clear results
function clearResults() {
document.getElementById("prompt").value = "";
document.getElementById("results").classList.remove("active");
document.getElementById("action-history-box").style.display = "none";
document.getElementById("screenshot-box").style.display = "none";
showNotification("Results cleared", "info");
}
// ===========================
// UI Helper Functions
// ===========================
// Show/hide loading indicator
function showLoading(show) {
const loading = document.getElementById("loading");
if (show) {
loading.classList.add("active");
} else {
loading.classList.remove("active");
}
}
// Hide results section
function hideResults() {
document.getElementById("results").classList.remove("active");
}
// Disable/enable buttons
function disableButtons(disabled) {
document.querySelectorAll(".btn").forEach((btn) => {
btn.disabled = disabled;
});
}
// Show notification (simple toast)
function showNotification(message, type = "info") {
// Check if notification container exists, create if not
let container = document.getElementById("notification-container");
if (!container) {
container = document.createElement("div");
container.id = "notification-container";
container.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
z-index: 10000;
`;
document.body.appendChild(container);
}
// Create notification element
const notification = document.createElement("div");
notification.className = `notification notification-${type}`;
const icon =
{
success: "✅",
error: "❌",
info: "️",
warning: "⚠️",
}[type] || "️";
const bgColor =
{
success: "#4caf50",
error: "#f44336",
info: "#2196f3",
warning: "#ff9800",
}[type] || "#2196f3";
notification.style.cssText = `
background: ${bgColor};
color: white;
padding: 1rem 1.5rem;
border-radius: 8px;
margin-bottom: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
display: flex;
align-items: center;
gap: 10px;
min-width: 300px;
animation: slideIn 0.3s ease;
`;
notification.innerHTML = `
<span style="font-size: 1.2rem;">${icon}</span>
<span style="flex: 1;">${message}</span>
`;
container.appendChild(notification);
// Auto remove after 3 seconds
setTimeout(() => {
notification.style.animation = "slideOut 0.3s ease";
setTimeout(() => {
notification.remove();
}, 300);
}, 3000);
}
// ===========================
// Event Listeners
// ===========================
// Initialize on page load
document.addEventListener("DOMContentLoaded", function () {
loadStats();
// Enter key to submit (Shift+Enter for new line)
document.getElementById("prompt").addEventListener("keydown", function (e) {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
executeTask();
}
});
// Add CSS for animations
if (!document.getElementById("notification-animations")) {
const style = document.createElement("style");
style.id = "notification-animations";
style.textContent = `
@keyframes slideIn {
from {
transform: translateX(400px);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
@keyframes slideOut {
from {
transform: translateX(0);
opacity: 1;
}
to {
transform: translateX(400px);
opacity: 0;
}
}
`;
document.head.appendChild(style);
}
});
// ===========================
// Utility Functions
// ===========================
// Format date/time
function formatDateTime(date) {
return new Date(date).toLocaleString();
}
// Copy text to clipboard
async function copyToClipboard(text) {
try {
await navigator.clipboard.writeText(text);
showNotification("Copied to clipboard!", "success");
} catch (err) {
showNotification("Failed to copy", "error");
}
}
// Download screenshot
function downloadScreenshot() {
const screenshot = document.getElementById("screenshot");
if (screenshot.src) {
const link = document.createElement("a");
link.href = screenshot.src;
link.download = `manus-ai-screenshot-${Date.now()}.png`;
link.click();
showNotification("Screenshot downloaded", "success");
}
}
// Export results as JSON
function exportResults() {
const resultOutput = document.getElementById("result-output").textContent;
const actionHistory = document.getElementById("action-history").innerHTML;
const data = {
timestamp: new Date().toISOString(),
output: resultOutput,
actionHistory: actionHistory,
stats: taskStats,
};
const blob = new Blob([JSON.stringify(data, null, 2)], {
type: "application/json",
});
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = `manus-ai-results-${Date.now()}.json`;
link.click();
URL.revokeObjectURL(url);
showNotification("Results exported", "success");
}
// Reset stats
function resetStats() {
if (confirm("Are you sure you want to reset all statistics?")) {
taskStats = {
total: 0,
successful: 0,
times: [],
};
saveStats();
updateStatsDisplay();
showNotification("Statistics reset", "info");
}
}