-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
493 lines (422 loc) · 17.5 KB
/
index.html
File metadata and controls
493 lines (422 loc) · 17.5 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Osho Dhara - Open Playlist</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
padding: 20px;
}
.container {
max-width: 400px;
width: 100%;
padding: 40px 30px;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20px;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.app-icon {
width: 80px;
height: 80px;
background: #007AFF;
border-radius: 18px;
margin: 0 auto 20px;
display: flex;
align-items: center;
justify-content: center;
font-size: 36px;
box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4);
}
h1 {
font-size: 28px;
font-weight: 700;
margin-bottom: 10px;
}
.playlist-info {
background: rgba(255, 255, 255, 0.1);
padding: 20px;
border-radius: 12px;
margin: 20px 0;
}
.playlist-name {
font-size: 20px;
font-weight: 600;
margin-bottom: 8px;
}
.track-count {
font-size: 16px;
opacity: 0.8;
}
.buttons {
display: flex;
flex-direction: column;
gap: 12px;
margin-top: 30px;
}
.btn {
padding: 16px 24px;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
text-decoration: none;
display: inline-block;
transition: all 0.3s ease;
}
.btn-primary {
background: #007AFF;
color: white;
}
.btn-primary:hover {
background: #0056CC;
transform: translateY(-2px);
}
.btn-secondary {
background: rgba(255, 255, 255, 0.2);
color: white;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateY(-2px);
}
.status {
margin-top: 20px;
padding: 12px;
border-radius: 8px;
font-size: 14px;
}
.status.loading {
background: rgba(255, 193, 7, 0.2);
color: #FFC107;
}
.status.success {
background: rgba(40, 167, 69, 0.2);
color: #28A745;
}
.status.error {
background: rgba(220, 53, 69, 0.2);
color: #DC3545;
}
.footer {
margin-top: 30px;
font-size: 12px;
opacity: 0.6;
}
@media (max-width: 480px) {
.container {
margin: 10px;
padding: 30px 20px;
}
h1 {
font-size: 24px;
}
.playlist-name {
font-size: 18px;
}
}
.debug-info {
margin-top: 20px;
padding: 12px;
background: rgba(0, 0, 0, 0.3);
border-radius: 8px;
font-size: 12px;
font-family: monospace;
text-align: left;
display: none;
}
.debug-toggle {
margin-top: 10px;
font-size: 12px;
color: rgba(255, 255, 255, 0.5);
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<div class="app-icon">🎵</div>
<h1>Osho Dhara</h1>
<div class="playlist-info">
<div class="playlist-name" id="playlistName">Loading playlist...</div>
<div class="track-count" id="trackCount"></div>
</div>
<div class="buttons">
<a href="#" class="btn btn-primary" id="downloadBtn">
⬇️ Download App from App Store
</a>
<button class="btn btn-secondary" id="haveAppBtn">
🔄 Try Opening App Again
</button>
<button class="btn btn-secondary" id="copyLinkBtn">
📋 Copy Link
</button>
</div>
<div class="status" id="status" style="display: none;">
<!-- Status will be shown when needed -->
</div>
<div class="debug-toggle" onclick="toggleDebug()">
🔧 Show Debug Info
</div>
<div class="debug-info" id="debugInfo">
<!-- Debug info will be populated by JavaScript -->
</div>
<div class="footer">
Share beautiful Osho discourses with friends
</div>
</div>
<script>
// Debug logging helper
let debugLogs = [];
function debugLog(message) {
const timestamp = new Date().toLocaleTimeString();
const logEntry = `[${timestamp}] ${message}`;
debugLogs.push(logEntry);
console.log('🔧 ' + logEntry);
updateDebugDisplay();
}
function updateDebugDisplay() {
const debugElement = document.getElementById('debugInfo');
debugElement.innerHTML = debugLogs.slice(-10).join('<br>'); // Show last 10 logs
}
function toggleDebug() {
const debugElement = document.getElementById('debugInfo');
const toggle = document.querySelector('.debug-toggle');
if (debugElement.style.display === 'none' || !debugElement.style.display) {
debugElement.style.display = 'block';
toggle.textContent = '🔧 Hide Debug Info';
} else {
debugElement.style.display = 'none';
toggle.textContent = '🔧 Show Debug Info';
}
}
// Parse URL parameters
const urlParams = new URLSearchParams(window.location.search);
const linkType = urlParams.get('type') || 'group'; // 'group', 'file', or 'audio'
const playlistName = urlParams.get('name') || 'Playlist';
const trackCount = urlParams.get('tracks') || '0';
const groupId = urlParams.get('id') || '';
const seriesId = urlParams.get('seriesId') || '';
const audioNumber = urlParams.get('audio') || '';
debugLog(`URL Parameters: type=${linkType}, name=${playlistName}, tracks=${trackCount}, id=${groupId}, seriesId=${seriesId}, audio=${audioNumber}`);
// Build deep link URL - try multiple formats
let deepLinkFormats = [];
if (linkType === 'audio') {
// Audio link (series ID + audio number)
debugLog('✅ Detected audio type link');
if (seriesId && audioNumber) {
document.getElementById('playlistName').textContent = 'Audio Track';
document.getElementById('trackCount').textContent = `Series: ${seriesId}, Track: ${audioNumber}`;
// Build audio deep link URL
deepLinkFormats = [
`oshoaudio://open/audio?seriesId=${encodeURIComponent(seriesId)}&audio=${encodeURIComponent(audioNumber)}`
];
debugLog(`Generated audio deep link: ${deepLinkFormats[0]}`);
} else {
debugLog('❌ Missing seriesId or audioNumber for audio link');
showStatus('Invalid audio link - missing required parameters', 'error');
showManualOptions();
}
} else {
// Group link (original logic)
document.getElementById('playlistName').textContent = decodeURIComponent(playlistName);
document.getElementById('trackCount').textContent = `${trackCount} audio tracks`;
// Build deep link URL - try multiple formats
deepLinkFormats = [
`oshoaudio://open/group?name=${encodeURIComponent(playlistName)}&tracks=${trackCount}${groupId ? `&id=${encodeURIComponent(groupId)}` : ''}`,
`oshoaudio://group?name=${encodeURIComponent(playlistName)}&tracks=${trackCount}${groupId ? `&id=${encodeURIComponent(groupId)}` : ''}`
];
debugLog(`Generated deep links: ${deepLinkFormats.join(', ')}`);
}
// App Store URL for Osho Dhara
const appStoreURL = 'https://apps.apple.com/app/id6738623487';
// Device detection
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
const isAndroid = /Android/.test(navigator.userAgent);
const isMobile = isIOS || isAndroid;
const isSafari = /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent);
debugLog(`Device: iOS=${isIOS}, Android=${isAndroid}, Mobile=${isMobile}, Safari=${isSafari}`);
debugLog(`User Agent: ${navigator.userAgent}`);
// Variables for app detection
let appInstalled = false;
let redirectAttempted = false;
let startTime = 0;
// Function to show status message
function showStatus(message, type = 'loading') {
const status = document.getElementById('status');
status.textContent = message;
status.className = `status ${type}`;
status.style.display = 'block';
debugLog(`Status: ${message} (${type})`);
}
// Function to hide manual options
function hideManualOptions() {
document.querySelector('.buttons').style.display = 'none';
}
// Function to show manual options
function showManualOptions() {
document.querySelector('.buttons').style.display = 'flex';
}
// Improved app detection using multiple methods
function attemptAppRedirect() {
if (redirectAttempted) {
debugLog('Redirect already attempted, skipping');
return;
}
if (deepLinkFormats.length === 0) {
debugLog('No deep link formats available');
showStatus('Invalid link format', 'error');
showManualOptions();
return;
}
redirectAttempted = true;
debugLog('Starting app redirect attempt');
showStatus('Opening your playlist...', 'loading');
hideManualOptions();
startTime = Date.now();
let currentFormatIndex = 0;
function tryNextFormat() {
if (currentFormatIndex >= deepLinkFormats.length) {
debugLog('All deep link formats failed, showing App Store');
showAppStore();
return;
}
const deepLinkURL = deepLinkFormats[currentFormatIndex];
debugLog(`Trying deep link format ${currentFormatIndex + 1}: ${deepLinkURL}`);
// Method 1: Direct window.location (most reliable on iOS)
const appDetectionTimeout = setTimeout(() => {
debugLog(`Format ${currentFormatIndex + 1} timeout - trying next format`);
currentFormatIndex++;
tryNextFormat();
}, 1500); // Shorter timeout for each attempt
// Set up visibility change listener
let visibilityChanged = false;
const visibilityHandler = () => {
if (document.hidden && !visibilityChanged) {
visibilityChanged = true;
clearTimeout(appDetectionTimeout);
debugLog('App opened successfully (visibility change detected)');
showStatus('Welcome to Osho Dhara! 🎵', 'success');
document.removeEventListener('visibilitychange', visibilityHandler);
}
};
document.addEventListener('visibilitychange', visibilityHandler);
// Check if page becomes hidden (app opened)
setTimeout(() => {
if (document.hidden && !visibilityChanged) {
visibilityChanged = true;
clearTimeout(appDetectionTimeout);
debugLog('App opened (page hidden after 800ms)');
showStatus('Enjoy your playlist! 🎵', 'success');
document.removeEventListener('visibilitychange', visibilityHandler);
}
}, 800);
// Attempt to open the app
try {
window.location.href = deepLinkURL;
} catch (error) {
debugLog(`Error opening deep link: ${error.message}`);
clearTimeout(appDetectionTimeout);
currentFormatIndex++;
tryNextFormat();
}
}
tryNextFormat();
}
function showAppStore() {
debugLog('Redirecting to App Store');
showStatus('App not found. Taking you to App Store...', 'loading');
showManualOptions();
setTimeout(() => {
try {
window.location.href = appStoreURL;
} catch (error) {
debugLog(`Error opening App Store: ${error.message}`);
showStatus('Please manually visit the App Store', 'error');
}
}, 2000);
}
// Event handlers
document.getElementById('downloadBtn').addEventListener('click', (e) => {
e.preventDefault();
debugLog('Manual download button clicked');
showAppStore();
});
document.getElementById('haveAppBtn').addEventListener('click', (e) => {
e.preventDefault();
debugLog('Manual "have app" button clicked');
redirectAttempted = false; // Reset to allow retry
attemptAppRedirect();
});
document.getElementById('copyLinkBtn').addEventListener('click', () => {
navigator.clipboard.writeText(window.location.href).then(() => {
const btn = document.getElementById('copyLinkBtn');
const originalText = btn.textContent;
btn.textContent = '✅ Copied!';
showStatus('Link copied! Share it with friends.', 'success');
debugLog('Link copied to clipboard');
setTimeout(() => {
btn.textContent = originalText;
document.getElementById('status').style.display = 'none';
}, 3000);
}).catch((error) => {
debugLog(`Clipboard error: ${error.message}`);
showStatus('Copy not supported. Long press the URL to copy manually.', 'error');
});
});
// Handle page load
window.addEventListener('load', () => {
debugLog('Page loaded');
if (!isMobile) {
debugLog('Desktop detected - showing manual options');
showStatus('Please open this link on your mobile device', 'error');
showManualOptions();
return;
}
if (!isIOS) {
debugLog('Non-iOS mobile detected - showing manual options');
showStatus('This app is only available for iPhone and iPad', 'error');
showManualOptions();
return;
}
debugLog('iOS device detected - starting auto redirect');
showStatus('Preparing to open your playlist...', 'loading');
// Auto-attempt for iOS users
setTimeout(() => {
attemptAppRedirect();
}, 1000); // Give user a moment to see the page
});
// Handle page visibility changes
document.addEventListener('visibilitychange', () => {
debugLog(`Visibility changed: hidden=${document.hidden}`);
});
// Handle focus events (additional app detection)
window.addEventListener('blur', () => {
if (startTime > 0 && Date.now() - startTime < 3000) {
debugLog('Window blur detected - app likely opened');
}
});
window.addEventListener('focus', () => {
debugLog('Window focus returned');
});
debugLog('Smart redirect system initialized');
</script>
</body>
</html>