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('openDialogButton').addEventListener('click', () => {
|
||||||
|
document.getElementById('overlay').style.display = 'block';
|
||||||
document.getElementById('dialog').style.display = 'block';
|
document.getElementById('dialog').style.display = 'block';
|
||||||
|
document.getElementById('openDialogButton').style.display = 'none';
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('submitDialogButton').addEventListener('click', () => {
|
document.getElementById('submitDialogButton').addEventListener('click', () => {
|
||||||
const form = document.getElementById('mainForm');
|
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
|
['name', 'email', 'phone'].forEach(id => {
|
||||||
const nameInput = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
nameInput.type = 'hidden';
|
input.type = 'hidden';
|
||||||
nameInput.name = 'name';
|
input.name = id;
|
||||||
nameInput.value = name;
|
input.value = document.getElementById(id).value;
|
||||||
form.appendChild(nameInput);
|
form.appendChild(input);
|
||||||
|
});
|
||||||
|
|
||||||
const emailInput = document.createElement('input');
|
if (isFormValid()) {
|
||||||
emailInput.type = 'hidden';
|
document.getElementById('error-message').style.display = 'none';
|
||||||
emailInput.name = 'email';
|
// renderPayPalButton();
|
||||||
emailInput.value = email;
|
} else {
|
||||||
form.appendChild(emailInput);
|
document.getElementById('error-message').style.display = 'block';
|
||||||
|
// removePayPalButton();
|
||||||
|
}
|
||||||
|
|
||||||
const phoneInput = document.createElement('input');
|
// const orderIDInput = document.createElement('input');
|
||||||
phoneInput.type = 'hidden';
|
// orderIDInput.type = 'hidden';
|
||||||
phoneInput.name = 'phone';
|
// orderIDInput.name = 'paypalOrderID';
|
||||||
phoneInput.value = phone;
|
// orderIDInput.value = paypalOrderID;
|
||||||
form.appendChild(phoneInput);
|
// form.appendChild(orderIDInput);
|
||||||
|
|
||||||
// Submit
|
|
||||||
form.submit();
|
form.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cancel button
|
|
||||||
document.getElementById('cancelDialogButton').addEventListener('click', () => {
|
document.getElementById('cancelDialogButton').addEventListener('click', () => {
|
||||||
// Clear values
|
document.getElementById('overlay').style.display = 'none';
|
||||||
document.getElementById('name').value = '';
|
|
||||||
document.getElementById('email').value = '';
|
|
||||||
document.getElementById('phone').value = '';
|
|
||||||
// Hide dialog
|
|
||||||
document.getElementById('dialog').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.min.css">
|
||||||
<link rel="stylesheet" href="/static/css/simplemde-dark.min.css">
|
<link rel="stylesheet" href="/static/css/simplemde-dark.min.css">
|
||||||
<link rel="stylesheet" href="/static/css/style.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>
|
</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="banner" style="background-image: url(/static/banner.jpg);">
|
||||||
<div class="desc">
|
<div class="desc">
|
||||||
<input type="text" name="title" class="input-title" placeholder="[Nombre Ejemplo]">
|
<input type="text" name="title" class="input-title" placeholder="[Nombre Ejemplo]">
|
||||||
|
@ -28,17 +30,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<div id="overlay"></div>
|
||||||
<div id="dialog">
|
<div id="dialog">
|
||||||
<h2>Ingrese sus detalles</h2>
|
<h2>Ingrese sus detalles</h2>
|
||||||
<p>Utilizaremos esta información para contactarle acerca de la publicación del sitio.</p>
|
<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="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="tel" id="phone" name="phone" placeholder="Número de teléfono" required>
|
||||||
<input type="email" id="email" name="email" placeholder="Correo electrónico" required>
|
<input type="email" id="email" name="email" placeholder="Correo electrónico" required>
|
||||||
<button id="submitDialogButton">Enviar solicitud</button>
|
<div id="paypal-button-container"></div>
|
||||||
<button id="cancelDialogButton">Cancelar</button>
|
<button id="submitDialogButton" class="button-pay" type="button">$20 al año</button>
|
||||||
|
<button id="cancelDialogButton" type="button">Cancelar</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<script src="/static/js/simplemde.min.js"></script>
|
|
||||||
<script>
|
<script>
|
||||||
var simplemde = new SimpleMDE({
|
var simplemde = new SimpleMDE({
|
||||||
element: document.getElementById("editor"),
|
element: document.getElementById("editor"),
|
||||||
|
|
|
@ -64,6 +64,7 @@ a {
|
||||||
|
|
||||||
.input-title {
|
.input-title {
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: #00000000;
|
background-color: #00000000;
|
||||||
|
@ -127,6 +128,7 @@ footer {
|
||||||
|
|
||||||
/* Hidden dialog styles */
|
/* Hidden dialog styles */
|
||||||
#dialog {
|
#dialog {
|
||||||
|
text-align: left;
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
display: none;
|
display: none;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
@ -138,6 +140,12 @@ footer {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#dialog h2 {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
#dialog input {
|
#dialog input {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
@ -147,6 +155,102 @@ footer {
|
||||||
margin-top: 10px;
|
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 */
|
/* Custom SimpleMDE styling */
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
|
|
@ -16,6 +16,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
$name = isset($_POST["name"]) ? $_POST["name"] : "";
|
$name = isset($_POST["name"]) ? $_POST["name"] : "";
|
||||||
$email = isset($_POST["email"]) ? $_POST["email"] : "";
|
$email = isset($_POST["email"]) ? $_POST["email"] : "";
|
||||||
$phone = isset($_POST["phone"]) ? $_POST["phone"] : "";
|
$phone = isset($_POST["phone"]) ? $_POST["phone"] : "";
|
||||||
|
$phone = isset($_POST["paypalOrderID"]) ? $_POST["paypalOrderID"] : "";
|
||||||
|
|
||||||
$editorContent = isset($_POST["editor"]) ? $_POST["editor"] : "";
|
$editorContent = isset($_POST["editor"]) ? $_POST["editor"] : "";
|
||||||
$editorContent = str_replace("\r\n", "\n", $editorContent); // Convert CRLF to LF
|
$editorContent = str_replace("\r\n", "\n", $editorContent); // Convert CRLF to LF
|
||||||
|
@ -25,6 +26,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
---
|
---
|
||||||
date: $isoDate
|
date: $isoDate
|
||||||
author: "$name <$email> <$phone>"
|
author: "$name <$email> <$phone>"
|
||||||
|
orderID: $paypalOrderID
|
||||||
title: "$title"
|
title: "$title"
|
||||||
description: "$slogan"
|
description: "$slogan"
|
||||||
layout: single
|
layout: single
|
||||||
|
|
Loading…
Reference in a new issue