-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitlyit_demo.html
52 lines (46 loc) · 1.58 KB
/
bitlyit_demo.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
<html>
<head>
<title>Bitlyit</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajaxSetup({
cache:false
});
// grab the URL
$('a#shortenit').click(function() {
var longUrl = $('input#longUrl').val();
// check to make sure the URL is legit
if (-1 == longUrl.indexOf('http://')){
alert('Your URL must include http://');
return false;
} else {
// proceed on with the ajax-ing
$('p#status').html('getting your link...');
$.post('ajax_bitly.php'
, { 'url':longUrl }
, function(data) {
if (data != null) {
var outputDiv = $('p#bitlyurl span');
$('p#status').html('success!');
$(outputDiv).html('<a href="'+ data +'" target="_blank">'+ data + '</a>');
$('p#bitlyurl').show();
} else {
$('p#status').html('<strong>Failure.</strong> Make sure your <a href="http://bit.ly/a/your_api_key" target="_blank">bitly API username and key</a> are correct on line 25 of ajax_bitly.php');
}
});
}
});
});
</script>
</head>
<body>
<h1>Shorten your URL with <a href="#">bitlyit</a></h1>
<p>Enter your long URL here:</p>
<input type="text" id="longUrl" value="http://www.playlookit.com" />
<a href="#" id="shortenit">Shorten this URL!</a>
<br /><br />
<p id="status"></p>
<p id="bitlyurl" style="display:none;">Your shortened URL is: <span style="font-weight:bold;"></span></p>
</body>
</html>