-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
132 lines (111 loc) · 2.97 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>jQeury QQ表情 插件</title>
<meta name="description" content="">
<meta name="keywords" content="">
<style type="text/css">
#box{
width: 450px;
height: 200px;
position: absolute;
}
a{
color: #333;
text-decoration: none;
}
#liveChatContent{
width: 400px;
height: 100px;
outline: none;
}
#face{
display: inline-block;
width: 100px;
height: 30px;
line-height: 30px;
border:1px solid #999;
background: #f3f3f3;
text-decoration: none;
text-align: center;
border-radius: 3px;
}
#box.a1{
left: 10px;
top: 0;
}
#box.a2{
right: 10px;
top: 0;
text-align: right;
}
#box.a3{
left: 10px;
bottom: 10px;
}
#box.a4{
right: 10px;
bottom: 10px;
text-align: right;
}
</style>
</head>
<body>
<div id="box" class="a1">
<p>
<a class="pos" href="javascript:;" data-index="1">位置1</a>
<a class="pos" href="javascript:;" data-index="2">位置2</a>
<a class="pos" href="javascript:;" data-index="3">位置3</a>
<a class="pos" href="javascript:;" data-index="4">位置4</a>
</p>
<div>
<textarea id="liveChatContent" spellcheck="false"></textarea>
</div>
<a href="javascript:;" id="face">表情</a>
<span id="left"></span>
</div>
<script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.qqface.min.js"></script>
<script type="text/javascript">
var oldLength = '';
$('#liveChatContent').on('change keydown keyup input', function(event) {
var textarea = $(this);
var value = $(this).val();
var length = getLenth(value);
if (length > 200) {
textarea.val(oldLength);
} else {
oldLength = value;
$('#left').html('还可以输入'+ (200 -length) + '个字符');
}
});
function getLenth(str) {
str = str.replace(/\[:([\s\S]+?)\]/g, 'F'); //把所有表情都变成F,一个字符
str = str.replace(/[\u4e00-\u9fa5]/g, 'CN'); //把所有表情都变成F,一个字符
return str.length;
}
$.qqface({
before : function(textarea, code){
var value = textarea.val();
var length = getLenth(value);
return length < 199;
}, //要在插入之前执行
after: function(textarea, code){
var value = textarea.val();
var length = getLenth(value);
$('#left').html('还可以输入'+ (200 -length) + '个字符');
$('#liveChatContent').change();
}, //在插入之后执行
imgPath : 'gif/',
textarea : $('#liveChatContent'),
handle : $('#face')
});
$('a.pos').on('click', function(){
var index = $(this).data('index');
$('#box').attr('class', 'a' + index);
});
</script>
</body>
</html>