1.html
2.69 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>asdfa</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body>
<div>
<div id="test">请初始化。</div>
<hr>
<a href="javascript:TIPS.init('#test');">初始化 TIPS.init('#test')</a>
<a href="javascript:TIPS.voiceStart()">开始保存语音</a>
<a href="javascript:TIPS.voiceDone();">语音保存成功</a>
<a href="javascript:TIPS.voiceError();">语音保存失败,请重新保存。</a>
<a href="javascript:TIPS.codeStart();">开始保存代码</a>
<a href="javascript:TIPS.codeDone();">代码保存成功</a>
<a href="javascript:TIPS.codeError();">代码保存错误,请重新保存</a>
<a href="javascript:TIPS.rebuild();">重置</a>
</div>
<script type="text/javascript">
var TIPS = {
container: null,
template: $('<div id="tips"><span id="voice"></span><span id="code"></span></div>'),
content: {
voice: {
start: "语音保存中...",
done: "语音保存成功",
error: "语音保存失败,请重新保存。"
},
code: {
start: "代码保存中...",
done: "代码保存成功",
error: "代码保存错误,请重新保存"
}
},
init: function(obj) {
if(!obj){ console.info('请输入:TIPS.init(\'body\')'); return false; }
this.container = obj;
$(this.container).html(this.template);
},
voiceStart: function(string){
var _dom = this.template.find('#voice');
string ? _dom.html(string) : _dom.html(this.content.voice.start);
},
voiceDone: function(string){
var _dom = $(this.template).find('#voice');
string ? _dom.html(string) : _dom.html(this.content.voice.done);
},
voiceError: function(string){
var _dom = $(this.template).find('#voice');
string ? _dom.html(string) : _dom.html(this.content.voice.error);
},
codeStart: function(string){
var _dom = $(this.template).find('#code');
string ? _dom.html(string) : _dom.html(this.content.voice.start);
},
codeDone: function(string){
var _dom = $(this.template).find('#code');
string ? _dom.html(string) : _dom.html(this.content.voice.done);
},
codeError: function(string){
var _dom = $(this.template).find('#code');
string ? _dom.html(string) : _dom.html(this.content.voice.error);
},
rebuild: function(){
this.template.find('#voice').html('');
this.template.find('#code').html('');
}
}
</script>
</body>
</html>