Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions katas/BerlinClock/solutions/PETARJEV/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dieses Projekt kann mit der Hilfe eines PHP Servers gestarten werden. Der Hauptordner ist root der Anwendung.
70 changes: 70 additions & 0 deletions katas/BerlinClock/solutions/PETARJEV/assets/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#berlin-clock {
position:relative;
margin:auto;
width:50%;
}

#berlin-clock > div {
margin-bottom:10px;
display:flex;
flex-wrap:wrap;
}

#berlin-clock > div > div {
height: 100px;
}

#seconds {
display:block;
border-radius:50%;
width:25%;
margin:auto;
height: 150px;
border: 1px solid #000;
}

#seconds.seconds-filled {
background:yellow;
}

#five-hours, #one-hours, #one-minutes {
width:100%;
border:5px solid #000;
}

.five-hour, .one-hour,.one-minute {
width:calc(25% - 5px);
border-right:5px solid #000;
}

.five-hour.five-hour-filled, .one-hour.one-hour-filled {
background:red;
}

.five-hour:last-of-type, .one-hour:last-of-type, .one-minute:last-of-type {
width:calc(25%);
border-right:0;
}

#five-minutes {
width:100%;
border:5px solid #000;
}

.five-minute {
width:calc((100% / 11) - 5px);
border-right:5px solid #000;
}

.five-minute.five-minute-filled, .one-minute.one-minute-filled {
background:yellow;
}

.five-minute.five-minute-filled:nth-of-type(3n) {
background:red;
}

.five-minute:last-of-type {
border-right:0;
width:calc((100% / 11));
}
71 changes: 71 additions & 0 deletions katas/BerlinClock/solutions/PETARJEV/assets/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
(function () {
//Die Funktion
function paintTheClock() {
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
//Variablen, die n�tig sind
var fiveHours = 0;
var oneHours = 0;
var fiveMinutes = 0;
var oneMinutes = 0;
//Stunden fur die erste Reihe
if (hours / 5 > 1) {
fiveHours = Math.floor(hours / 5);
hours = hours - (fiveHours * 5);
var fiveHoursTiles = document.querySelectorAll(".five-hour");
var fiveHoursTilesLength = fiveHoursTiles.length;
for (var i = 0; i < fiveHours; i++) {
fiveHoursTiles[i].className = "five-hour five-hour-filled";
}
for (var i = fiveHours; i < fiveHoursTilesLength; i++) {
fiveHoursTiles[i].className = "five-hour";
}
}
//Stunden fur die zweite Reihe
if (hours > 0) {
var oneHoursTiles = document.querySelectorAll(".one-hour");
var oneHoursTilesLength = oneHoursTiles.length;
for (var i = 0; i < hours; i++) {
oneHoursTiles[i].className = "one-hour one-hour-filled";
}
for (var i = hours; i < oneHoursTilesLength; i++) {
oneHoursTiles[i].className = "one-hour";
}
}
//Minuten fur die dritte Reihe
if (minutes / 5 > 1) {
fiveMinutes = Math.floor(minutes / 5);
minutes = minutes - (fiveMinutes * 5);
var fiveMinutesTiles = document.querySelectorAll(".five-minute");
var fiveMinutesTilesLength = fiveMinutesTiles.length;
for (var i = 0; i < fiveMinutes; i++) {
fiveMinutesTiles[i].className = "five-minute five-minute-filled";
}
for (var i = fiveMinutes; i < fiveMinutesTilesLength; i++) {
fiveMinutesTiles[i].className = "five-minute";
}
}
//Minuten fur die vierte Reihe
if (minutes > 0) {
var oneMinutsTiles = document.querySelectorAll(".one-minute");
var oneMinutsTilesLength = oneMinutsTiles.length;
for (var i = 0; i < minutes; i++) {
oneMinutsTiles[i].className = "one-minute one-minute-filled";
}
for (var i = minutes; i < oneMinutsTilesLength; i++) {
oneMinutsTiles[i].className = "one-minute";
}
}
//Sekunden
var secondsTile = document.getElementById("seconds");
if (seconds % 2 == 0) {
secondsTile.className = "";
}
else {
secondsTile.className = "seconds-filled";
}
}
window.setInterval(paintTheClock,1000);
})();
16 changes: 16 additions & 0 deletions katas/BerlinClock/solutions/PETARJEV/functions/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

function config($key = '')
{
$config = [
'name' => 'Berlin Clock',
'site_url' => '',
'template_path' => 'template',
'css_path' => 'assets/css',
'js_path' => 'assets/js',
'version' => 'v1.0',
];

return isset($config[$key]) ? $config[$key] : null;
}
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Es l�dt das HTML Template
*/
function init()
{
require config('template_path') . '/template.php';
}

/**
* Es l�dt CSS Dateien
*/
function load_css($file = '')
{
$url = config('site_url') . '/' . config('css_path') . '/' . $file . '.css';
$path = getcwd() . '/' . config('css_path') . '/' . $file . '.css';
if (file_exists($path)) {
echo '<link href="'.$url.'" rel="stylesheet" type="text/css" />';
}
}
/**
* Es l�dt JS Dateien
*/
function load_js($file = '')
{
$url = config('site_url') . '/' . config('js_path') . '/' . $file . '.js';
$path = getcwd() . '/' . config('js_path') . '/' . $file . '.js';
if (file_exists($path)) {
echo '<script src="'.$url.'"></script>';
}
}
?>
6 changes: 6 additions & 0 deletions katas/BerlinClock/solutions/PETARJEV/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
require 'functions/config.php';
require 'functions/generate_html_elements.php';

init();
?>
63 changes: 63 additions & 0 deletions katas/BerlinClock/solutions/PETARJEV/template/template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<html lang="de">
<head>
<title></title>
<meta name="description" content=">" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1">
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8" />
<link rel="apple-touch-icon" sizes="180x180" href="">
<link rel="icon" type="image/png" sizes="32x32" href="">
<link rel="icon" type="image/png" sizes="16x16" href="">
<link rel="shortcut icon" type="image/png" sizes="16x16" href="">
<?php load_css("styles"); ?>
</head>
<body>

<header>

</header>

<main class="container">
<div id="berlin-clock">
<div id="seconds">
</div>
<div id="five-hours">
<div class="five-hour"></div>
<div class="five-hour"></div>
<div class="five-hour"></div>
<div class="five-hour"></div>
</div>
<div id="one-hours">
<div class="one-hour"></div>
<div class="one-hour"></div>
<div class="one-hour"></div>
<div class="one-hour"></div>
</div>
<div id="five-minutes">
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
<div class="five-minute"></div>
</div>
<div id="one-minutes">
<div class="one-minute"></div>
<div class="one-minute"></div>
<div class="one-minute"></div>
<div class="one-minute"></div>
</div>
</div>
</main>

<footer>

</footer>
<?php load_js("index"); ?>
</body>
</html>
1 change: 1 addition & 0 deletions katas/StrangeChessboard/solutions/PETARJEV/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dieses Projekt kann mit der Hilfe eines PHP Servers gestarten werden. Der Hauptordner ist root der Anwendung.
14 changes: 14 additions & 0 deletions katas/StrangeChessboard/solutions/PETARJEV/functions/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

function config($key = '')
{
$config = [
'name' => '',
'site_url' => '',
'template_path' => 'template',
'version' => 'v1.0',
];

return isset($config[$key]) ? $config[$key] : null;
}
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Es l�dt das HTML Template
*/
function init()
{
require config('template_path') . '/template.php';
}

function calculateTheSum(array $cs, array $rs) {
$cs_length = count($cs);
$rs_length = count($rs);
//Der erste Check - ob die L�ngen der Arrays gleich sind
if($cs_length != $rs_length) {
return "Die Arrays haben unterschiedliche L�nge";
}
else {
$total_white_area = 0;
$total_black_area = 0;
for($i = 0;$i < $rs_length; $i++) {
for($j = 0;$j < $cs_length; $j++) {
//Wenn die Indexes beider Arrays gerade sind oder ungerade sind, wird das Produkt der Werte der Elemente beider Array dem Wert f�r $total_white_area hinzugef�gt
if(($j % 2 == 0 && $i % 2 == 0) || ($j % 2 != 0 && $i % 2 != 0)) {
$total_white_area = $total_white_area + $cs[$j] * $rs[$i];
}
else {
$total_black_area = $total_black_area + $cs[$j] * $rs[$i];
}
}
}
$tuple = array();
array_push($tuple,$total_white_area,$total_black_area);
return $tuple;
}
}
?>
12 changes: 12 additions & 0 deletions katas/StrangeChessboard/solutions/PETARJEV/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

// Comment these lines to hide errors
error_reporting(E_ALL);
ini_set('display_errors', 1);
// REQUIRES:

require 'functions/config.php';
require 'functions/generate_html_elements.php';

init();
?>
28 changes: 28 additions & 0 deletions katas/StrangeChessboard/solutions/PETARJEV/template/template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<html lang="de">
<head>
<title></title>
<meta name="description" content=">" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1">
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8" />
<link rel="apple-touch-icon" sizes="180x180" href="">
<link rel="icon" type="image/png" sizes="32x32" href="">
<link rel="icon" type="image/png" sizes="16x16" href="">
<link rel="shortcut icon" type="image/png" sizes="16x16" href="">
</head>
<body>

<header>

</header>

<main class="container">
<?php print_r(calculateTheSum([ 3, 1, 2, 7, 1 ],[ 1, 8, 4, 5, 2 ])); ?>
</main>

<footer>

</footer>

</body>
</html>