+ `;
+
+ proposalsContainer.appendChild(proposalCard);
+
+ // Add event listeners for vote buttons
+ const upvoteButton = proposalCard.querySelector('[data-vote-type="upvote"]');
+ const downvoteButton = proposalCard.querySelector('[data-vote-type="downvote"]');
+ const shareButton = proposalCard.querySelector('.share-button');
+
+ if (upvoteButton) {
+ upvoteButton.addEventListener('click', () => {
+ handleVote(proposal.id, 'upvote');
+ });
+ }
+
+ if (downvoteButton) {
+ downvoteButton.addEventListener('click', () => {
+ handleVote(proposal.id, 'downvote');
+ });
+ }
+
+ if (shareButton) {
+ shareButton.addEventListener('click', () => {
+ // Copy the shareable link to clipboard
+ copyToClipboard(getShareableLink(proposal.id));
+ });
+ }
+ });
+}
// Create meme upload elements
function createMemeUpload() {
@@ -1616,7 +1774,7 @@
const consentLabel = document.createElement('label');
consentLabel.setAttribute('for', 'petition-consent');
- consentLabel.innerHTML = 'I certify that I am an Australian citizen or eligible resident, registered to vote, and consent to my information being used for this official petition.';
+ consentLabel.innerHTML = 'I certify that I am an Australian citizen or eligible resident, registered to vote, and consent to my information being used for this official petition. I also certify that I am excited to join the radical party as a member and take back our sexy country.';
consentDiv.appendChild(consentCheckbox);
consentDiv.appendChild(consentLabel);
@@ -1760,6 +1918,38 @@
}
}
}
+
+ async function checkForProposalInUrl() {
+ const urlParams = new URLSearchParams(window.location.search);
+ const proposalId = urlParams.get('proposal');
+
+ if (proposalId) {
+ try {
+ // Show loading state
+ showToastMessage('Loading petition...', '#11cc77');
+
+ // Fetch the specific proposal
+ const response = await fetch(`${API_BASE_URL}/proposals?userId=${currentUser.id}`);
+
+ if (!response.ok) {
+ throw new Error('Failed to fetch proposal');
+ }
+
+ const proposals = await response.json();
+ const targetProposal = proposals.find(p => p.id === proposalId);
+
+ if (targetProposal) {
+ // Create and show the modal with the proposal data
+ createProposalViewModal(targetProposal);
+ } else {
+ showToastMessage('⚠️ Petition not found', '#ff0099');
+ }
+ } catch (error) {
+ console.error('Error fetching proposal:', error);
+ showToastMessage('⚠️ Failed to load petition', '#ff0099');
+ }
+ }
+}