@ -64,69 +64,109 @@
< / div >
< / div >
< script >
< script >
// Wait for DOM to be ready
console.log('Script loading...');
document.addEventListener('DOMContentLoaded', function() {
console.log('DOM loaded, initializing test functions...');
// Use global Capacitor and plugin objects instead of ES modules
// Mock DailyNotification plugin for WebView testing
// These are provided by the Capacitor runtime
if (!window.DailyNotification) {
const Capacitor = window.Capacitor;
console.log('Creating mock DailyNotification plugin...');
const DailyNotification = window.DailyNotification;
window.DailyNotification = {
echo: function(options) {
// Define global functions
return Promise.resolve({ value: `Mock echo: ${options.value}` });
window.testPlugin = async function() {
},
const status = document.getElementById('status');
configure: function(config) {
status.innerHTML = 'Testing plugin...';
console.log('Mock configure called with:', config);
return Promise.resolve();
try {
},
if (!DailyNotification) {
getStatus: function() {
status.innerHTML = 'DailyNotification plugin not available';
return Promise.resolve({
return;
configured: true,
}
platform: 'web-mock',
const result = await DailyNotification.echo({ value: 'Hello from test app!' });
lastFetch: new Date().toISOString()
status.innerHTML = `Plugin test successful: ${result.value}`;
});
} catch (error) {
status.innerHTML = `Plugin test failed: ${error.message}`;
}
}
};
};
}
window.configurePlugin = async function() {
// Define functions immediately and attach to window
const status = document.getElementById('status');
function testPlugin() {
status.innerHTML = 'Configuring plugin...';
console.log('testPlugin called');
const status = document.getElementById('status');
status.innerHTML = 'Testing plugin...';
try {
try {
if (!DailyNotification) {
if (!window.DailyNotification) {
status.innerHTML = 'DailyNotification plugin not available';
status.innerHTML = 'DailyNotification plugin not available';
return;
return;
}
}
await DailyNotification.configure({
window.DailyNotification.echo({ value: 'Hello from test app!' })
fetchUrl: 'https://api.example.com/daily-content',
.then(result => {
scheduleTime: '09:00',
status.innerHTML = `Plugin test successful: ${result.value}`;
enableNotifications: true
})
.catch(error => {
status.innerHTML = `Plugin test failed: ${error.message}`;
});
});
} catch (error) {
status.innerHTML = `Plugin test failed: ${error.message}`;
}
}
function configurePlugin() {
console.log('configurePlugin called');
const status = document.getElementById('status');
status.innerHTML = 'Configuring plugin...';
try {
if (!window.DailyNotification) {
status.innerHTML = 'DailyNotification plugin not available';
return;
}
window.DailyNotification.configure({
fetchUrl: 'https://api.example.com/daily-content',
scheduleTime: '09:00',
enableNotifications: true
})
.then(() => {
status.innerHTML = 'Plugin configured successfully!';
status.innerHTML = 'Plugin configured successfully!';
} catch (error) {
})
.catch(error => {
status.innerHTML = `Configuration failed: ${error.message}`;
status.innerHTML = `Configuration failed: ${error.message}`;
}
});
};
} catch (error) {
status.innerHTML = `Configuration failed: ${error.message}`;
}
}
window.checkStatus = async function() {
function checkStatus() {
const status = document.getElementById('status');
console.log('checkStatus called');
status.innerHTML = 'Checking plugin status...';
const status = document.getElementById('status');
status.innerHTML = 'Checking plugin status...';
try {
try {
if (!DailyNotification) {
if (!window.DailyNotification) {
status.innerHTML = 'DailyNotification plugin not available';
status.innerHTML = 'DailyNotification plugin not available';
return;
return;
}
const result = await DailyNotification.getStatus();
status.innerHTML = `Plugin status: ${JSON.stringify(result, null, 2)}`;
} catch (error) {
status.innerHTML = `Status check failed: ${error.message}`;
}
}
};
window.DailyNotification.getStatus()
.then(result => {
status.innerHTML = `Plugin status: ${JSON.stringify(result, null, 2)}`;
})
.catch(error => {
status.innerHTML = `Status check failed: ${error.message}`;
});
} catch (error) {
status.innerHTML = `Status check failed: ${error.message}`;
}
}
// Attach to window object
window.testPlugin = testPlugin;
window.configurePlugin = configurePlugin;
window.checkStatus = checkStatus;
console.log('Test functions initialized');
console.log('Functions attached to window:', {
testPlugin: typeof window.testPlugin,
configurePlugin: typeof window.configurePlugin,
checkStatus: typeof window.checkStatus
});
});
< / script >
< / script >
< / body >
< / body >