{"id":24,"date":"2024-07-25T11:35:31","date_gmt":"2024-07-25T11:35:31","guid":{"rendered":"https:\/\/posterity.indeginus.com\/?page_id=24"},"modified":"2024-07-27T19:07:38","modified_gmt":"2024-07-27T16:07:38","slug":"home","status":"publish","type":"page","link":"https:\/\/posterity.indeginus.com\/","title":{"rendered":"Home"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"24\" class=\"elementor elementor-24\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-59b5d32 e-con-full e-flex e-con e-parent\" data-id=\"59b5d32\" data-element_type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-a355844 elementor-widget elementor-widget-html\" data-id=\"a355844\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>#March2Parliament Support<\/title>\n    <link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.3.0-alpha1\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\">\n    <script src=\"https:\/\/challenges.cloudflare.com\/turnstile\/v0\/api.js\" async defer><\/script>\n    <style>\n        :root {\n            --primary-color: #62776B;\n            --text-color: #333333;\n            --secondary-text-color: #666666;\n        }\n\n        body {\n            font-family: 'Open Sans', sans-serif;\n            line-height: 1.6;\n            color: var(--text-color);\n            background-color: #f8f9fa;\n        }\n\n        .donation-container {\n            max-width: 600px;\n            background-color: #ffffff;\n            border-radius: 10px;\n            box-shadow: 0 0 10px rgba(0,0,0,0.1);\n            margin: 0 auto;\n            padding: 2rem;\n        }\n\n        h1 {\n            color: var(--primary-color);\n        }\n\n        .progress-stats {\n            font-size: 1.2rem;\n            font-weight: bold;\n            color: var(--primary-color);\n        }\n\n        .form-control {\n            border: none;\n            border-bottom: 1px solid #ced4da;\n            border-radius: 0;\n        }\n\n        .form-control:focus {\n            box-shadow: none;\n            border-color: var(--primary-color);\n        }\n\n        #toggle-form-button, #donate-button {\n            background-color: var(--primary-color);\n            border: none;\n        }\n\n        #toggle-form-button:hover, #donate-button:hover {\n            background-color: #556a5e;\n        }\n\n        .contributors {\n            font-size: 0.9rem;\n            color: var(--secondary-text-color);\n        }\n\n        .contributors a {\n            color: var(--primary-color);\n            text-decoration: none;\n        }\n\n        .contributors a:hover {\n            text-decoration: underline;\n        }\n\n        .collapsing {\n            position: relative;\n            height: 0;\n            overflow: hidden;\n            transition: height 0.35s ease;\n        }\n\n        .ticker {\n            overflow: hidden;\n            height: 1.5em;\n        }\n\n        .ticker-value {\n            display: inline-block;\n            transition: transform 0.5s ease-out;\n        }\n    <\/style>\n<\/head>\n<body>\n    <div class=\"container py-2\">\n        <div class=\"donation-container\">\n            <h1 class=\"text-center mb-3\">#March2Parliament Support<\/h1>\n            <p class=\"text-center mb-4\">The proceeds from this drive are going towards all those abducted and harmed by the authorities after the #March2Parliament peaceful protests.<\/p>\n\n            <div class=\"mb-4\">\n                <img decoding=\"async\" src=\"https:\/\/posterity.indeginus.com\/wp-content\/uploads\/2024\/07\/march2parliament-2.jpeg\" alt=\"#March2Parliament Banner\" class=\"img-fluid rounded\">\n            <\/div>\n\n            <div class=\"progress-stats d-flex justify-content-center mb-4\">\n                <div class=\"ticker\">\n                    <span class=\"ticker-value\" id=\"amount-raised\">UGX 0 Raised<\/span>\n                <\/div>\n            <\/div>\n\n            <div class=\"mb-4\">\n                <button id=\"toggle-form-button\" class=\"btn btn-primary w-100 py-2\">Donate<\/button>\n            <\/div>\n\n            <div id=\"donation-form-container\" style=\"display: none;\">\n                <form id=\"donation-form\">\n                    <div class=\"mb-3\">\n                        <label for=\"donation-amount\" class=\"form-label\">Amount (UGX)<\/label>\n                        <input type=\"number\" class=\"form-control\" id=\"donation-amount\" name=\"amount\" min=\"100\" required>\n                    <\/div>\n                    <div class=\"mb-3\">\n                        <label for=\"phone-number\" class=\"form-label\">Phone Number<\/label>\n                        <input type=\"tel\" class=\"form-control\" id=\"phone-number\" name=\"phone_number\" required>\n                    <\/div>\n                    <div class=\"mb-3\">\n                        <label for=\"email\" class=\"form-label\">Email<\/label>\n                        <input type=\"email\" class=\"form-control\" id=\"email\" name=\"email\" required>\n                    <\/div>\n                    <div class=\"cf-turnstile mb-3\" data-sitekey=\"0x4AAAAAAAf3msdfbzG0FCrr\"><\/div>\n                    <button type=\"button\" id=\"donate-button\" class=\"btn btn-primary w-100 py-2\" onclick=\"validateAndPay()\">Donate<\/button>\n                <\/form>\n            <\/div>\n\n            <div class=\"text-center mt-3\">\n                <small>\ud83d\udd12 Secured by Flutterwave<\/small>\n            <\/div>\n            <div class=\"contributors text-center mt-2\">\n                Coordinators: \n                <a href=\"https:\/\/twitter.com\/AgoraCFR\" target=\"_blank\">Agora Discourse<\/a> |\n                <a href=\"https:\/\/twitter.com\/NelsonSsenyange\" target=\"_blank\">Nelson Ssenyange<\/a> |\n                <a href=\"https:\/\/twitter.com\/Mutuzo_M\" target=\"_blank\">Misheline Mutuzo<\/a>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.3.0-alpha1\/dist\/js\/bootstrap.bundle.min.js\"><\/script>\n    <script src=\"https:\/\/checkout.flutterwave.com\/v3.js\"><\/script>\n    <script>\n        let totalAmount = 0; \/\/ Initial amount set to 0\n        let flutterwavePublicKey = '';\n\n        document.addEventListener('DOMContentLoaded', function() {\n            console.log('DOM fully loaded');\n            \n            \/\/ Fetch the Flutterwave public key\n            fetch('\/wp-content\/themes\/indeginus-elementor-theme\/get-flutterwave-key.php')\n                .then(response => response.json())\n                .then(data => {\n                    if (data.key) {\n                        flutterwavePublicKey = data.key;\n                        console.log('Flutterwave public key loaded');\n                    } else {\n                        console.error('Failed to load Flutterwave public key');\n                    }\n                })\n                .catch(error => console.error('Error loading Flutterwave key:', error));\n\n            const toggleFormButton = document.getElementById('toggle-form-button');\n            const formContainer = document.getElementById('donation-form-container');\n            \n            toggleFormButton.addEventListener('click', function() {\n                if (formContainer.style.display === 'none') {\n                    formContainer.style.display = 'block';\n                    toggleFormButton.textContent = 'Cancel';\n                    \/\/ Scroll to the form\n                    formContainer.scrollIntoView({ behavior: 'smooth' });\n                } else {\n                    formContainer.style.display = 'none';\n                    toggleFormButton.textContent = 'Donate';\n                }\n            });\n\n            \/\/ Display the initial amount raised as 0\n            document.getElementById('amount-raised').textContent = `UGX ${totalAmount.toLocaleString()} Raised`;\n\n            \/\/ Fetch the latest donation stats\n            fetchDonationStats();\n\n            \/\/ Set up interval for future updates\n            setInterval(fetchDonationStats, 30000); \/\/ Fetch every 30 seconds\n        });\n\n        function fetchDonationStats() {\n            console.log('Fetching donation stats...');\n            fetch(`\/wp-json\/march2parliament\/v1\/donation-stats?t=${Date.now()}`)\n                .then(response => {\n                    console.log('Response status:', response.status);\n                    console.log('Response headers:', response.headers);\n                    return response.text();\n                })\n                .then(text => {\n                    console.log('Raw response:', text);\n                    return JSON.parse(text);\n                })\n                .then(data => {\n                    console.log('Parsed donation stats:', data);\n                    if (data.totalAmount !== undefined) {\n                        updateProgress(data.totalAmount);\n                    } else {\n                        throw new Error('Invalid data format: totalAmount is undefined');\n                    }\n                })\n                .catch(error => {\n                    console.error('Error fetching donation stats:', error);\n                    document.getElementById('amount-raised').textContent = 'Error fetching data';\n                });\n        }\n\n        function updateProgress(newTotalAmount) {\n            console.log('Updating progress:', newTotalAmount, 'Current total:', totalAmount);\n            const amountRaisedElem = document.getElementById('amount-raised');\n            newTotalAmount = parseInt(newTotalAmount);\n            if (isNaN(newTotalAmount)) {\n                console.error('Invalid newTotalAmount:', newTotalAmount);\n                return;\n            }\n            if (newTotalAmount !== totalAmount) {\n                const oldValue = parseInt(totalAmount) || 0;\n                const newValue = newTotalAmount;\n\n                console.log('Animating from', oldValue, 'to', newValue);\n                animateValue(amountRaisedElem, oldValue, newValue, 1000);\n                totalAmount = newTotalAmount;\n            } else {\n                console.log('No change in total amount');\n                amountRaisedElem.textContent = `UGX ${totalAmount.toLocaleString()} Raised`;\n            }\n        }\n\n        function animateValue(obj, start, end, duration) {\n            console.log('Animating value from', start, 'to', end);\n            if (isNaN(start) || isNaN(end)) {\n                console.error('Invalid start or end value for animation');\n                obj.textContent = `UGX ${end.toLocaleString()} Raised`;\n                return;\n            }\n            let startTimestamp = null;\n            const step = (timestamp) => {\n                if (!startTimestamp) startTimestamp = timestamp;\n                const progress = Math.min((timestamp - startTimestamp) \/ duration, 1);\n                const currentValue = Math.floor(progress * (end - start) + start);\n                obj.textContent = `UGX ${currentValue.toLocaleString()} Raised`;\n                console.log('Current animated value:', currentValue);\n                if (progress < 1) {\n                    window.requestAnimationFrame(step);\n                } else {\n                    console.log('Animation completed');\n                }\n            };\n            window.requestAnimationFrame(step);\n        }\n\n        function validateAndPay() {\n            const turnstileResponse = document.querySelector('[name=\"cf-turnstile-response\"]').value;\n            const amount = parseFloat(document.getElementById('donation-amount').value);\n            const phoneNumber = document.getElementById('phone-number').value;\n            const email = document.getElementById('email').value;\n\n            if (!turnstileResponse) {\n                alert(\"Please complete the Cloudflare challenge.\");\n                return;\n            }\n\n            if (isNaN(amount) || amount <= 0) {\n                alert('Please enter a valid amount.');\n                return;\n            }\n\n            if (!phoneNumber || !email) {\n                alert('Please fill out all required fields.');\n                return;\n            }\n\n            makePayment(amount, phoneNumber, email);\n        }\n\n        function makePayment(amount, phoneNumber, email) {\n            FlutterwaveCheckout({\n                public_key: flutterwavePublicKey,\n                tx_ref: `FLW_${Date.now()}`,\n                amount: amount,\n                currency: 'UGX',\n                payment_options: 'mobilemoneyuganda',\n                redirect_url: \"https:\/\/posterity.indeginus.com\/index.php\/donation-result\/\",\n                customer: {\n                    email: email,\n                    phone_number: phoneNumber,\n                    name: \"Anonymous\",\n                },\n                customizations: {\n                    title: \"March2Parliament\",\n                    description: \"Donation to support Protesters\",\n                    logo: \"https:\/\/posterity.indeginus.com\/wp-content\/uploads\/2024\/07\/march2parliament-2.jpeg\",\n                },\n                callback: function (data) {\n                    console.log('Payment callback data:', data);\n                    if (data.status === 'successful') {\n                        alert('Payment successful!');\n                        updateProgress(totalAmount + parseInt(amount));\n                        fetchDonationStats();\n                    } else {\n                        alert('Payment failed.');\n                    }\n                },\n                onclose: function() {\n                    console.log('Payment modal closed');\n                }\n            });\n        }\n    <\/script>\n<\/body>\n<\/html>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>#March2Parliament Support #March2Parliament Support The proceeds from this drive are going towards all those abducted and harmed by the authorities after the #March2Parliament peaceful protests. UGX 0 Raised Donate Amount (UGX) Phone Number Email Donate \ud83d\udd12 Secured by Flutterwave Coordinators: Agora Discourse | Nelson Ssenyange | Misheline Mutuzo<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"elementor_canvas","meta":{"footnotes":""},"class_list":["post-24","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/posterity.indeginus.com\/index.php\/wp-json\/wp\/v2\/pages\/24","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/posterity.indeginus.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/posterity.indeginus.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/posterity.indeginus.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/posterity.indeginus.com\/index.php\/wp-json\/wp\/v2\/comments?post=24"}],"version-history":[{"count":145,"href":"https:\/\/posterity.indeginus.com\/index.php\/wp-json\/wp\/v2\/pages\/24\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/posterity.indeginus.com\/index.php\/wp-json\/wp\/v2\/pages\/24\/revisions\/226"}],"wp:attachment":[{"href":"https:\/\/posterity.indeginus.com\/index.php\/wp-json\/wp\/v2\/media?parent=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}