-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
223 lines (212 loc) · 6.38 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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />
<title>dataset</title>
<script type="text/javascript" src="dataset.1.0.1.js"></script>
<style type="text/css">
body{
margin:0;
padding:0;
}
.dataset-box{
margin:0 auto;
width:95%;
}
.t-pos-center{
text-align:center;
}
h1{
font-size:55px;
text-align:center;
color:#f50;
}
h2{
font-size:20px;
font-style:normal;
}
.dataset{
padding:3px;
text-decoration:none;
background:rgb(226,226,226);
border:1px solid rgb(202,202,202);
}
a{
text-decoration:none;
}
ul{
list-style:none;
line-height:23px;
}
.code{
box-shadow:0px 0px 10px #333;
-webkit-box-shadow:0px 0px 10px #333;
-moz-box-shadow:0px 0px 10px #333;
-o-box-shadow:0px 0px 10px #333;
-webkit-border-radius:10px;
-moz-border-radius:10px;
-o-border-radius:10px;
padding:10px;
margin:10px;
}
.action-box{
overflow:auto;
overflow-x:hidden;
overflow-y:hidden;
zoom:1;
}
.action-box a{
display:block;
float:left;
margin:10px;
width:45%;
height:80px;
line-height:80px;
font-size:30px;
color:#fff;
background:#000;
text-align:center;
-webkit-border-radius:10px;
-moz-border-radius:10px;
-o-border-radius:10px;
}
.action-box a.right{
float:right;
}
.action-box a:hover{
background:#d4d4d4;
color:#000;
}
.code h2{
font-size:15px;
color:#666;
}
#J-output{
-webkit-border-radius:10px;
-moz-border-radius:10px;
-o-border-radius:10px;
background:#f50;color:#fff;padding:5px 10px;margin:5px;
}
</style>
</head>
<body>
<div class="dataset-box">
<h1 clas="t-pos-center">{dataset} <a href="https://github.com/mui-lychi/dataset" target="_blank" style="margin-left:20px;font-size:16px;">Fork me on GitHub</a></h1>
<h2 clas="t-pos-center">What is the <ins class="dataset">dataset</ins>?</h2>
<p>The dataset is a util used to get customise data(HTML tag data-attribute).It is very lightly,i hope you will enjoy it :-)</p>
<a href="ut.html" target="_blank">Test Suite</a>
<h2 clas="t-pos-center">Usage</h2>
<div class="code">
<h2>HTML: Turn this</h2>
<pre>
<div data-type="username"
data-age="23"
data-userAddress='{"province":"ZheJiang","city":"HangZhou"}'
data-company='{"china":"[\"Alipay\",\"Taobao\"]"}'
data-vip="true"
data-email="null"
data-avatars='[{"google":["img.png","img2.png"]}]'
>
</div>
</pre>
<h2>Data: You want into this</h2>
<pre>
{
type: 'username', {String}
age: 23, {Number}
userAddress: { {Object}
province: 'ZheJiang',
city: 'HangZhou'
},
vip: true, {Boolean}
email: null, {Object}
company:{ {Object}
"china":["Alipay","Taobao"]
},
avatars:[{"google":["img.png","img2.png"]}] {Object}
}
</pre>
<span style="color:#F50;">Please note that data type.</span>
<h2>So you can do this</h2>
<pre>
dataset(document.querySelectorAll('div')[0])
</pre>
<h2>OK! Try it yourself</h2>
<textarea id="data-source" style="width:80%;height:150px;">
<div data-type="username"
data-age="23"
data-userAddress='{"province":"ZheJiang","city":"HangZhou"}'
data-company='{"china":"[\"Alipay\",\"Taobao\"]"}'
data-vip="true"
data-email="null"
data-avatars='[{"google":["img.png","img2.png"]}]'
>
I'm here :-)
</div>
</textarea>
<div id="data-box">
You can change the content of the above text box.<br /><br />
</div>
<div id="data-output"></div>
<a href="javascript:void(0)" id="J-output">Try it</a>
<script type="text/javascript">
document.getElementById('J-output').onclick = function (){
var dataSource = document.getElementById('data-source').value,
dataBox = document.getElementById('data-box'),
datOutput = document.getElementById('data-output');
dataBox.innerHTML = dataSource;
var node = dataBox.getElementsByTagName('div')[0],
returnData = function (data){
var data = data || dataset(node),
html = '';
if(typeof data === 'object'){
for(i in data){
html += '<p>' + i + ': ' + (typeof data[i]==='object' && data[i] !== null ? JSON.stringify(data[i]) : data[i]) + ' <span style="color:#f50;">(Data type: ' + typeof data[i] + ')</span></p>';
}
data = html;
}
return html;
};
output = (window['JSON'] ? '<code>'+(returnData)()+'</code>' : dataset(node));
if(typeof output === 'object'){
var html = '';
for(i in output){
html += '<p>'+i+': '+output[i]+' <span style="color:#f50;">(Data type: '+typeof output[i]+')</span></p>';
}
output = html;
}
datOutput.innerHTML = '<br />' + output + '<br />' + '<br /><strong>Yea, so easy!</strong><br /><br />';
return false;
};
</script>
</div>
<img src="qrcode.png" alt="dataset qrcode" />
<p>Shooting this code to open</p>
<h2>Merits</h2>
<p>The reason why the <ins class="dataset">dataset</ins> is lightly, because the <ins class="dataset">dataset</ins> for HTML tag's [<a href="http://www.w3.org/TR/html5/global-attributes.html#embedding-custom-non-visible-data-with-the-data-attributes" target="_blank">data-attribute</a>] made simple encapsulate.</p>
<p>The <ins class="dataset">dataset</ins> solves HTML5 element.dataset dont't deal with data type problem.<span style="color:#FF5500;">Note that, HTML5 element.dataset put all the customise data are as string return.</span></p>
<p>The <ins class="dataset">dataset</ins> compatible with the lower level of the browser(Don't supported HTML5),such as IE6,IE7 and IE8.</p>
<h2>Compatible</h2>
<ul>
<li>Chrome all</li>
<li>Firefox all</li>
<li>Safari all</li>
<li>Opera all</li>
<li>IE6+</li>
<li>Windows Phone 7 IE</li>
<li>iOS Safari all</li>
<li>Android OS browser all</li>
<li>UC browser 7.9+</li>
</ul>
<div class="action-box">
<a href="dataset.js" title="download dataset.js" target="_blank">Download v1.0.1</a>
<a href="https://github.com/mui-lychi/dataSet" title="contribute code" target="_blank" class="right">Contribute on GitHub</a>
<div>
<div>
</body>
</html>