|
17 | 17 |
|
18 | 18 | <section id="donate"> |
19 | 19 | <h2>How can I donate?</h2> |
20 | | - <p>You can donate using our secure stripe donation button below. Please select your desired donation and click "Donate Now". But you're pretty smart and probably figured that out on your own didn't you?</p> |
| 20 | + <p>You can donate using our secure Stripe donation button below. Please enter your desired donation and click "Donate Now". But you're pretty smart and probably figured that out on your own didn't you?</p> |
21 | 21 |
|
22 | 22 | <script src="https://checkout.stripe.com/checkout.js"></script> |
23 | 23 |
|
24 | 24 | <div class="donate_form"> |
25 | | - <div class="dropdown_frame"> |
26 | | - <select id="donation_amount" class="dropdown"> |
27 | | - <option value="100">$1.00</option> |
28 | | - <option value="500">$5.00</option> |
29 | | - <option value="1000">$10.00</option> |
30 | | - <option value="1500">$15.00</option> |
31 | | - <option value="2000">$20.00</option> |
32 | | - <option value="5000">$50.00</option> |
33 | | - <option value="10000">$100.00</option> |
34 | | - </select> |
35 | | - </div> |
36 | | - <button id="donate_button" class="button">Donate Now</button> |
| 25 | + $ <input class="donateInput" id="donation_amount" type="number" min="1.00" step="1.00" value="5.00" /> |
| 26 | + <button id="donate_button" class="button">Donate Now</button><br><br> |
| 27 | + <textarea class="comment" rows="3" cols="60" id="comment" placeholder="Leave a comment"></textarea> |
37 | 28 | </div> |
38 | 29 |
|
39 | 30 | <script> |
40 | 31 | var handler = StripeCheckout.configure({ |
41 | 32 | key: '<%=stripePublishKey%>', |
42 | 33 | image: 'img/donate_small.png', |
43 | 34 | token: function(token, args) { |
44 | | - token.price = Number(document.getElementById('donation_amount').value); |
| 35 | + token.price = Number(donationAmt()); |
45 | 36 |
|
46 | 37 | $.ajax({ |
47 | 38 | type: 'POST', |
48 | 39 | url: '/donate', |
49 | | - data: { data: JSON.stringify(token) }, |
| 40 | + data: { data: JSON.stringify({token, comment: document.getElementById('comment').value}) }, |
50 | 41 | success: function(data) { |
51 | 42 | window.alert("Thanks for your donation!"); |
52 | 43 | }, |
|
61 | 52 | handler.open({ |
62 | 53 | name: 'Random User API', |
63 | 54 | description: 'Thanks for donating!', |
64 | | - amount: Number(document.getElementById('donation_amount').value) |
| 55 | + amount: Number(donationAmt()) |
65 | 56 | }); |
66 | 57 | e.preventDefault(); |
67 | 58 | }); |
| 59 | +
|
| 60 | + function donationAmt() { |
| 61 | + let input = document.getElementById('donation_amount'); |
| 62 | + let amt = input.value; |
| 63 | +
|
| 64 | + if (Number(amt) < 1) { |
| 65 | + input.value = "1.00"; |
| 66 | + return 100; |
| 67 | + } else if (amt.indexOf('.') === -1) { |
| 68 | + input.value = amt + ".00"; |
| 69 | + return Number(amt)*100; |
| 70 | + } else { |
| 71 | + input.value = Number(amt).toFixed(2); |
| 72 | + return Number((input.value*100).toFixed(0)); |
| 73 | + } |
| 74 | + } |
68 | 75 | </script> |
69 | 76 |
|
70 | 77 | <%//<p style="text-align: center;">Don't have your card details handy? <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QBRGZ79MNX9W6" target="_blank">Click here to donate via PayPal</a></p>%> |
|
74 | 81 |
|
75 | 82 | <section id="why"> |
76 | 83 | <h2>Why should I donate?</h2> |
77 | | - <p>The Random User Generator API is a 100% free service and is paid for out of our own pockets. <strong>We generate up to a million random users a day</strong>, and the bandwidth involved to deliver that information is costly. Random User Generator will never require a paid subscription to use our service, and we strive to continue providing this service free to you for life. Donating isn't required, but it will help us continue to improve and enhance our service.</p> |
| 84 | + <p>The Random User Generator API is a 100% free service and is paid for out of our own pockets. <strong>We generate up to <span id='gen'>1,000,000</span> random users everyday</strong>, and the servers involved to deliver that information is costly. Random User Generator will never require a paid subscription to use our service, and we strive to continue providing this service free to you for life. Donating isn't required, but it will help us continue to improve and enhance our service.</p> |
78 | 85 | </section> |
79 | 86 |
|
80 | 87 | <section class="advertisement"> |
81 | 88 | <h2>Advertising</h2> |
82 | | - <p>Alternatively, we also earn money from you clicking on the verious advertisements you see on the site. If you aren't seeing ads, it's most likely because you are running an adblock service. We don't blame you, we hate ads too! However it would help us out a lot of you disabled your adblock service for our website.</p> |
| 89 | + <p>Alternatively, we also earn money from you clicking on the various advertisements you see on the site. If you aren't seeing ads, it's most likely because you are running an adblock service. We don't blame you, we hate ads too! However it would help us out a lot of you disabled your adblock service for our website.</p> |
83 | 90 | <p>If not, that's cool too. We love you either way.</p> |
84 | 91 | </section> |
85 | 92 | <% include ../snippets/ads %> |
86 | 93 | </div> |
87 | 94 | <% include ../snippets/footer %> |
88 | 95 | <% include ../snippets/analytics %> |
| 96 | + <script> |
| 97 | + setInterval(() => { |
| 98 | + $.get("getStats", data => { |
| 99 | + document.getElementById('gen').innerHTML = data['30'].total; |
| 100 | + }); |
| 101 | + }, 1000); |
| 102 | + </script> |
89 | 103 | </body> |
90 | 104 | </html> |
0 commit comments