-
Notifications
You must be signed in to change notification settings - Fork 47
/
create-html-link.html
356 lines (345 loc) · 16.7 KB
/
create-html-link.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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
---
title: Create Proper HTML Link | URL Tools
layout: post
---
<html>
<head>
<!-- Meta tags common for website -->
{% include common-meta %}
<title>{{ page.title }}</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="description"
content="This is easy to use open source tool to create a valid HTML link from an existing URL." />
<meta name="keywords" content="online,tool,html,url,link,maker,builder,creator,generator,opensource" />
<!-- CSS for the site theme -->
{% include theme-css %}
<link rel="stylesheet" href="plugins/colorpicker/bootstrap-colorpicker.min.css">
<link rel="stylesheet" href="plugins/bootstrap-slider/slider.css">
<!-- Annoying IE fixes -->
{% include ie-fixes %}
<!-- Data Table Addon Styles -->
<link rel="stylesheet" href="https://tools.fromdev.com/plugins/datatables.net/dataTables.bootstrap.min.css">
</head>
<body class="hold-transition skin-green sidebar-mini">
<!-- Site wrapper -->
<div class="wrapper">
<!-- header tag from theme -->
{% include theme-header %}
<!-- Sidebar for the whole website -->
{% include theme-sidebar %}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Main content -->
<section class="content">
<div class="row">
<!-- left column -->
<div class="col-md-6">
<div class="box box-success">
<div class="box-header with-border">
<h1 class="box-title">Generate Proper HTML Link Code</h1>
</div>
<!-- /.box-header -->
<!-- form start -->
<div class="box-body">
<form role="form">
<div class="form-group">
<label for="input">URL</label>
<input class="form-control" id="input" value="" placeholder="Enter URL here" />
</div>
<div class="form-group">
<label for="linktext">Link Text</label>
<input class="form-control" id="linktext" type="text" value=""
placeholder="Enter display text for HTML link" />
</div>
<div class="form-group">
<label for="following">Link Type (DOFOLLOW / NOFOLLOW)</label>
<select id="following">
<option value="" selected="selected">Do Follow</option>
<option value="nofollow">No Follow</option>
</select>
</div>
<div class="form-group">
<label for="target">Link Open (in New / Same Window / more)</label>
<select id="target">
<option value="_self" selected="selected">Same Window [Default]</option>
<option value="_blank">New Window/Tab</option>
<option value="_parent">Immediate Parent Window/Tab</option>
<option value="_top">Top Most Parent Window/Tab</option>
</select>
</div>
<div class="form-group">
<p id="error" class="text-red"></p>
</div>
</form>
</div>
<!-- /.box-body -->
<div class="box-footer">
<div class="row">
<div class="col-xs-3">
<button type="button" class="btn btn-info" id="convert">Generate Link <i
class="fa fa-fw fa-arrow-right"></i></button>
</div>
</div>
</div>
<!-- /.box-footer -->
</div>
</div>
<div class="col-md-6">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Copy Link Here</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<div class="form-group">
<div class="form-group">
<label for="openurl">Clickable URL</label>
<div class="form-control"> <a id="openurl" target="_blank"></a></div>
<div id="linkcodecontainer" style="display: none;"><a></a></div>
</div>
<div class="form-group">
<label for="linkhtml">HTML Formatted Code For Link</label>
<textarea class="form-control" rows="3" id="linkhtml" readonly="readonly"
placeholder="HTML Formatted Code For Link"></textarea>
<span class="input-group-btn">
<button type="button" id="copy-linkhtml" class="btn btn-default btn-flat"><i
class="fa fa-copy"></i> Copy Code</button>
</span>
<span class="label label-success" id="confirm-linkhtml" style="display:none"><i
class="fa fa-check"></i> Copied</span>
</div>
</div>
</div>
<!-- /.box-body -->
</div>
</div>
</div>
</section>
<section class="content">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Recently Created Links History (Saved On Browser)</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<div id="history_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
<div id="history">Empty</div>
</div>
</div>
<!-- /.box-body -->
</div>
</section>
<section class="content">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">About HTML Link Creator Tool</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<img class="img-responsive" src="images/create-html-link.jpg"
alt="Online HTML link Generator Tool" title="Online HTML link Generator Tool">
<p>This is a free online tool to create simple HTML link code from an existing URL. The input to
this tool is a valid url and optional link text. Output of this tool is an updated HTML code
that can be used as valid HTML.</p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">What is a HTML Link?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>A HTML link is simple way to add a web page URL on a website. </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Do I Need To Enter The Link Text Always?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>The link text field is optional.</p>
<p>If you do not provide the link text we will default it to 'click here' </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Can I create a dofollow or nofollow link?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>Yes, you can select the link type option to create dofollow and nofollow links.</p>
<p>The default value for link is dofollow, this will not be added in the code since it is
default browser behavior when <code>rel</code> is not present. </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">How to create a link that open in new window?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>To create a link that opens in new window you need to select the 'Link Open' option value of
'New Window/Tab' that corresponds to html attribute <code>target='_blank'</code> </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">How To Use These Links?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>You can use these links to share on social media, blog or in emails. You can also add them to
your website or in blog comments. </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">How To Make Money Using Links and This Tool?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>There are many affiliate websites that may pay you for sharing a web page. </p>
<ul>
<li>Share an awesome product link with your friends.</li>
<li>Write a review of product on a blog.</li>
<li>Email your friends about your favorite products on a website.</li>
</ul>
</div>
<!-- /.box-body -->
</div>
</section>
{% include addthis %}
</div>
<!-- /.content-wrapper -->
{% include theme-footer %}
</div>
<!-- ./wrapper -->
{% include theme-bottom-js %}
</body>
<script src="/javascripts/fromdev-ux-addon.js"></script>
<script src="/plugins/selectOnFocus/jquery.selectOnFocus.min.js"></script>
<script src="/plugins/copyText/jquery.copyText.min.js"></script>
<script src="/javascripts/fromdev-utils.js"></script>
<script src="/plugins/datatables.net/jquery.dataTables.min.js"></script>
<script src="/plugins/datatables.net/dataTables.bootstrap.min.js"></script>
<script src="/javascripts/custom-analytics.js"></script>
<script src="/javascripts/history.js"></script>
<script>
const Page = {
request: {},
context: {
tableName: 'CREATE-HTML-LINK',
containerId: '#history',
createTableHeader: () => {
return `<thead><tr><th>Link</th><th>Type</th><th>Target</th><th>Title</th><th>Alt</th><th>Date Created</th></tr></thead>`;
},
createRow: (context) => {
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' };
return `<tr>
<td><a href='${context.url}' target='_blank'> ${context.linkText || 'Click here'}</a></td>
<td>${context.rel || 'dofollow'}</td>
<td>${context.target || ''}</td>
<td>${context.linkText || ''}</td>
<td>${context.linkText || ''}</td>
<td>${(new Date(context.timestamp).toLocaleDateString(undefined, options))}</td>
</tr>`;
}
}
};
$(document).ready(function () {
const handleConvertClick = () => {
clear();
var input = $('#input').val();
Page.request.url = input.trim();
if (isValidURL(Page.request.url)) {
processUrl(Page.request.url);
} else {
$('#error').text('Invalid input URL');
}
};
$('#convert').click(function () {
try {
handleConvertClick();
} catch (e) {
CustomAnalytics.collector.collectError(
{
eventAction: `${Page.context.tableName}-convert-click`,
message: `${JSON.stringify(Page.request)}`
},
e
);
}
});
CopyTextAddon.register('linkhtml');
$('#linkhtml').selectOnFocus();
$('#input').selectOnFocus();
$('#converters-category').addClass('active');
$('.markdown-body').attr('style', 'max-width:100%;');
History.collectAndShow(Page);
});
const createLink = ($link, context) => {
$link.attr('href', context.url);
if (context.rel) {
$link.attr('rel', context.rel);
}
if (context.target && context.target !== '_self') {
$link.attr('target', context.target);
}
$link.text(context.text);
$link.attr('title', context.text);
$link.attr('alt', context.text);
};
var processUrl = function (url) {
Page.request.rel = $('#following option:selected').val();
Page.request.target = $('#target option:selected').val();
const openUrlLink = $('#openurl');
createLink(openUrlLink, {
url: url,
rel: Page.request.rel,
text: 'Open Link (in new window)',
target: Page.request.target
});
const linkCode = $('#linkcodecontainer a');
Page.request.linkText = $('#linktext').val() || 'Click here';
createLink(linkCode, {
url: url,
rel: Page.request.rel,
target: Page.request.target,
text: Page.request.linkText
});
$('#linkhtml').val(getLinkCode(url));
History.collectAndShow(Page);
CustomAnalytics.collector.collect(
{
eventName: 'convert',
eventAction: 'click',
message: `${JSON.stringify(Page.request)}`
}
);
};
var getLinkCode = function (url) {
return $('#linkcodecontainer').html();
};
var isValidURL = function (s) {
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
return regexp.test(s);
};
var clear = function () {
$('#openurl').attr('href', '');
$('#openurl').text('');
$('#linkhtml').text('');
$('#error').text('');
$('#linkcodecontainer').empty();
$('#linkcodecontainer').html('<a></a>');
Page.request = {};
};
</script>
</html>