-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathform.html
71 lines (63 loc) · 1.67 KB
/
form.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/style.css" rel="stylesheet" media="screen">
<title>shtfy</title>
</head>
<body>
<div class="shtfy-container">
<div class="shtfy-search">
<h1>
shtfy
<span class="about">
<a href="about.html">
about
</a>
</span>
</h1>
<form action="shorten/" method="get" class="input-append">
<input id="longurl" name="url" type="text" class="span2">
<input type="submit" class="btn">
</form>
<ul id="shorturls" class="unstyled">
</ul>
</div>
</div>
<script src="js/jquery-1.9.1.min.js"></script>
<script>
var form = $("form");
form.on("submit", function(e) {
e.preventDefault();
var longurl = $("#longurl").val();
if (!longurl)
return;
var request = $.ajax({
url: form.attr("action"),
data: { url: longurl }
});
request.done(function (response) {
var input = $("<input type=text readonly/>");
input.val(response);
input.on("click", function() {
input.select();
});
input.on("mouseup", function(e) {
e.preventDefault();
});
var target = $("<span class=target></span>")
target.text(longurl);
var li = $("<li/>");
li.hide();
li.append(input);
li.append(" ↝ ");
li.append(target);
$("#shorturls").append(li);
li.fadeIn();
});
});
</script>
</body>
</html>