-
Notifications
You must be signed in to change notification settings - Fork 0
/
count-google-index-demo.html
136 lines (108 loc) · 4.47 KB
/
count-google-index-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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Count Google Index Demo</title>
<link href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.6/yeti/bootstrap.min.css" rel="stylesheet" integrity="sha384-yxFy3Tt84CcGRj9UI7RA25hoUMpUPoFzcdPtK3hBdNgEGnh9FdKgMVM+lbAZTKN2" crossorigin="anonymous">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<style>
.header {
border-bottom: 1px solid #e5e5e5;
}
@media (min-width: 768px) {
.container {
max-width: 730px;
}
.header {
margin-bottom: 30px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header text-center">
<h3 class="text-muted">Count Google Index Demo</h3>
</div>
<div class="row">
<div class="col-md-12">
<form id="form-demo" action="count-google-index.php" class="form-horizontal" method="GET">
<div class="form-group">
<div class="col-md-12">
<input type="text" class="form-control text-center" id="url" name="url" placeholder="Enter URL">
</div>
</div>
<div class="form-group text-center">
<button id="btn" type="submit" class="btn btn-primary">Submit</button>
</div>
<table id="result" class="table table-bordered table-striped">
<tr>
<td width="20%">Count</td>
<td class="result__count"></td>
</tr>
<tr>
<td width="20%">URL</td>
<td class="result__url"></td>
</tr>
<tr>
<td width="20%">Google URL</td>
<td class="result__google-url"></td>
</tr>
</table>
</form>
</div>
</div>
</div>
<script src="//code.jquery.com/jquery-2.2.1.min.js"></script>
<script>
(function ($, undefined) {
$(document).on('submit', '#form-demo', function (e) {
e.preventDefault()
var action = $(this).attr('action')
var url = $('#url')
var urlValue = $.trim(url.val())
var btn = $('#btn')
if (urlValue == '') {
url.val('')
return alert('URL is required!')
}
url.attr('disabled', true)
btn.attr('disabled', true)
$.getJSON(action, {url: urlValue}, function (response) {
$('.result__count').text(response.data.count)
$('.result__url').html($('<a />', {
target: '_blank',
text: response.data.url,
title: response.data.url,
href: response.data.url
}))
$('.result__google-url').html($('<a />', {
target: '_blank',
text: response.data.google,
title: response.data.google,
href: response.data.google
}))
})
.fail(function (jqxhr, textStatus, error) {
var json = jqxhr.responseJSON
if (undefined === json.error) {
return alert('Something wrong!')
}
alert(json.error)
})
.always(function () {
url.attr('disabled', false)
btn.attr('disabled', false)
})
})
})(jQuery)
</script>
</body>
</html>