master
Robert Köpferl 2021-01-17 21:16:42 +01:00
commit 37b7eb3818
6 changed files with 348 additions and 0 deletions

7
php/const.php Normal file
View File

@ -0,0 +1,7 @@
<?php
define('TEXT_MAXLEN', 160);
define('TEXT_MAXLINE', 63);
define('ERIKA_CMD', "echo");
?>

85
php/erika.php Normal file
View File

@ -0,0 +1,85 @@
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="5; url=index.php" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Schreib auf die Erika</title>
<meta name="description" content="Simple Webseite, um auf Erika zu tippen.">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<div id="logo"><img src="logo.png">Erika-Tippmaschine</div>
<nav>
<ul>
<li><a href="./">Heim</a>
<!-- <li><a href="https://html-css-js.com/">HTML</a>
<li><a href="https://html-css-js.com/css/code/">CSS</a>
<li><a href="https://htmlcheatsheet.com/js/">JS</a> -->
</ul>
</nav>
</header>
<section>
<?php
include 'const.php';
$text = $_POST['texta'];
$len = strlen(utf8_decode($text));
if ( $len > TEXT_MAXLEN )
{
$meldung = "Text ist zu lang und wurde eingekürzt";
$text = substr($text, 0, TEXT_MAXLEN);
}
echo "Text: ".$len." von erlaubten ".TEXT_MAXLEN." Zeichen.";
$nlkorrekt = preg_replace('~\R~u', "\r\n", $text);
$suchmuster = '/[^-a-zA-Z0-9äüöÄÜÖß ,;\.:()%&$§"!+*#\'\?\/\n\r]/';
$ersetzung = '(?)';
$neuertext = preg_filter($suchmuster, $ersetzung, $nlkorrekt);
//Ersetze vier+mehr \n durch \n---\n
$newlinebereinigt = preg_replace('/(\R){3,}/m', "\r\n---\r\n", $neuertext );
$umgebrochen = wordwrap($newlinebereinigt, TEXT_MAXLINE);
//echo $neuertext;
//echo "<br/>Der Text:<br/>";
//echo $newlinebereinigt;
echo "<br/>";
// $arg = escapeshellarg($newlinebereinigt);
//echo "<br/> arg: ".$arg;
$res = system(ERIKA_CMD.$arg);
echo "<br/>";
?>
<strong>Befehl wurde ausgeführt: <?php echo $res ?></strong>.
</section>
<section id="pageContent">
<main role="main">
<h1>Erika schreibt</h1>
<article>
<p>Wenn alles gut war, ist jetzt der Text zu sehen:
</p>
<br/>
<pre><?php echo $umgebrochen ?></pre>
</article>
<h1>Zurück</h1>
<article>
Hier geht's wieder <a href="./" >zurück</a>. Normalerweise aber automatisch.
</article>
</main>
</section>
<footer>
<p>&copy; Robert Köpferl für ChCh und Klub Solitär | Vorlage: <a href="https://html5-templates.com/" target="_blank" rel="nofollow">HTML5 Templates</a></p>
<address>
Kontakt: <a href="mailto:presse@klub-solitaer.de">E-Mail an Klub Solitär</a>
</address>
</footer>
</body>
</html>

79
php/index.php Normal file
View File

@ -0,0 +1,79 @@
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Schreib auf die Erika</title>
<meta name="description" content="Simple Webseite, um auf Erika zu tippen.">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<div id="logo"><img src="logo.png">Erika-Tippmaschine</div>
<nav>
<ul>
<li><a href="./">Heim</a>
<!-- <li><a href="https://html-css-js.com/">HTML</a>
<li><a href="https://html-css-js.com/css/code/">CSS</a>
<li><a href="https://htmlcheatsheet.com/js/">JS</a> -->
</ul>
</nav>
</header>
<section>
Hier kann man nach gewissen Parametern auf der nebenstehenden <strong></strong>Schreibmaschine
Texte ausgeben</strong>.
</section>
<section id="pageContent">
<main role="main">
<h1>Erklärung</h1>
<article>
<h2>Limitierungen</h2>
<p>Es gibt gewisse Limits für die Texte. Siehe rechts.
</p>
</article>
<article>
<h2>Texten</h2>
<p>Hier Deinen Text eingeben:</p>
<form method="POST" action="erika.php" accept-charset="utf-8" enctype="multipart/form-data">
<textarea accesskey="t" id="texta" name="texta" maxlength="160" ></textarea>
<br/>
<label id="zeichen" >Zeichen: </label>
<br/>
<label id="sekunden" >Sekunden: </label>
<br/>
<button type="submit" id="bsenden" title="Senden" disabled>Senden</button>
</form>
</article>
</main>
<aside>
<div>Aktuell darf nur alle <strong>3</strong> Minuten ein Text ausgedruckt werden.</div>
<div>Es sind nur 63 Zeichen pro Zeile Platz (Schreibmaschinenbreite) - es
gibt aber einen automatischen Umbruch.</div>
<div><p>Der Zeichensatz ist auf das limitiert, was die Maschine kann.
Das ist [a-zA-ZäüöÄÜÖ,.;:-_=!"^°+#*?()/ ] u.a.m.
</p>
<p>Nichtdruckbares wid zu ?</p>
</div>
<div>
Außerdem erlauben wir maximal 160 Zeichen insgesamt. Wobei maximal
3 Leerzeilen in einer Folge erlaubt sind.</div>
</aside>
</section>
<footer>
<p>&copy; Robert Köpferl für ChCh und Klub Solitär | Vorlage: <a href="https://html5-templates.com/" target="_blank" rel="nofollow">HTML5 Templates</a></p>
<address>
Kontakt: <a href="mailto:presse@klub-solitaer.de">E-Mail an Klub Solitär</a>
</address>
</footer>
<script>
window.letztesMal = Date.now();
</script>
<script src="script.js"></script>
</body>
</html>

BIN
php/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

44
php/script.js Normal file
View File

@ -0,0 +1,44 @@
function interaktiv(){
const zl = document.getElementById('zeichen');
const tf = document.getElementById('texta');
const sl = document.getElementById('sekunden');
const bs = document.getElementById('bsenden');
var upd = (target) =>{
const maxLength = target.getAttribute("maxlength");
const currentLength = target.value.length;
zl.innerText = `Zeichen: ${currentLength}/${maxLength} `;
if (currentLength >= maxLength) {
zl.innerText += " (länger geht nicht!)";
return; // console.log("You have reached the maximum number of characters.");
}
}
tf.addEventListener("input", (event) => {
const target = event.currentTarget;
upd(target);
// tf.ononkeyup = function(ev){
// zl.innerText = "Zeichen: "+ tf.textContent.length;
// }
});
setInterval( event=>{
var diff = (window.letztesMal + 5000) - Date.now();
var sek = Math.floor(diff / 1000);
if(sek == 0) {
bs.disabled = false;
}
if(sek < 0)
return;
sl.innerText = "Sekunden bis zum nächsten Senden: " + sek;
}, 100);
upd(tf);
}
document.onload = interaktiv().bind(this);

133
php/style.css Normal file
View File

@ -0,0 +1,133 @@
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}
body{line-height:1; font-family: arial;}
h1{font-size: 25px;}h2{font-size: 21px;}h3{font-size: 18px;}h4{font-size: 16px;}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}
nav ul{list-style:none}
blockquote,q{quotes:none}
blockquote:before,blockquote:after,q:before,q:after{content:none}
a{margin:0;padding:0;font-size:100%;vertical-align:baseline;background:transparent}
ins{background-color:#ff9;color:#000;text-decoration:none}
mark{background-color:#ff9;color:#000;font-style:italic;font-weight:bold}
del{text-decoration:line-through}
abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help}
table{border-collapse:collapse;border-spacing:0}
hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}
input,select{vertical-align:middle}
body,html {
background-color: #FFF;
}
header {
background: #f1b8f8;
padding: 20px 30px;
max-width: 940px;
margin: auto;
}
nav {
display: inline-block;
}
nav ul li a {
background: #EEE;
padding: 2px 10px;
font-size: 20px;
text-decoration: none;
font-weight: bold;
color: #444;
border-radius: 10px;
}
nav ul li a:hover {
background: #FFF;
}
nav ul li {
display: inline-block;
margin: 10px;
}
nav ul {
list-style: none;
}
#pageContent {
max-width: 1000px;
margin: auto;
border: none;
}
main {
float: left;
width: 60%;
}
aside {
float: right;
width: 30%;
}
article {
border-bottom: 2px dotted #999;
padding-bottom: 20px;
margin-bottom: 20px;
}
article h2 {
font-weight: normal;
margin-bottom: 12px;
}
article p {
}
main section {
}
footer {
background: #f1b8f8;
max-width: 1000px;
margin: auto;
clear: both;
text-align: right;
}
footer p {
padding: 20px;
}
address {
padding: 10px 20px 30px 10px;
}
aside > div {
margin: 10px auto;
background: #ffb81f;
min-height: 100px;
}
#logo {
display: inline-block;
vertical-align: middle;
font-size: 30px;
margin-right: 75px;
color: #FFF;
}
#logo img {
width: 50px;
vertical-align: middle;
margin-right: 10px;
}
body > section {
max-width: 1000px;
margin: auto;
padding: 30px 0px;
border-bottom: 1px solid #999;
color: #333;
}
@media screen and (max-width: 1000px) {
body > section {
padding: 30px 20px;
}
}
@media screen and (max-width: 600px) {
main {
float: none;
width: 100%;
}
aside {
float: none;
width: 100%;
}
}
textarea {
width: 80%;
height: 200px;
}