File size: 5,225 Bytes
d0f4bc4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Expression Editor | iPortal</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <link rel="apple-touch-icon" href="/static/favicon.ico">
</head>
<body class="bg-gray-100 min-h-screen">
    <custom-navbar></custom-navbar>
    
    <main class="container mx-auto px-4 py-8">
        <div class="bg-white rounded-xl shadow-lg overflow-hidden p-6">
            <h2 class="text-2xl font-bold text-gray-800 mb-6 flex items-center">
                <i data-feather="edit-2" class="mr-3 text-indigo-500"></i> Expression Editor
            </h2>
            
            <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                <div>
                    <div class="mb-4">
                        <label class="block text-gray-700 font-medium mb-2">Expression Input</label>
                        <textarea id="expression-input" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" rows="8" placeholder="Enter your expression here..."></textarea>
                    </div>
                    
                    <div class="flex gap-3">
                        <button id="evaluate-btn" class="btn-tap bg-indigo-500 hover:bg-indigo-600 text-white px-4 py-2 rounded-lg flex items-center">
                            <i data-feather="play" class="mr-2"></i> Evaluate
                        </button>
                        <button id="clear-btn" class="btn-tap bg-gray-500 hover:bg-gray-600 text-white px-4 py-2 rounded-lg flex items-center">
                            <i data-feather="trash-2" class="mr-2"></i> Clear
                        </button>
                    </div>
                </div>
                
                <div>
                    <label class="block text-gray-700 font-medium mb-2">Result</label>
                    <div id="result-container" class="w-full p-3 border border-gray-300 rounded-lg bg-gray-50 min-h-[200px]">
                        <p class="text-gray-500">Results will appear here...</p>
                    </div>
                    
                    <div class="mt-4">
                        <label class="block text-gray-700 font-medium mb-2">Variables</label>
                        <div id="variables-container" class="grid grid-cols-2 gap-3">
                            <input type="text" placeholder="Variable" class="p-2 border rounded">
                            <input type="text" placeholder="Value" class="p-2 border rounded">
                        </div>
                        <button id="add-variable-btn" class="btn-tap mt-2 bg-gray-200 hover:bg-gray-300 text-gray-700 px-3 py-1 rounded text-sm flex items-center">
                            <i data-feather="plus" class="mr-1 w-4 h-4"></i> Add Variable
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <custom-footer></custom-footer>

    <script src="components/navbar.js"></script>
    <script src="components/footer.js"></script>
    <script src="script.js"></script>
    <script>
        feather.replace();
        
        document.getElementById('evaluate-btn').addEventListener('click', function() {
            const expression = document.getElementById('expression-input').value;
            try {
                const result = eval(expression);
                document.getElementById('result-container').innerHTML = `
                    <p class="text-green-600 font-medium">Success!</p>
                    <p class="text-gray-800 mt-2">${expression} = ${result}</p>
                `;
            } catch (error) {
                document.getElementById('result-container').innerHTML = `
                    <p class="text-red-600 font-medium">Error!</p>
                    <p class="text-gray-800 mt-2">${error.message}</p>
                `;
            }
        });
        
        document.getElementById('clear-btn').addEventListener('click', function() {
            document.getElementById('expression-input').value = '';
            document.getElementById('result-container').innerHTML = '<p class="text-gray-500">Results will appear here...</p>';
        });
        
        document.getElementById('add-variable-btn').addEventListener('click', function() {
            const container = document.getElementById('variables-container');
            const newVar = document.createElement('div');
            newVar.className = 'col-span-2 grid grid-cols-2 gap-3';
            newVar.innerHTML = `
                <input type="text" placeholder="Variable" class="p-2 border rounded">
                <input type="text" placeholder="Value" class="p-2 border rounded">
            `;
            container.appendChild(newVar);
        });
    </script>
</body>
</html>