Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework #2 #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
body {
width: 400px;
margin: auto;
margin-top: 50px;
margin-bottom: 50px;
font-family: sans-serif;
}
#htmldescription {
height: 80px
;
}
27 changes: 27 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<title>Homework2</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/event.js"></script>
</head>
<body>
<h3>Add event</h3>
<label for="htmlname"></label>
<p><input type="text" id="htmlname" placeholder="Name"/></p>
<label for="htmldescription"></label>
<p><input type="text" id="htmldescription" placeholder="About"/></p>
<label for="htmldate"></label>
<p><input type="text" id="htmldate" placeholder="When"/></p>
<label for="htmltime"></label>
<p><input type="text" id="htmltime" placeholder="How long"/></p>
<label for="htmlwhere"></label>
<p><input type="text" id="htmlwhere" placeholder="Where"/></p>
<p><button type="button" id="htmlbutton" class="btn">Submit</button></p>
<p id="htmlresult"></p>
<article></article>
</body>
</html>
6 changes: 6 additions & 0 deletions js/bootstrap.min.js

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions js/event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Возвращает объект Event
*
* @param {String} name Название события
* @param {String} description Описание события
* @param {String} date Время события
* @param {String} time Длительность события
* @param {String} where Место проведения события
*
* @example
* Event('BalalaikaFest',
* 'Awesome musical performance',
* '2012-10-30T19:30:00-05:00',
* '2 hours',
* 'Yekaterinburg')
*
* @return {Object}
*/
function event(name, description, date, time, where) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше использовать от и до, а не от и продолжительность. Попробуй так же сократить количество аргументов.

{
    name: "name",
    description: "pewpew ololo",
    ...
}

"use strict";
return {
"name": name || "Name",
"description": description || "Description",
"date": new Date(+date) || "Date",
"time": time || "Time",
"where": where || "Where"
};
}
function toTitleCase(string) {
"use strict";
return string.charAt(0).toUpperCase() + string.slice(1);
}
function init() {
"use strict";
document.getElementById('htmlbutton').onclick = function () {
var jsname = document.getElementById('htmlname').value || "Name of Event",
jsdescription = document.getElementById('htmldescription').value,
jsdate = document.getElementById('htmldate').value,
jstime = document.getElementById('htmltime').value,
jswhere = document.getElementById('htmlwhere').value,
obj = event(jsname, jsdescription, jsdate, jstime, jswhere),
temp = '<table class="table table-striped"><p></p><p style = "font-size: 16px; font-weight: bold; text-align: center;">' + jsname + '</p>';
delete obj.name;
for (var objname in obj) {
//noinspection JSUnfilteredForInLoop
temp += '<tr><th>' + toTitleCase(objname) + '</th><td>' + obj[objname] + '</td></tr>';
}
temp += '</table>';
document.getElementById('htmlresult').innerHTML += temp;
};
}
onload = init;