/
index.html
256 lines (226 loc) · 6.05 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
<!DOCTYPE html>
<html>
<head>
<title>jQuery Link Classifier</title>
<link rel="stylesheet" href="font/entypo.css">
<link href='http://fonts.googleapis.com/css?family=Average+Sans|Arbutus+Slab|Share+Tech+Mono' rel='stylesheet' type='text/css'>
<style>
@font-face {
font-family: 'entypo';
src: url('font/entypo.eot');
src: url('font/entypo.eot?#iefix') format('embedded-opentype'),
url('font/entypo.woff') format('woff'),
url('font/entypo.ttf') format('truetype'),
url('font/entypo.svg#entypo') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'entypo-social';
src: url('font/entypo-social.eot');
src: url('font/entypo-social.eot?#iefix') format('embedded-opentype'),
url('font/entypo-social.woff') format('woff'),
url('font/entypo-social.ttf') format('truetype'),
url('font/entypo-social.svg#entypo-social') format('svg');
font-weight: normal;
font-style: normal;
}
body {
background: #ddd;
font-family: 'Average Sans';
}
p {
font-family: 'Arbutus Slab';
}
pre,
#links {
font-family: 'Share Tech Mono';
}
.wrapper {
width: 640px;
}
a {
font-size: 1em;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:after,
a:before {
line-height: 1em;
}
/* protocols */
a.irc:before {
font-family: 'entypo';
font-size: 1.5em;
content: '\e720';
margin-right: 0.1em;
display: inline-block;
}
a.mailto:before {
font-family: 'entypo';
font-size: 1.5em;
content: '\2709';
margin-right: 0.1em;
display: inline-block;
}
a.https:after {
font-family: 'entypo';
font-size: 1.5em;
color: #daa520;
content: '\1f512';
margin-left: 0.1em;
display: inline-block;
}
a.ftp:before {
font-family: 'entypo';
font-size: 1.5em;
content: '\1f4be';
margin-right: 0.1em;
display: inline-block;
}
/* */
a.in-page:after {
font-family: 'entypo';
font-size: 1.5em;
color: #0c0;
content: '\1f516';
margin-left: 0.1em;
display: inline-block;
}
a.external:after {
font-family: 'entypo';
font-size: 1.5em;
color: #e00;
content: '\1f30e';
margin-left: 0.1em;
display: inline-block;
}
/* file type */
a.gif:before,
a.png:before,
a.jpeg:before,
a.jpg:before {
font-family: 'entypo';
font-size: 1.5em;
content: '\1f304';
margin-right: 0.1em;
display: inline-block;
}
/* sites */
a.github:before {
font-family: 'entypo-social';
font-size: 1.5em;
content: '\f300';
margin-right: 0.1em;
display: inline-block;
}
a.gplus:before {
font-family: 'entypo-social';
font-size: 1.5em;
content: '\f30f';
margin-right: 0.1em;
display: inline-block;
}
a.facebook:before {
font-family: 'entypo-social';
font-size: 1.5em;
content: '\f30c';
margin-right: 0.1em;
display: inline-block;
}
a.flickr:before {
font-family: 'entypo-social';
font-size: 1.5em;
content: '\f303';
margin-right: 0.1em;
display: inline-block;
}
a.twitter:before {
font-family: 'entypo-social';
font-size: 1.5em;
content: '\f309';
margin-right: 0.1em;
display: inline-block;
}
/* fixes */
a.external.https:after {
font-family: 'entypo';
font-size: 1.5em;
color: #daa520;
content: '\1f30e\1f512';
margin-left: 0.1em;
display: inline-block;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.link.classifier.js"></script>
<script>
function addlink() {
var link = $('#link').val();
$('<br/>').prependTo($('#links'));
var $a = $('<a/>')
.attr('href', link)
.text(link)
.linkcls()
.prependTo($('#links'))
;
$('<span/>')
.text(' (' + $a.attr('class') + ')')
.insertAfter($a)
;
}
$(function () {
$('a').linkcls();
var html = $('.wrapper').html();
var re = /<a.*?>.*?<\/a>/g;
var match;
while (match = re.exec(html))
$('<span/>')
.text(match[0] + '\n')
.appendTo($('#a-source'))
;
$('#link').keyup(function (evt) {
if (evt.keyCode == 13)
addlink();
})
});
</script>
</head>
<body>
<h1>jQuery Link Classifier</h1>
<h2>Introduction</h2>
<div class='wrapper'>
<p>
<a href='https://github.com/livibetter/jquery.link.classifier.js'>jQuery Link Classifier</a> adds classes to links based on their URLs. The most possible usage is for identifying external links, like links listed in <i>External links</i> section on <a href='http://en.wikipedia.org/wiki/Wikipedia#External_links'>Wikipedia</a>.
</p>
<p>
<span style='font-family: entypo; font-size: 2em; line-height: 1em; color: red;'></span>This plugin does nothing with representation or visualization of link, it only adds classes, and that's all what it does. You will need to handle CSS and/or JavaScript on your own.
</p>
<p>
The protocol (scheme) is extracted from the URL, for examples, FTP of <a href='ftp://ftp.kernel.org/pub/'>Linux Kernel</a>, IRC of <a href='irc://irc.gentoo.org/gentoo'>#gentoo</a>, and an email link <a href='mailto:someone@example.com'>someone@example.com</a>. It can also add class for file extensions, such as an image file of <a href='http://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png'>Tux</a>. A set of regular expressions are used for identifying some popular websites, such as <a href='http://twitter.com'>Twitter</a>, <a href='http://facebook.com/'>Facebook</a>, or <a href='http://plus.google.com/'>Google+</a>. Or a bookmark to <a href='#try-a-link'>next section</a>.
</p>
<p>
HTML of links in this section after process by this plugin, the original HTML source of these links do not have any classes specified:
<pre id='a-source'></pre>
</p>
</div>
<h2>More information</h2>
<div>
<p>See <a href='https://github.com/livibetter/jquery.link.classifier.js'>project website</a> for detail information.</p>
</div>
<h2 id='try-a-link'>Try a link</h2>
<div>
<p><input id='link' type='text' value='http://example.com/'/> <button onclick='addlink()'>Add</button></p>
<div id='links'></div>
</div>
<div id='footer'>
<p>
Made by <a href='http://yjl.im/'>Yu-Jie Lin</a>
•
Entypo pictograms by Daniel Bruce — <a href='http://www.entypo.com'>www.entypo.com</a>
</p>
</div>
</body>
</html>