-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathID-Gen.html
46 lines (46 loc) · 1.72 KB
/
ID-Gen.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>ID-Generate</title>
</head>
<body>
<button onclick="gen()">开始生成</button><br>
<span id="layout">输出:</span><br>
<a href="https://github.com/i-am-a-loser-using-windows-server/PRC-ID-Generate" target="__blank">GitHub</a>
<script type="text/javascript">
function gen(){
var date = new Date();
var locale = prompt("指定地区编码(5位数)","");
var year = prompt("指定出生年份(0000-"+date.getFullYear()+"):",date.getFullYear());
var month = prompt("指定出生月份(01-12):",date.getMonth()+1);
if(month.length == 1){month="0"+month;}
var day = window.prompt("指定出生日期(01-31):",date.getDate());
if(day.length == 1){day="0"+day;}
var num = window.prompt("指定出生顺序(00-99):","00");
var sex = window.prompt("指定性别(0-9):","1");
var conf = window.confirm("确定生成?");
if(conf == false){
window.alert("错误:用户取消!");
return;
}else{
var id_str = locale.toString() + year.toString()+month.toString()+day.toString()+num.toString()+sex.toString();
if(id_str.length != 17){
window.alert("错误:格式错误(非17位)");
}
var temp;
var code = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
var conf_cod=0;
for(var i=0;i<17;i++){
var temp = id_str.slice(i,i+1);
temp=temp*code[i];
conf_cod = conf_cod+temp;
}
var conf_remark = [1,0,'X',9,8,7,6,5,4,3,2];
var layout=document.getElementById("layout");
layout.innerHTML = "输出:"+id_str+conf_remark[conf_cod%11];
}
}
</script>
</body>
</html>