Adding a lot of fonts, and general system

Took 1 hour 11 minutes
This commit is contained in:
2020-08-07 04:19:02 +02:00
parent 6eaeb73a83
commit 18c55bd052
16 changed files with 123 additions and 30 deletions

View File

@ -12,7 +12,8 @@ class website
public function showScore( ) : string
{
try {
$website = file_get_contents( __DIR__ . '/website_score.html' );
$website = file_get_contents( __DIR__ . '/website.html' );
$website = $this->replaceDefaultThings( $website );
$website = $this->setScore( $website );
@ -48,7 +49,6 @@ class website
if( !isset( language::$lang_file[language::TITLE],
language::$lang_file[language::MAIN_TITLE],
language::$lang_file[language::DESCRIPTION],
language::$lang_file[language::EXPLANATION],
language::$lang_file[language::SCORE_FINISHED],
language::$lang_file[language::PROJECT_DESCRIPTION],
language::$lang_file[language::HELP_US],
@ -60,13 +60,12 @@ class website
}
$website = str_replace(
array(
'[LANG]', '[TITLE]', '[MAIN_TITLE]', '[DESCRIPTION]', '[EXPLANATION]', '[SCORE_FINISHED]', '[PROJECT_DESCRIPTION]', '[HELP_US]', '[REQUEST_MORE]','[LANGUAGE_CHOOSE]', '[JOIN_DISCORD]' ),
'[LANG]', '[TITLE]', '[MAIN_TITLE]', '[DESCRIPTION]', '[SCORE_FINISHED]', '[PROJECT_DESCRIPTION]', '[HELP_US]', '[REQUEST_MORE]','[LANGUAGE_CHOOSE]', '[JOIN_DISCORD]' ),
array(
substr( language::$lang, 0, 2 ),
language::$lang_file[language::TITLE],
language::$lang_file[language::MAIN_TITLE],
language::$lang_file[language::DESCRIPTION],
language::$lang_file[language::EXPLANATION],
language::$lang_file[language::SCORE_FINISHED],
language::$lang_file[language::PROJECT_DESCRIPTION],
language::$lang_file[language::HELP_US],
@ -88,6 +87,8 @@ HTML;
private function setQuestions( $website ) : string
{
$website = str_replace( '[EXPLANATION]', language::$lang_file[language::EXPLANATION_QUESTIONS], $website );
if( !isset( language::$lang_file['questions'] ) )
{
throw new RuntimeException( 'Error while reading the questions in langauge file', 203 );
@ -125,10 +126,11 @@ HTML;
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' )
if( isset( $_POST["question_$number"] ) && $_POST["question_$number"] === 'on' )
{
$score--;
}
@ -138,7 +140,11 @@ HTML;
private function setScore ( string $a_website ): string
{
$a_website = str_replace( '[EXPLANATION]', language::$lang_file[language::EXPLANATION_SCORE], $a_website );
$score = $this->calculateScore();
$max = count( language::$lang_file['questions'] );
$back = language::$lang_file['BACK'];
$html = <<<HTML
<div class="row">
<div class="col s12">
@ -148,12 +154,14 @@ HTML;
<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>
<span id="score" class="deep-orange-text" style="font-size: 8.8em; font-family: PressStart2P, serif">$max</span>
</div>
<div class="col s4"></div>
</div>
</div>
@ -163,14 +171,26 @@ HTML;
</div>
</div>
</div>
</div>
<div style="padding-left: 1em;">
<button class="btn waves-effect btn-large waves-light" type="submit" name="submit" value="checked" onclick="location.href = '?';"">{$back}
<i class="material-icons right">arrow_back</i>
</button>
</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 );
$script = <<<JS
if( {$score} !== {$max} )
{
animateValue("score", {$max}, {$score}, 600);
}
JS;
$a_website = str_replace( array( '[SCRIPT_CONTENT]', '[CONTENT]' ), array( $script, $html ), $a_website );
return $a_website;
}
}