-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.html
More file actions
73 lines (64 loc) · 2.32 KB
/
Copy pathcheckout.html
File metadata and controls
73 lines (64 loc) · 2.32 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
---
title: Checkout
layout: page
class: header--dark
permalink: /checkout/
### Hero
hero:
class: hero--rightthanks
subheading: 'Checkout'
image: hero/download.webp
---
{%- include hero.liquid -%}
<section class="thanks" id="checkout-result">
<div id="checkout-content">
<p class="thanks__title--small">Loading...</p>
</div>
</section>
<script>
(function() {
// Parse hash: #/drive/{name}/?success={action}
// Example: #/drive/MyZone/?success=success or #/drive/MyZone/?success=cancel
function parseCheckoutHash() {
var hash = window.location.hash.slice(1) || '';
var pathMatch = hash.match(/\/drive\/([^/]+)/);
var name = pathMatch ? decodeURIComponent(pathMatch[1]) : '';
var searchStart = hash.indexOf('?');
var params = new URLSearchParams(searchStart >= 0 ? hash.slice(searchStart) : '');
var action = params.get('success') || 'cancel';
return { name: name, action: action };
}
function renderCheckoutContent() {
var data = parseCheckoutHash();
var container = document.getElementById('checkout-content');
if (!container) return;
if (data.action === 'success') {
var displayName = data.name || 'your Zone';
var buttonHtml = data.name
? '<br><a href="ddrive://checkout_done/' + encodeURIComponent(data.name) + '" class="btn btn-primary">Open Diode</a>'
: '';
container.innerHTML = '<h3 class="thanks__title">Your Zone "' + escapeHtml(displayName) + '" is now upgraded!</h3>' +
'<p class="thanks__title--small">Switch back to the Diode Collab application to check it out.</p>' +
buttonHtml;
} else {
container.innerHTML = '<h3 class="thanks__title">Checkout cancelled</h3>' +
'<p class="thanks__title--small">The checkout was cancelled. Return to the Diode Collab app to retry.</p>';
}
}
function escapeHtml(text) {
var div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Update hero subheading based on action
function updateHeroSubheading() {
var data = parseCheckoutHash();
var subheading = document.querySelector('.hero__subheading');
if (subheading) {
subheading.textContent = data.action === 'success' ? 'Thank you for your purchase!' : 'Checkout cancelled';
}
}
renderCheckoutContent();
updateHeroSubheading();
})();
</script>