Commit 0079f5e0 authored by Matthias Eurich's avatar Matthias Eurich
Browse files

add example project

parent bd7f6f8a
The MIT License (MIT)
Copyright (c) 2017 Matthias Eurich
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
### Documentation placeholder
\ No newline at end of file
body {
margin: 0;
padding: 0;
font-family: sans-serif;
font-size: 18px;
background-color: #CECECE;
}
#page {
padding: 25px;
}
#form {
padding: 15px;
}
#view {
margin-right: 25px;
}
#title {
width: 100%;
padding: 1px;
font-size: 24px;
}
#description {
width: 100%;
resize: none;
font-size: 18px;
}
#textAreaContainer {
margin-top: 15px;
}
#submitButtonContainer {
margin-top: 15px;
}
#submitButton {
width: 100%;
text-align: center;
background-color: #7CB342;
padding: 25px;
}
.component {
width: 100%;
}
.page-title {
text-align: center;
padding: 15px;
}
.box {
background-color: #FFFFFF;
box-shadow: rgba(0, 0, 0, 0.14902) 0 0 1px 0;
padding: 15px;
}
.todo-container {
margin-top: 15px;
}
.box-sizing {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Todo!</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="todo.js"></script>
</head>
<body>
<div id="page">
<div class="page-title box-sizing"><h1>Todo!</h1></div>
<div id="form" class="component box box-sizing">
<div><input id="title" class="box-sizing" type="text" placeholder="Titel"/></div>
<div id="textAreaContainer"><textarea id="description" class="box-sizing" cols="40" rows="10" placeholder="Beschreibung"></textarea></div>
<div id="submitButtonContainer"><div id="submitButton" class="box-sizing" onclick="submitTodo()"><strong>Hinzufügen</strong></div></div>
</div>
<div id="view" class="component"></div>
</div>
</body>
</html>
\ No newline at end of file
/**
* Created by merh on 24.03.17.
*/
const todos = [];
class Todo {
constructor(title, description) {
this.title = title;
this.description = description;
}
}
function addTodo(todo) {
todos.push(todo);
}
function addTodoView(todo) {
const view = document.getElementById('view');
const wrapper = document.createElement('DIV');
const title = document.createElement('H3');
const description = document.createElement('P');
title.appendChild(document.createTextNode(todo.title));
description.appendChild(document.createTextNode(todo.description));
wrapper.appendChild(title);
wrapper.appendChild(description);
wrapper.className = 'todo-container box box-sizing';
view.appendChild(wrapper);
}
function submitTodo() {
const title = document.getElementById('title');
const description = document.getElementById('description');
const todo = new Todo(title.value, description.value);
addTodo(todo);
addTodoView(todo);
title.value = '';
description.value = '';
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment