Skip to content

Commit

Permalink
main.elm: auch unverschlüsselte Buchstaben auf beiden Zeilen zeigen
Browse files Browse the repository at this point in the history
satz.php: erste funktionsfähige Version
  • Loading branch information
Christian Bläul committed Oct 10, 2016
1 parent 49980e9 commit 0c4e696
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ holeEchtenSatzVomServer : String -> Cmd Msg
holeEchtenSatzVomServer topic =
let
url =
"http://localhost/satz.php"
"http://blaeul.de/Der-Wunschpunsch-in-Geheimschrift/satz.php"
in
Task.perform FetchFail SatzHolenWarErfolgreich (Http.get decodeWunschpunschJson url)

Expand Down Expand Up @@ -259,7 +259,9 @@ buchstabenInput model aktuellerBuchstabenIndex echterBuchstabe =
in
case verschlüsselungsergebnis of
NichtVerschlüsselt ->
[ text echterBuchstabe ]
[ text echterBuchstabe
, Html.br [] []
, text echterBuchstabe ]

Verschlüsselt zufälligerBuchstabe ->
[ text zufälligerBuchstabe
Expand Down
14 changes: 13 additions & 1 deletion satz.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<?php
$sText = join(' ', array_map(function($input) {
return preg_replace("/([a-z])- +/", "$1", $input);
}, file('Michael Ende - Der Wunschpunsch.txt')));

$sText = str_replace(array("\n", "\r"), "", $sText);

$aSaetze = explode(".", $sText);
$iSatz = rand(0, count($aSaetze) - 1);

$sSatz = '';
while(strlen($sSatz) < 150) $sSatz .= $aSaetze[$iSatz++] . ".";

header('Access-Control-Allow-Origin: *');
echo json_encode(array('echterSatz' => 'Zufall'));
echo json_encode(array('anzahlSaetze' => count($aSaetze), 'aktuellerSatzIndex'=> $iSatz, 'echterSatz' => trim(str_replace(" ", " ", $sSatz))));

0 comments on commit 0c4e696

Please sign in to comment.