mirror of
https://github.com/tavo-wasd-gh/conex-builder.git
synced 2025-06-07 12:13:30 -06:00
paypal 2nd try
This commit is contained in:
parent
233b7fe659
commit
989d105fba
4 changed files with 145 additions and 32 deletions
|
@ -1,43 +1,45 @@
|
|||
// Handle form submission after filling out the dialog
|
||||
function isFormValid() {
|
||||
const form = document.getElementById('mainForm');
|
||||
return form.checkValidity(); // Returns true if the form is valid
|
||||
}
|
||||
|
||||
document.getElementById('openDialogButton').addEventListener('click', () => {
|
||||
document.getElementById('overlay').style.display = 'block';
|
||||
document.getElementById('dialog').style.display = 'block';
|
||||
document.getElementById('openDialogButton').style.display = 'none';
|
||||
});
|
||||
|
||||
document.getElementById('submitDialogButton').addEventListener('click', () => {
|
||||
const form = document.getElementById('mainForm');
|
||||
const name = document.getElementById('name').value;
|
||||
const email = document.getElementById('email').value;
|
||||
const phone = document.getElementById('phone').value;
|
||||
|
||||
// Append additional fields to the form
|
||||
const nameInput = document.createElement('input');
|
||||
nameInput.type = 'hidden';
|
||||
nameInput.name = 'name';
|
||||
nameInput.value = name;
|
||||
form.appendChild(nameInput);
|
||||
['name', 'email', 'phone'].forEach(id => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = id;
|
||||
input.value = document.getElementById(id).value;
|
||||
form.appendChild(input);
|
||||
});
|
||||
|
||||
const emailInput = document.createElement('input');
|
||||
emailInput.type = 'hidden';
|
||||
emailInput.name = 'email';
|
||||
emailInput.value = email;
|
||||
form.appendChild(emailInput);
|
||||
if (isFormValid()) {
|
||||
document.getElementById('error-message').style.display = 'none';
|
||||
// renderPayPalButton();
|
||||
} else {
|
||||
document.getElementById('error-message').style.display = 'block';
|
||||
// removePayPalButton();
|
||||
}
|
||||
|
||||
const phoneInput = document.createElement('input');
|
||||
phoneInput.type = 'hidden';
|
||||
phoneInput.name = 'phone';
|
||||
phoneInput.value = phone;
|
||||
form.appendChild(phoneInput);
|
||||
|
||||
// Submit
|
||||
// const orderIDInput = document.createElement('input');
|
||||
// orderIDInput.type = 'hidden';
|
||||
// orderIDInput.name = 'paypalOrderID';
|
||||
// orderIDInput.value = paypalOrderID;
|
||||
// form.appendChild(orderIDInput);
|
||||
form.submit();
|
||||
});
|
||||
|
||||
// Cancel button
|
||||
document.getElementById('cancelDialogButton').addEventListener('click', () => {
|
||||
// Clear values
|
||||
document.getElementById('name').value = '';
|
||||
document.getElementById('email').value = '';
|
||||
document.getElementById('phone').value = '';
|
||||
// Hide dialog
|
||||
document.getElementById('overlay').style.display = 'none';
|
||||
document.getElementById('dialog').style.display = 'none';
|
||||
document.getElementById('openDialogButton').style.display = 'block';
|
||||
document.getElementById('submitDialogButton').style.display = 'inline';
|
||||
// removePayPalButton();
|
||||
});
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
<link rel="stylesheet" href="/static/css/simplemde.min.css">
|
||||
<link rel="stylesheet" href="/static/css/simplemde-dark.min.css">
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<script src="/static/js/simplemde.min.js"></script>
|
||||
<script src="https://www.paypal.com/sdk/js?client-id=test¤cy=USD"></script>
|
||||
</head>
|
||||
<form action="submit.php" method="post">
|
||||
<form action="submit.php" id="mainForm" method="post">
|
||||
<div class="banner" style="background-image: url(/static/banner.jpg);">
|
||||
<div class="desc">
|
||||
<input type="text" name="title" class="input-title" placeholder="[Nombre Ejemplo]">
|
||||
|
@ -28,17 +30,20 @@
|
|||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<div id="overlay"></div>
|
||||
<div id="dialog">
|
||||
<h2>Ingrese sus detalles</h2>
|
||||
<p>Utilizaremos esta información para contactarle acerca de la publicación del sitio.</p>
|
||||
<div id="error-message"><p>Por favor digite los campos requeridos.</p></div>
|
||||
<div id="error-with-payment"></div>
|
||||
<input type="text" id="name" name="name" placeholder="Nombre completo" required>
|
||||
<input type="tel" id="phone" name="phone" placeholder="Número de teléfono" required>
|
||||
<input type="email" id="email" name="email" placeholder="Correo electrónico" required>
|
||||
<button id="submitDialogButton">Enviar solicitud</button>
|
||||
<button id="cancelDialogButton">Cancelar</button>
|
||||
<div id="paypal-button-container"></div>
|
||||
<button id="submitDialogButton" class="button-pay" type="button">$20 al año</button>
|
||||
<button id="cancelDialogButton" type="button">Cancelar</button>
|
||||
</div>
|
||||
</form>
|
||||
<script src="/static/js/simplemde.min.js"></script>
|
||||
<script>
|
||||
var simplemde = new SimpleMDE({
|
||||
element: document.getElementById("editor"),
|
||||
|
|
|
@ -64,6 +64,7 @@ a {
|
|||
|
||||
.input-title {
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
background-color: #00000000;
|
||||
|
@ -127,6 +128,7 @@ footer {
|
|||
|
||||
/* Hidden dialog styles */
|
||||
#dialog {
|
||||
text-align: left;
|
||||
max-width: 400px;
|
||||
display: none;
|
||||
position: fixed;
|
||||
|
@ -138,6 +140,12 @@ footer {
|
|||
border: 1px solid #ccc;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
#dialog h2 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#dialog input {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
|
@ -147,6 +155,102 @@ footer {
|
|||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#overlay {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
#dialog {
|
||||
width: 20em;
|
||||
max-width: var(--page-width);
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
padding: 1.5em;
|
||||
background: var(--background-color);
|
||||
border: 1px solid var(--hover-border);
|
||||
box-shadow: 0 0 3em rgba(0, 0, 0, 0.4);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#dialog input {
|
||||
font-size: 1em;
|
||||
display: block;
|
||||
width: 90%;
|
||||
color: var(--color);
|
||||
background: var(--hover-background);
|
||||
border: 1px solid var(--hover-border);
|
||||
border-radius: 10px;
|
||||
padding: 1em;
|
||||
margin: 1em auto;
|
||||
}
|
||||
|
||||
#error-message {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#error-message p {
|
||||
text-decoration: underline;
|
||||
color: var(--unemph-color);
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 0.5em;
|
||||
margin: 1em auto;
|
||||
color: var(--unemph-color);
|
||||
background: var(--background);
|
||||
border: 1px solid var(--hover-border);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#dialog button:hover {
|
||||
background: var(--hover-background);
|
||||
color: var(--color);
|
||||
}
|
||||
|
||||
#dialog .button-pay{
|
||||
border: 0px solid #000;
|
||||
background: #0070ba;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#dialog .button-pay:hover {
|
||||
background: #0066aa;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#openDialogButton {
|
||||
position: fixed;
|
||||
bottom: 2em;
|
||||
right: 2em;
|
||||
height: 4em;
|
||||
cursor: pointer;
|
||||
font-size: 1em;
|
||||
z-index: 1001;
|
||||
background: linear-gradient(135deg, #00336b, #0099c5);
|
||||
border-radius: 999px;
|
||||
box-shadow: #006994 0 10px 20px -10px;
|
||||
box-sizing: border-box;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
outline: 0 solid transparent;
|
||||
padding: 8px 18px;
|
||||
width: fit-content;
|
||||
word-break: break-word;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/* Custom SimpleMDE styling */
|
||||
.CodeMirror {
|
||||
border-radius: 10px;
|
||||
|
|
|
@ -16,6 +16,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||
$name = isset($_POST["name"]) ? $_POST["name"] : "";
|
||||
$email = isset($_POST["email"]) ? $_POST["email"] : "";
|
||||
$phone = isset($_POST["phone"]) ? $_POST["phone"] : "";
|
||||
$phone = isset($_POST["paypalOrderID"]) ? $_POST["paypalOrderID"] : "";
|
||||
|
||||
$editorContent = isset($_POST["editor"]) ? $_POST["editor"] : "";
|
||||
$editorContent = str_replace("\r\n", "\n", $editorContent); // Convert CRLF to LF
|
||||
|
@ -25,6 +26,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||
---
|
||||
date: $isoDate
|
||||
author: "$name <$email> <$phone>"
|
||||
orderID: $paypalOrderID
|
||||
title: "$title"
|
||||
description: "$slogan"
|
||||
layout: single
|
||||
|
|
Loading…
Reference in a new issue