// 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); }); }); }