-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
106 lines (96 loc) · 3.28 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html>
<head>
<title>genPass</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./css/weui.min.css"/>
<script type="text/javascript" src="./js/zepto.min.js"></script>
<script type="text/javascript" src="./js/md5.min.js"></script>
<script type="text/javascript" src="./js/sha256.min.js"></script>
<script>
$(function(){
var $sliderTrack = $('#sliderTrack'),
$sliderHandler = $('#sliderHandler'),
$sliderValue = $('#sliderValue');
var totalLen = $('#sliderInner').width(),
startLeft = 0,
startX = 0;
$sliderHandler
.on('touchstart', function (e) {
startLeft = parseInt($sliderHandler.css('left')) * totalLen / 100;
startX = e.changedTouches[0].clientX;
})
.on('touchmove', function(e){
var dist = startLeft + e.changedTouches[0].clientX - startX,
percent;
dist = dist < 0 ? 0 : dist > totalLen ? totalLen : dist;
percent = parseInt(dist / totalLen * 100);
$sliderTrack.css('width', percent + '%');
$sliderHandler.css('left', percent + '%');
$sliderValue.text(parseInt(8+percent*24/100));
e.preventDefault();
})
;
$( "#genButton" ).on("tap click",function( e ){
websiteString = $("#websiteText").val();
customString = $("#customText").val();
shaString = sha256(websiteString);
shaString = sha256(shaString+customString);
md5String = md5(shaString);
digit = parseInt($("#sliderValue").text());
$("#pwd").html(md5String.substring(0,digit));
document.getElementById('customText').type = 'password';
});
$("#customText").on("focusin", function(e){
document.getElementById('customText').type = 'text';
});
$("#customText").on("focusout", function(e){
document.getElementById('customText').type = 'password';
});
});
</script>
</head>
<body>
<div class="ui-container">
<div class="weui-cells__title">Website:</div>
<div class="weui-cells">
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="text" class="weui-input" id="websiteText">
</div>
</div>
</div>
<div class="weui-cells__title">Custom string:</div>
<div class="weui-cells">
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="password" class="weui-input" id="customText">
</div>
</div>
</div>
<div class="weui-cells__title">Digit:</div>
<div class="weui-slider-box">
<div class="weui-slider">
<div id="sliderInner" class="weui-slider__inner">
<div id="sliderTrack" style="width: 50%;" class="weui-slider__track"></div>
<div id="sliderHandler" style="left: 50%;" class="weui-slider__handler"></div>
</div>
</div>
<div id="sliderValue" class="weui-slider-box__value">16</div>
</div>
<div class="weui-cells">
<a id="genButton" class="weui-btn weui-btn_primary">generate password</a>
</div>
<div class="weui-cells__title">Password:</div>
<div class="weui-cells">
<div class="weui-cell">
<div class="weui-cell__bd">
<!-- <input type="text" class="weui-input" id="pwd"> -->
<span id="pwd"></span>
</div>
</div>
</div>
</div>
</body>
</html>