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
9 changes: 9 additions & 0 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
body {
width: 450px;
margin: auto;
margin-top: 50px;
margin-bottom: 50px;
font-family: sans-serif;
}
18 changes: 18 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>Пример сортировки</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
<script src="js/sort_array.js"></script>
</head>
<body>
<legend>Регистрация:</legend>
<form class="form-inline">
Copy link
Member

Choose a reason for hiding this comment

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

Так же табуляция и UTF-8

<input type="text" placeholder="Имя" id="txtName"/>
<button type="button" id="btn" class='btn'>Продолжить</button>
</form>
<p id="result"></p>
</body>
</html>
6 changes: 6 additions & 0 deletions js/bootstrap.min.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions js/sort_array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var userNames = ["ilya", "vasya", "predator", "littlepony"];
function registerName() {
"use strict";
var newName = document.getElementById("txtName").value.toLowerCase(),
result = document.getElementById("result"),
success;
if (newName === "") {
alert("Введите имя пользователя!");
return false;
}
for (var i = 0; i < userNames.length; i++) {
if (userNames[i] === newName) {
result.innerHTML = "Данное имя пользователя " + userNames[i] + " уже существует. Выберите другой вариант";
success = false;
return false;
} else {
result.innerHTML = "Поздравляем, вы успешно зарегистрировались под именем " + newName;
success = true;
}
}
if (success) {
userNames.push(newName);
}
result.innerHTML += "<br />Зарегистрированные пользователи: " + userNames.sort();
}
function init() {
"use strict";
document.getElementById("btn").onclick = registerName;
Copy link
Member

Choose a reason for hiding this comment

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

4 пробела
2 пробела
выбери что-нибудь одно :)

}
onload = init;