Updating a lot of stuff

Took 1 hour 48 minutes
This commit is contained in:
Tobias Hopp 2020-08-06 04:33:48 +02:00
parent 4cbdab57e3
commit e48bece328
7 changed files with 104 additions and 18 deletions

View File

@ -18,8 +18,16 @@ try
$website = new website();
$content = $website->buildWebsite();
//@ob_clean();
if( isset( $_POST['submit'] ) )
{
$content = $website->showScore();
}
else
{
$content = $website->buildWebsite();
}
@ob_clean();
echo $content;
} catch( Exception $e )

View File

@ -14,7 +14,19 @@ JOIN_DISCORD = "Tritt unserem Discord bei!"
LANGUAGE_CHOOSE = "Wähle deine Sprache aus"
CALCULATE = "Berechne meine Punkte!"
SCORE_TITLE = "Reinheits-Level"
SCORE_DESCRIPTION = "Hier kannst du sehen, wie Rein du bist.<br>Jeder hat eine Dunkle Seite!"
SCORE_SHARE = "Teilen"
SCORE_SAVE = "Speichern"
[questions]
1 = "Hast du schon mal einen Schwangerschaftstest benutzt?"
2 = "Hast du dich schon mal selbst befriedigt?"
3 = ""
3 = ""
4 = ""
5 = ""
6 = ""
7 = ""
8 = ""
9 = ""
10 = ""

View File

@ -14,7 +14,19 @@ JOIN_DISCORD = "Join our Discord!"
LANGUAGE_CHOOSE = "Choose your langauge"
CALCULATE = "Calculate my score!"
SCORE_TITLE = "Purity-Score"
SCORE_DESCRIPTION = "Here you can see how purity you are.<br>Everyone has a dark side!"
SCORE_SHARE = "Share it"
SCORE_SAVE = "Save it"
[questions]
1 = "Have you ever used a pregnancy test before?"
2 = "Did you ever masturbated?"
3 = ""
3 = ""
4 = ""
5 = ""
6 = ""
7 = ""
8 = ""
9 = ""
10 = ""

View File

@ -2,5 +2,5 @@
body {
background-image: url('/vendor/images/background.png');
background-attachment: fixed;
}

View File

@ -14,9 +14,12 @@ class website
try {
$website = file_get_contents( __DIR__ . '/website_score.html' );
$website = $this->replaceDefaultThings( $website );
$website = $this->setScore( $website );
return $website;
} catch( Exception $e )
{
throw new RuntimeException( 'Cannot load the score file', 201 );
}
}
@ -93,9 +96,9 @@ HTML;
foreach( language::$lang_file['questions'] as $number => $question )
{
$questions .= <<<CHECKBOX
<label>
<label style="font-size: 1.15em;">
<input name="question_$number" type="checkbox" class="filled-in" />
<span>$question</span>
<span class="black-text text-lighten-3">$question</span>
</label><br>
CHECKBOX;
@ -106,7 +109,7 @@ HTML;
$submit = language::$lang_file[language::CALCULATE];
$form_end = <<<HTML
<br>
<button class="btn waves-effect btn-large waves-light " type="submit" name="action">{$submit}
<button class="btn waves-effect btn-large waves-light" type="submit" name="submit" value="checked">{$submit}
<i class="material-icons right">send</i>
</button>
</form>
@ -119,4 +122,55 @@ HTML;
return $website;
}
private function calculateScore() : int
{
$score = count( language::$lang_file['questions'] );
foreach( language::$lang_file['questions'] as $number => $question )
{
if( isset( $_POST["question_$number"] ) && $_POST["question_$number"] === 'checked' )
{
$score--;
}
}
return $score;
}
private function setScore ( string $a_website ): string
{
$score = $this->calculateScore();
$html = <<<HTML
<div class="row">
<div class="col s12">
<div class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title">[SCORE_TITLE]</span>
<div class="row">
<div class="col s5">
<p>[SCORE_DESCRIPTION]</p>
</div>
<div class="col s2 l2">
<span class="black-text" style="font-size: 8.5em;">52</span>
</div>
<div class="col s4"></div>
</div>
</div>
<div class="card-action right-align">
<a href="#">[SCORE_SHARE] <i class="material-icons" style="font-size: 1.2em;">share</i></a>
<a href="#">[SCORE_SAVE] <i class="material-icons" style="font-size: 1.2em;">save</i></a>
</div>
</div>
</div>
</div>
HTML;
$html = str_replace( ['[SCORE_TITLE]', '[SCORE_DESCRIPTION]', '[SCORE_SHARE]', '[SCORE_SAVE]'], [language::$lang_file['SCORE_TITLE'], language::$lang_file['SCORE_DESCRIPTION'], language::$lang_file['SCORE_SHARE'], language::$lang_file['SCORE_SAVE']], $html );
$a_website = str_replace( '[CONTENT]', $html, $a_website );
return $a_website;
}
}

View File

@ -30,10 +30,10 @@
</head>
<body>
<div class="content">
<div class="section no-pad-bot" id="index-banner">
<div class="container z-depth-3">
<div class="section no-pad-bot" id="index-banner" style="margin-top: -58px;">
<div class="orange" style="padding-top: 20px;">
<h1 class="header center orange-text">[MAIN_TITLE]</h1>
<h1 class="header center white-text truncate">[MAIN_TITLE]</h1>
<div class="row center">
<h5 class="header col s12 light">[DESCRIPTION]</h5>
</div>
@ -50,7 +50,7 @@
</div>
</div>
<div class="container z-depth-3" style="padding-left: 20px;">
<div class="container z-depth-3 " style="padding-left: 20px; background-color: hsla(221,63%,70%,0.18); border-radius: 2px;">
<div class="section">
[CONTENT]
<br>

View File

@ -30,10 +30,10 @@
</head>
<body>
<div class="content">
<div class="section no-pad-bot" id="index-banner">
<div class="container z-depth-3">
<div class="section no-pad-bot" id="index-banner" style="margin-top: -58px;">
<div class="orange" style="padding-top: 20px;">
<h1 class="header center orange-text">[MAIN_TITLE]</h1>
<h1 class="header center white-text truncate">[MAIN_TITLE]</h1>
<div class="row center">
<h5 class="header col s12 light">[DESCRIPTION]</h5>
</div>
@ -50,10 +50,10 @@
</div>
</div>
<div class="container z-depth-3" style="padding-left: 20px;">
<div class="container z-depth-3">
<div class="section ">
[CONTENT]
<br>
</div>