Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: bd3db54ca4
Fetching contributors…

Cannot retrieve contributors at this time

277 lines (237 sloc) 8.887 kb
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<title>在线密码生产器 | Password Generator Online</title>
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="http://leegorous.net/css/bootstrap/2.0.3/css/bootstrap.min.css" />
<link rel="stylesheet" href="http://leegorous.net/css/bootstrap/2.0.3/css/bootstrap-responsive.min.css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
body {
background: #6ab3f6;
padding: 20px 0;
}
.pwd-text {
font-family: Monaco, Consolas, "DejaVu Sans Mono", "Courier New", Courier, monospace;
}
.page-wrap {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
.container {
background: #fff;
min-width: 940px !important;
}
.headline {
text-align: center;
margin: 40px 0 36px 0;
color: #aaa;
}
.desc {
text-align: center;
color: #666;
}
.desc code {
font-size: 18px;
cursor: pointer;
display: inline-block;
}
.desc .enabled:hover,
.desc .disabled {
text-decoration: none;
}
.desc .disabled {
color: #bbb;
}
.desc .disabled:hover,
.desc .enabled {
text-decoration: none;
}
.desc .enabled {
color: #D14;
}
.rule {
font-size: 18px;
}
.tooltip {
font-size: 12px;
}
.form-generator {
text-align: center;
padding: 20px 0 25px 0;
}
.btn-huge {
font-size: 64px;
padding: 20px 64px;
line-height: normal;
-webkit-border-radius: 64px;
-moz-border-radius: 64px;
border-radius: 64px;
}
.input-huge {
width: 570px;
font-size: 72px;
line-height: normal;
height: auto;
padding: 10px;
margin: 25px;
text-align: center;
-webkit-border-radius: 16px;
-moz-border-radius: 16px;
border-radius: 16px;
}
.footer {
text-align: center;
padding: 20px 0 30px 0;
border-top: 1px solid #E5E5E5;
}
.len {
display: inline-block;
border-radius: 4px;
background: #ccc;
padding: 8px;
font-size: 24px;
color: #fff;
cursor: pointer;
}
.len:hover, .len-selected {
background: #999;
}
</style>
</head>
<body>
<div class="container page-wrap">
<header class="headline">
<h1>在线密码生成器</h1>
<p class="lead">Password Generator</p>
</header>
<section class="desc">
<p class="lead rule pwd-text">
密码规则: 由 <code class="include enabled" group="0">a-z</code>, <code class="include enabled" group="1">A-Z</code>, <code class="include enabled" group="2">0-9</code>, <code class="include enabled" group="3">!@#$%^&amp;*+-=_</code> 组成; 不包含 <code class="exclude enabled">o, O, 0, l, I, 1</code>; 随机
</p>
<p>完全不涉及,不收集任何个人信息,运算过程由 JavaScript 在浏览器内完成,可安全离线使用</p>
</section>
<div class="form-generator">
<input class="btn btn-success btn-huge" id="gen-btn" type="button" value="产生新密码" />
<div>
<input class="input-huge pwd-text" id="result" type="text"/>
<div class="lens">
<span class="len">6位</span>
<span class="len">7位</span>
<span class="len len-selected">8位</span>
<span class="len">10位</span>
<span class="len">16位</span>
</div>
</div>
</div>
<footer class="footer">
<p>Build by <a href="http://weibo.com/leegorous">@leegorous</a>. This page licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p><a href="http://leegorous.net/"><i class="icon-home"></i> leegorous.net</a></p>
</footer>
</div>
<!--[if lt IE 9]>
<script src="http://leegorous.net/js/ie-patch.min.js"></script>
<![endif]-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://leegorous.net/css/bootstrap/2.0.3/js/bootstrap-tooltip.js"></script>
<script>
$(document).ready(function() {
function verticalCenter(el) {
var max = $(window).height();
if (el.height() + 40 >= max) return;
$(document.body).css('padding', Math.floor((max - el.height()) / 2) + 'px 0');
}
verticalCenter($('.container:first'));
var tmpl = ["abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "0123456789", "!@#$%^&*+-=_"],
excludedChar = ['l', 'o', 'I', 'O', '0', '1'], rules = tmpl, allChar;
function getRules() {
var arr = [];
$('.include').each(function(i, it) {
it = $(it), group = it.attr('group');
if (it.hasClass('enabled')) arr.push(tmpl[group]);
});
return arr;
}
function getExcludedRules() {
return $('.exclude.enabled').length === 1 ? excludedChar : [];
}
function getAllChar(rules) {
var s = rules.join(''), ex = getExcludedRules();
for(var i = ex.length - 1; i >= 0; i--) {
s = s.split(ex[i]).join('');
}
return s;
}
function updateAllChar() {
rules = getRules();
allChar = getAllChar(rules);
}
function randomStr(str, maxLen) {
var arr = [], len = str.length;
while(arr.length < maxLen) {
arr.push(str.charAt(Math.floor(Math.random() * len)));
}
return arr.join('');
}
function generate() {
var pwd, len = parseInt($('.len-selected').text()) || 8;
function contain(str) {
return function (target) {
for (var i = target.length - 1; i>= 0; i--) {
if (str.indexOf(target.charAt(i)) != -1) return true;
}
return false;
};
}
updateAllChar();
while (!rules.every(contain(pwd = randomStr(allChar, len)))) {};
return pwd;
}
$('#gen-btn').click(function() {
var result = $('#result'), pwd = generate();
result.val(pwd);
result.animate({'width': (pwd.length === 16 ? '770px' : '570px')}, 600);
try {
result.focus();
result[0].select();
} catch(e) {}
});
function toggleRuleStatus(el) {
if (el.hasClass('enabled')) {
el.attr('title', '点击 启用 规则');
} else {
el.attr('title', '点击 禁用 规则');
}
el.tooltip('show');
el.toggleClass('enabled');
el.toggleClass('disabled');
}
$('.include').click(function() {
var el = $(this);
if ($('.include.enabled').length === 1 && el.hasClass('enabled')) return;
toggleRuleStatus(el);
var enabledRules = $('.include.enabled');
if (enabledRules.length === 1) enabledRules.tooltip('disable');
else enabledRules.tooltip('enable');
$('#gen-btn').click();
});
$('.exclude').click(function() {
toggleRuleStatus($(this));
$('#gen-btn').click();
});
$('.lens').delegate('.len', 'click', function() {
$('.len').removeClass('len-selected');
$(this).addClass('len-selected');
$('#gen-btn').click();
});
$('.rule code').tooltip({'title': '点击 禁用 规则'});
$('.rule code:eq(1)').tooltip('show');
});
</script>
<script src="http://leegorous.net/js/ga-track.min.js"></script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.