-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
261 lines (215 loc) · 8.58 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="lib/themes/vue.css">
<link rel="stylesheet" href="lib/css/gitalk.css">
<link rel="stylesheet" href="lib/css/index.css">
</head>
<body>
<div id="app"></div>
<script src="lib/plugins/gitalk.min.js"></script>
<script>
window.$docsify = {
name: 'WIT-Learner',
loadSidebar: true,
mergeNavbar: true,
coverpage: true,
repo: 'https://github.com/wantstudy/docs/',
loadNavbar: true,
loadNavbar: 'nav.md',
mergeNavbar: true,
subMaxLevel: 4,
auto2top: true,
search: {
maxAge: 86400000, // 过期时间,单位毫秒,默认一天
paths: 'atuo', // or 'auto'
placeholder: 'Type to search',
// 支持本地化
placeholder: {
'/': 'Type to search'
},
noData: 'No Results!',
// 支持本地化
noData: {
'/': 'No Results'
},
// 搜索标题的最大程级, 1 - 6
depth: 2
},
disqus: 'shortname',
plugins: [
function (hook) {
var footer = [' <div id="gitalk-container"></div>',].join('')
hook.afterEach(function (html) {
return html + footer
})
hook.doneEach(function() {
// 每次路由切换时数据全部加载完成后调用,没有参数。
var path = window.location.href.split('#')[1];
if(path != '/' && path != '/start'){
loadTalk(path);
}
})
}
]
}
</script>
<!--聊天室-->
<div class="chat-container">
<div class="chat-btn" type="0"></div>
<div class="title">交流会</div>
<ul id="messages" class="chat-message"></ul>
<form action="" class="chat-form">
<textarea id="chat_content" name="chat_content" class="chat-input"></textarea>
<span class="emotion"><img src="lib/image/bq.png" ></span>
<button class="chat-btton">发 送</button>
</form>
</div>
<script src="lib/docsify.min.js"></script>
<script src="lib/plugins/search.js"></script>
<script src="lib/plugins/ga.js"></script>
<script src="lib/plugins/zoom-image.js"></script>
<script src="//unpkg.com/docsify-copy-code"></script>
<script src="lib/plugins/disqus.min.js"></script>
<script src="lib/plugins/gitalk.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
<!--<script src="https://code.jquery.com/jquery-1.11.1.js"></script>-->
<script src="lib/plugins/jquery.min.js"></script>
<script src="lib/plugins/jquery.qqFace.js"></script>
<script>
$(function () {
var gitname = window.localStorage['real-name'];
if(!gitname){
gitname = '游客'+new Date().getTime().toString().substring(5);
window.localStorage['real-name']=gitname;
}
var socket = io('47.93.232.108:3001?gitname='+gitname);
//var socket = io('192.168.1.12:3001?gitname='+gitname);
var data ={};
$('form').submit(function(){
data.username = gitname;
data.msg = replace_em($('#chat_content').val());
if(!data.msg){return;};
var html =
'<li class="fr animate-r-s">' +
' <label class="fr head"><img src="lib/image/head.jpg"></label>' +
' <label class="con-label fr"><span class="name fr">'+data.username+'</span><span class="msg fr">'+data.msg+'</span></label>' +
'</li>';
$('#messages').append(html);
setTimeout(function () {
$('#messages li').css('transform', 'translateX(0px)');
},50);
scrHeight();
socket.emit('chat message', data);
$('#chat_content').val('');
// $('#m').css('height', '35px');
return false;
});
socket.on('conn', function(data){
var html = '<li class="chat-info"><span>'+data.msg+'</span></li>';
$('#messages').append(html);
scrHeight();
});
socket.on('disconn', function(data){
var html = '<li class="chat-info"><span>'+data.msg+'</span></li>';
$('#messages').append(html);
scrHeight();
});
socket.on('chat message', function(data){
var html = '';
if(data.username == localStorage.getItem('real-name')){
html +=
'<li class="fr animate-r-s">' +
' <label class="fr head"><img src="lib/image/head.jpg"></label>' +
' <label class="con-label fr"><span class="name fr">'+data.username+'</span><span class="msg fr">'+data.msg+'</span></label>' +
'</li>';
}else{
html +=
'<li class="fl animate-l-s">' +
' <label class="fl head"><img src="lib/image/head.jpg"></label>' +
' <label class="con-label fl"><span class="name fl">'+data.username+'</span><span class="msg fl">'+data.msg+'</span></label>' +
'</li>';
}
$('#messages').append(html);
setTimeout(function () {
$('#messages li').css('transform', 'translateX(0px)');
},50);
scrHeight();
});
$('.chat-btn').click(function () {
var _this = this;
if($(_this).attr('type') == 0){
$(_this).attr('type', 1);
$(_this).css('background-image', 'url(lib/image/btn-right.png)');
$('div.chat-container').css('transform', 'translateX(0)');
}else{
$(_this).attr('type', 0);
$(_this).css('background-image', 'url(lib/image/btn-left.png)');
$('div.chat-container').css('transform', 'translateX(104%)');
}
});
$('#chat_content').keyup(function(event){
if(event.which == 13){
$('form').submit();
}
//textareHei(this);
});
/* $('#m').blur(function(event){
var _this = this;
textareHei(_this);
});*/
$('span.emotion').qqFace({
id : 'facebox',
assign:'chat_content',
path:'lib/image/arclist/' //表情存放的路径
});
});
function textareHei(_this) {
if(_this.scrollHeight <= 118 && _this.scrollHeight >= 35){
$(_this).css('height', _this.scrollHeight + 'px');
}else if (_this.scrollHeight > 118){
$(_this).css('height', '118px');
}else if(_this.scrollHeight <= 35){
$(_this).css('height', '35px');
}
if(!$(_this).val()){
$(_this).css('height', '35px');
}
$('#messages').css('height', (490 - $(_this).parent().height()) + 'px');
}
function replace_em(str){
str = str.replace(/\</g,'<');
str = str.replace(/\>/g,'>');
str = str.replace(/\n/g,'<br/>');
str = str.replace(/\[em_([0-9]*)\]/g,'<img src="lib/image/arclist/$1.gif" border="0" />');
return str;
}
function scrHeight() {
var scrollDom = document.getElementById('messages');
scrollDom.scrollTop = scrollDom.scrollHeight;
}
</script>
<script src="lib/plugins/disqus.min.js"></script>
<script type="text/javascript">
var gitalk ;
function loadTalk(path){
gitalk = new Gitalk({
id : path,
clientID: '3166bd7720c1a2e35cc2',
clientSecret: '117bf872afbc09e8efea2c0935d43ef8ebf55029',
repo: 'docs',
owner: 'wantstudy',
admin: ['wantstudy', 'WL-XIN'],
// facebook-like distraction free mode
distractionFreeMode: false
})
gitalk.render('gitalk-container');
}
</script>
</body>
</html>