Compare commits
5 Commits
2026.01.24
...
2026.01.24
| Author | SHA1 | Date | |
|---|---|---|---|
| 03692608cc | |||
| b95d1dc461 | |||
| 59df695530 | |||
| 03b6e5d70f | |||
| f8919af31a |
@@ -7016,7 +7016,7 @@ class TWP_Admin {
|
||||
<div class="phone-interface">
|
||||
<div class="phone-display">
|
||||
<div id="phone-status">Ready</div>
|
||||
<div id="device-connection-status" style="font-size: 12px; color: #999; margin-top: 5px;">Connecting...</div>
|
||||
<div id="device-connection-status" style="font-size: 12px; color: #999; margin-top: 5px;">Loading...</div>
|
||||
<div id="phone-number-display"></div>
|
||||
<div id="call-timer" style="display: none;">00:00</div>
|
||||
</div>
|
||||
@@ -7445,6 +7445,11 @@ class TWP_Admin {
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Preload and preconnect for faster loading -->
|
||||
<link rel="preload" href="https://unpkg.com/@twilio/voice-sdk@2.11.0/dist/twilio.min.js" as="script">
|
||||
<link rel="dns-prefetch" href="//unpkg.com">
|
||||
<link rel="dns-prefetch" href="//chunderw-vpc-gll.twilio.com">
|
||||
<link rel="preconnect" href="https://chunderw-vpc-gll.twilio.com" crossorigin>
|
||||
<!-- Twilio Voice SDK v2 from unpkg CDN -->
|
||||
<script src="https://unpkg.com/@twilio/voice-sdk@2.11.0/dist/twilio.min.js"></script>
|
||||
<script>
|
||||
@@ -8233,16 +8238,40 @@ class TWP_Admin {
|
||||
});
|
||||
|
||||
// Check if SDK loaded and initialize
|
||||
// Poll for Twilio SDK availability (window.load may not fire on mobile)
|
||||
var sdkCheckAttempts = 0;
|
||||
var maxSdkCheckAttempts = 100; // 5 seconds max (100 * 50ms)
|
||||
|
||||
function checkAndInitialize() {
|
||||
sdkCheckAttempts++;
|
||||
|
||||
if (typeof Twilio !== 'undefined' && Twilio.Device) {
|
||||
console.log('Twilio SDK loaded successfully');
|
||||
initializeBrowserPhone();
|
||||
} else if (sdkCheckAttempts < maxSdkCheckAttempts) {
|
||||
// Keep checking every 50ms for faster response
|
||||
setTimeout(checkAndInitialize, 50);
|
||||
} else {
|
||||
showError('Twilio Voice SDK failed to load. Please check your internet connection and try refreshing the page.');
|
||||
console.error('Twilio SDK not found after ' + sdkCheckAttempts + ' attempts.');
|
||||
}
|
||||
}
|
||||
|
||||
// Check immediately - SDK script is synchronous so should be loaded
|
||||
// If not ready yet (mobile), polling will catch it
|
||||
if (typeof Twilio !== 'undefined' && Twilio.Device) {
|
||||
console.log('Twilio SDK already loaded');
|
||||
initializeBrowserPhone();
|
||||
} else {
|
||||
// Start polling immediately
|
||||
checkAndInitialize();
|
||||
}
|
||||
|
||||
// Also keep the window.load as backup for desktop
|
||||
$(window).on('load', function() {
|
||||
setTimeout(function() {
|
||||
if (typeof Twilio === 'undefined') {
|
||||
showError('Twilio Voice SDK failed to load. Please check your internet connection and try refreshing the page.');
|
||||
console.error('Twilio SDK not found. Script may be blocked or failed to load.');
|
||||
} else {
|
||||
console.log('Twilio SDK loaded successfully');
|
||||
initializeBrowserPhone();
|
||||
}
|
||||
}, 1000);
|
||||
if (typeof Twilio !== 'undefined' && !device) {
|
||||
initializeBrowserPhone();
|
||||
}
|
||||
});
|
||||
|
||||
// Clean up on page unload
|
||||
|
||||
@@ -101,8 +101,8 @@ if (!defined('TWILIO_AUTOLOADER_REGISTERED')) {
|
||||
}
|
||||
|
||||
// Convert class name to file path
|
||||
$relative_class = substr($class, 7); // Remove 'Twilio\'
|
||||
$file = __DIR__ . '/twilio/sdk/' . str_replace('\\', '/', $relative_class) . '.php';
|
||||
// The SDK structure is: twilio/sdk/Twilio/Rest/Client.php for Twilio\Rest\Client
|
||||
$file = __DIR__ . '/twilio/sdk/' . str_replace('\\', '/', $class) . '.php';
|
||||
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
@@ -120,10 +120,10 @@ if (!defined('TWILIO_AUTOLOADER_REGISTERED')) {
|
||||
|
||||
// Load essential Twilio classes manually to ensure they're available
|
||||
$essential_classes = [
|
||||
__DIR__ . '/twilio/sdk/Rest/Client.php',
|
||||
__DIR__ . '/twilio/sdk/TwiML/VoiceResponse.php',
|
||||
__DIR__ . '/twilio/sdk/Exceptions/TwilioException.php',
|
||||
__DIR__ . '/twilio/sdk/Security/RequestValidator.php'
|
||||
__DIR__ . '/twilio/sdk/Twilio/Rest/Client.php',
|
||||
__DIR__ . '/twilio/sdk/Twilio/TwiML/VoiceResponse.php',
|
||||
__DIR__ . '/twilio/sdk/Twilio/Exceptions/TwilioException.php',
|
||||
__DIR__ . '/twilio/sdk/Twilio/Security/RequestValidator.php'
|
||||
];
|
||||
|
||||
foreach ($essential_classes as $class_file) {
|
||||
|
||||
@@ -79,8 +79,8 @@ if (!defined('TWILIO_AUTOLOADER_REGISTERED')) {
|
||||
}
|
||||
|
||||
// Convert class name to file path
|
||||
$relative_class = substr($class, 7); // Remove 'Twilio\'
|
||||
$file = __DIR__ . '/twilio/sdk/' . str_replace('\\', '/', $relative_class) . '.php';
|
||||
// The SDK structure is: twilio/sdk/Twilio/Rest/Client.php for Twilio\Rest\Client
|
||||
$file = __DIR__ . '/twilio/sdk/' . str_replace('\\', '/', $class) . '.php';
|
||||
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
@@ -98,10 +98,10 @@ if (!defined('TWILIO_AUTOLOADER_REGISTERED')) {
|
||||
|
||||
// Load essential Twilio classes manually to ensure they're available
|
||||
$essential_classes = [
|
||||
__DIR__ . '/twilio/sdk/Rest/Client.php',
|
||||
__DIR__ . '/twilio/sdk/TwiML/VoiceResponse.php',
|
||||
__DIR__ . '/twilio/sdk/Exceptions/TwilioException.php',
|
||||
__DIR__ . '/twilio/sdk/Security/RequestValidator.php'
|
||||
__DIR__ . '/twilio/sdk/Twilio/Rest/Client.php',
|
||||
__DIR__ . '/twilio/sdk/Twilio/TwiML/VoiceResponse.php',
|
||||
__DIR__ . '/twilio/sdk/Twilio/Exceptions/TwilioException.php',
|
||||
__DIR__ . '/twilio/sdk/Twilio/Security/RequestValidator.php'
|
||||
];
|
||||
|
||||
foreach ($essential_classes as $class_file) {
|
||||
|
||||
Reference in New Issue
Block a user