-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
76 lines (75 loc) · 2.94 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RJs</title>
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-S9LDSSZ2FT"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-S9LDSSZ2FT');
</script>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="well clearfix">
<blockquote>
<p id="getOtherJoke"></p>
<footer><cite title="Source Title">Internet Database</cite></footer>
</blockquote>
<div class="fright">
<button class="btn btn-success" id="getMessage">New Joke</button>
</div>
<div class="fleft">
<a id="twitter" data-size="small" target="_blank">
<button type="button" class="btn btn-primary">Tweet Joke!</button></a>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
init();
var jokes = [];
function init () {
var jokesAPI = "https://icanhazdadjoke.com/";
$.getJSON(
jokesAPI,
{}
)
.done(function(json) {
var obj = JSON.stringify(json);
var data = JSON.parse(obj);
var jokeDisplay = document.getElementById("getOtherJoke");
for (var i = 0; i < data.joke.length; i++) {
jokes.push(data.joke);
}
document.getElementById("getOtherJoke").innerHTML = data.joke;
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
$("#getOtherJoke").append('Request to the server failed. Try again later!');
});
}
$("#getMessage").on("click", function() {
init();
});
$("#twitter").on("click", function() {
var textJoke = $('#getOtherJoke').text();
$(this).attr("href", 'https://twitter.com/intent/tweet?text=' + textJoke);
});
});
</script>
</body>
</html>