File size: 1,689 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
// iPad specific enhancements
document.addEventListener('DOMContentLoaded', function() {
    // Prevent zooming
    document.addEventListener('gesturestart', function(e) {
        e.preventDefault();
    });
    // Add touch feedback to all buttons
    const buttons = document.querySelectorAll('a, button');
    buttons.forEach(button => {
        button.classList.add('btn-tap');
    });

    // Safe evaluation function for expression editor
    function safeEval(expression, variables = {}) {
        try {
            // Create safe context
            const safeContext = {
                Math: Math,
                Number: Number,
                Date: Date,
                Array: Array,
                Object: Object,
                String: String,
                Boolean: Boolean,
                RegExp: RegExp,
                JSON: JSON,
                console: console,
                ...variables
            };
            
            // Return evaluated expression
            return Function('"use strict";return (' + expression + ')').call(safeContext);
        } catch (e) {
            throw e;
        }
    }
// Handle orientation changes
    window.addEventListener('orientationchange', function() {
        console.log('Orientation changed to ' + window.orientation);
    });
});

// Service Worker registration for PWA
if ('serviceWorker' in navigator) {
    window.addEventListener('load', () => {
        navigator.serviceWorker.register('/sw.js').then(registration => {
            console.log('ServiceWorker registration successful');
        }).catch(err => {
            console.log('ServiceWorker registration failed: ', err);
        });
    });
}