-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
161 lines (151 loc) · 4.76 KB
/
index.html
File metadata and controls
161 lines (151 loc) · 4.76 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>王者荣耀改名</title>
<style>
*{margin:0;padding:0;}
html,body{width:100%;height:100%;position:relative;}
.ipt-wrap{width:510px;overflow:hidden;margin:0 auto; padding-top: 60px;}
.ipt{width:400px;height:48px;text-align:center;font-size:18px;outline:none;float:left;border:1px solid #38f;}
.btn{font-size:18px;height:50px;width:100px;text-align:center;background-color:#38f;color:#FFF;outline:none;border:1px solid #38f;float:left;}
.tips{color:#38f;text-align:center;margin:0 auto;padding-top:150px;font-size:18px;}
.res-list-wrap{
width: 620px;
margin: 0 auto;
padding-top: 50px;
display: none;
}
.res-list{
list-style: none;
overflow: hidden;
}
.res-item{
float: left;
width: 150px;
height: 40px;
line-height: 40px;
color: #38f;
border: 1px solid #f1f1f1;
}
.res-ipt{
display: block;
width: 100%;
height: 100%;
text-align: center;
font-size: 16px;
border: none;
}
.res-tips{
color:#333;
padding: 20px 0;
}
em{
color: #F00;
}
.fenge{
height:20px;
padding:10px 0;
width:100%;
text-align: center;
}
</style>
</head>
<body>
<p class="tips">温馨提示: 请不要超过游戏里面规定最大字符长度(6个中文字或者是12个英文字符)</p>
<div class="ipt-wrap">
<input type="text" class="ipt" placeholder="输入您想改的名字: 如 王思聪" id="Jipt" >
<button class="btn" id="Jbtn">确定</button>
</div>
<div class="res-list-wrap" id="Jres">
<p class="res-tips"> 以下是经过特殊处理的名字,每一个都<em>不一样</em> : 选中复制即可</p>
<ol class="res-list" id="Jol"></ol>
<div class="fenge">-------对照插入的位置-------</div>
<ol class="res-list" id="Yol"></ol>
</div>
<script>
// 工具函数
var _word = [];
function transfer(str) {
str = str.replace(/\\/g, "%");
return unescape(str);
}
function clone(obj){
var tmp ;
tmp = [];
var len = obj.length;
for (var i = 0; i < len; i++) {
tmp[i]=obj[i];
}
return tmp;
}
function rdIndex(length){
return Math.floor(Math.random()*(length))
}
function gen(v){
var pre = v.split('#'); //原始值
// console.log(pre,"pre");
var demand = 0;
if (pre.length>1) {
var o = pre[0].split('')
//typeof NaN === 'number'
!!+pre[1] ? (demand = pre[1]) :(demand = 3);
}else{
var o = v.split('');
demand = 3;
}
// 按需求插入个数
for (var i = 0; i <demand; i++) {
var index = rdIndex(o.length+1);
// 随机取一个字符插入, PS, 一旦选出, _clone会被修改, 必须还原
var _clone = clone(spStr);
var _pick = _clone.splice(rdIndex(_clone.length),1).toString();
// console.log(escape(_pick),"_pick");
o.splice(index,0,_pick); // o都原始值会被修改
var res = transfer(o.join(''));
}
_word.push(unescape(escape(res).replace(/(%u2060)|(%u2061)|(%u2062)|(%u2063)/g,"*")));
console.log('最终值:',escape(res));
// console.log(_word);
return res;
}
function genEmpty(){
// 全空白
var arr = [];
for (var i = 0; i <6; i++) {
var _clone = clone(spStr);
var _pick = _clone.splice(rdIndex(_clone.length),1).toString();
arr.push(_pick)
}
var res = arr.join('');
_word.push(unescape(escape(res).replace(/(%u2060)|(%u2061)|(%u2062)|(%u2063)/g,"*")));
console.log(res,"res");
return res;
};
// var spStr = ['\u200a','\u2060','\u2061','\u2062','\u2063'];
var spStr = ['\u2060','\u2061','\u2062','\u2063'];
// var spStr = ['\u2060','\u2061','\u2062','\u2063','\u2064','\u2065','\u2066','\u2067','\u2068','\u2069'];
// var spStr = ['\u202a','\u202b','\u202c','\u202d','\u202e','\u200b','\u200c','\u200d',,'\u200e','\u200f'];
// var spStr = ['\u206a','\u206b','\u206c','\u206d','\u206e','\u206f'];
Jbtn.addEventListener('click',function(){
var v = Jipt.value.trim();
if(!!v){
var _html = '', _whtml = '';
for (var i = 0; i < 12; i++) {
_html+='<li class="res-item"><input class="res-ipt" type="text" value="'+ (v.indexOf('$')>-1 ? genEmpty(): gen(v))+'"></li>';
};
for (var i = 0; i < 12; i++) {
_whtml+='<li class="res-item"><input class="res-ipt" type="text" value="'+ _word[i] +'"></li>';
}
Jol.innerHTML = _html;
Yol.innerHTML = _whtml;
Jres.style.display="block";
}else{
alert('不能为空!')
}
})
</script>
</body>
</html>
<!-- $ ----代表全空白名 -->
<!-- # ----代表需要插入几个字符 -->