<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div>
<label>
<span>ИК:</span>
<input type="text" id="ic" maxlength="10">
</label>
</div>
<div>
<label>
<span>Дата:</span>
<span id="date"></span>
</label>
</div>
<div>
<label>
<span>Пол:</span>
<span id="gender"></span>
</label>
</div>
</body>
</html>
body {
font-family: Ubuntu, Tahoma, sans-serif;
font-size: 16px;
color: #444;
}
label {
display: block;
margin-bottom: 15px;
}
label > span:first-child {
display: inline-block;
width: 50px;
padding-right: 10px;
text-align: right;
}
input, label > span:last-child {
background: none;
border: 1px solid #dcdcdc;
display: inline-block;
padding: 5px;
width: 150px;
font-family: inherit;
text-align: center;
font-size: 14px;
height: 15px;
vertical-align: middle;
}
label > span:last-child {
border-width: 0 0 1px 0;
}
var month = "Января,Февраля,Марта,Апреля,Мая,Июня,Июля,Августа,Сентября,Остября,Ноября,Декабря".split(",");
var source = document.querySelector("#ic");
var birth = document.querySelector("#date");
var gender = document.querySelector("#gender");
function Parser(code) {
var isValid = /\d{10}/.test(code) && (code[9] == ((2 * code[0] + 4 * code[1] + 10 * code[2] + 3 * code[3] + 5 * code[4] + 9 * code[5] + 4 * code[6] + 6 * code[7] + 8 * code[8]) % 11) % 10);
this.birth = function() {
if (!isValid) return "";
var date = new Date(new Date("1900 1 1").getTime() + ((code.substr(0, 5) - 1) * 24 * 60 * 60 * 1000));
return date.getDate() + " " + month[date.getMonth()] + " " + date.getFullYear();
}
this.gender = function() {
if (!isValid) return "";
return code.substr(8, 1) % 2 ? "мужской" : "женский";
}
}
source.addEventListener("keyup", function() {
var parser = new Parser(this.value);
birth.innerText = parser.birth();
gender.innerText = parser.gender();
});
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |