89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>PHP Quote Maker</title>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
|
|
<style>
|
|
#modifiedText {
|
|
white-space: pre-wrap; /* css-3 */
|
|
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
|
white-space: -pre-wrap; /* Opera 4-6 */
|
|
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
|
}
|
|
</style>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#copyButton').click(function() {
|
|
var modifiedText = $('#modifiedText').text();
|
|
|
|
// Create an invisible textarea element to include the modified text
|
|
var textarea = $('<textarea></textarea>');
|
|
textarea.val(modifiedText);
|
|
$('body').append(textarea);
|
|
|
|
// Copy the text from the textarea element
|
|
textarea.select();
|
|
document.execCommand("copy");
|
|
|
|
// Remove the textarea element
|
|
textarea.remove();
|
|
|
|
// Show confirmation message
|
|
alert("The modified text has been copied to your clipboard!");
|
|
});
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1>PHP Quote Maker</h1>
|
|
|
|
<hr>
|
|
|
|
<div>
|
|
<p>A simple, no-frills quote generator that puts "> " before each line of a text.</p>
|
|
</div>
|
|
|
|
|
|
|
|
<form method="POST">
|
|
<textarea name="text" rows="10" cols="50"></textarea><br><br>
|
|
<input type="submit" name="submit" value="Create quote">
|
|
</form>
|
|
|
|
<?php
|
|
/**
|
|
* PHP Quote Maker
|
|
*
|
|
* Author: Helmut Kaczmarek <email@helmutkaczmarek.de>
|
|
* License: GPL 3 <https://www.gnu.org/licenses/gpl-3.0.html>
|
|
*/
|
|
if(isset($_POST['submit'])) {
|
|
// Retrieve text from clipboard
|
|
$text = $_POST['text'];
|
|
|
|
// Expand each line with "> " at the beginning
|
|
$lines = explode("\n", $text);
|
|
$modifiedText = '';
|
|
foreach($lines as $line) {
|
|
$modifiedText .= "> " . $line . "\n";
|
|
}
|
|
|
|
// Show the modified text
|
|
echo "<h2>Modified text:</h2>";
|
|
echo "<div>";
|
|
echo "<p><pre id='modifiedText'>" . $modifiedText . "</pre></p>";
|
|
echo "<p><button id='copyButton'>Copy text</button></p>";
|
|
echo "</div>";
|
|
}
|
|
?>
|
|
|
|
|
|
<hr>
|
|
|
|
<div>
|
|
<p>View <a href="https://code.helmutkaczmarek.de/helmut/php-quote-maker">sorce code</a>.</p>
|
|
</div>
|
|
</body>
|
|
</html>
|