-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
193 lines (181 loc) · 6.44 KB
/
index.html
File metadata and controls
193 lines (181 loc) · 6.44 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>ProCATstinator</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style>
.form-check {
padding-bottom: 10px
}
.hidden {
display: none;
}
.btn-primary {
background-color: #3E48CE !important;
}
</style>
</head>
<body>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div class="mx-auto">
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0">
<a class="navbar-brand col-md-3" href="#">ProCATstinator</a>
</nav>
</div>
<div class="container-fluid">
<div class="row">
<nav class="col-md-3 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<br><h4>Customize your selection here:</h4><br>
<div class="form-check">
<input class="form-check-input" type="radio" name="catRadio" id="randoCat" value="randoCat" checked>
<label class="form-check-label" for="catRadio1">
Rando-Cat: get a totally random cat
</label>
</div>
<br>
<div class="form-check">
<input class="form-check-input" type="radio" name="catRadio" id="gifCat" value="gifCat">
<label class="form-check-label" for="catRadio3">
Cat Gif: always cats in action
</label>
</div>
<br>
<div class="form-check">
<input class="form-check-input" type="radio" name="catRadio" id="filterCat" value="filterCat">
<label class="form-check-label" for="catRadio3">
Insta-Cat: get a cat with a hip filter
</label>
</div>
<br>
<div class="form-check">
<input class="form-check-input" type="radio" name="catRadio" id="tagCat" value="tagCat">
<label class="form-check-label" for="catRadio2">
Tag, You're Cat! Get a cat with a tag:
</label>
</div>
<div class="btn-group">
<select class="form-control" id="tagSelect" hidden ="true">
<option value="/cute">Cute</option>
<option value="/computer">Computer</option>
<option value="/kitten">Kitten</option>
<option value="/sleepy">Sleepy</option>
</select>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="catRadio" id="memeCat" value="memeCat">
<label class="form-check-label" for="catRadio3">
Meme-Cat! Get a cat with some text:
</label>
</div>
<div class="form-group">
<input type="text" class="form-control" id="catText" hidden="true" placeholder="What shall the cat say?">
</div>
<button type="reset" class="btn btn-outline-dark" id="resetButton">Reset</button>
<p><small>Using <a href = "https://cataas.com/#/">Cat As A Service</a></small></p>
</div>
</nav>
<main role="main" class="col-md-9 pt-3 px-4" style="height:100%">
<div class = "text-center">
<div class="alert alert-danger hidden" id="noTextError">
<strong>Oops!</strong> Please enter some input for this selection.
</div>
<img src="img/defaultCat.jpg" height="500px" class="rounded" id="catTainer" alt="Responsive image">
</div>
</main>
</div>
</div>
<br><br>
<button type="submit" class="btn btn-primary btn-lg btn-block" style="padding: 20px" id="submitButton">Pro-cat-stinate!</button>
<br>
<audio controls autoplay>
<source src="thundercat.mp3" type="audio/mpeg" id="songPlayer">
Your browser does not support the audio element.
</audio>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Icons -->
<!-- Graphs -->
<script>
$(document).ready(function() {
var height = $('.content').height()
$('.sidebar').height(height)
$( "#submitButton" ).click(function() {
var tag = $("#tagSelect").val();
var catRadio = $('input[name=catRadio]:checked').val();
var inputText = $('#catText').val();
if(inputText.length == 0 && catRadio == 'memeCat') {
$("#noTextError").removeClass("hidden");
} else {
$("#noTextError").addClass("hidden");
}
var url = processInput(catRadio, inputText, tag);
d = new Date()
$("#catTainer").attr('src', url+"?"+d.getTime());
});
$("#resetButton").click(function() {
var inputText = $('#catText').val("");
$("#noTextError").addClass("hidden");
$("#catTainer").attr('src', 'img/defaultCat.jpg' );
$("#randoCat").prop("checked", true)
});
function processInput(catRadio, inputText, tag) {
var baseURL = "https://cataas.com/cat"
switch(catRadio) {
case "randoCat":
return baseURL ;
case "tagCat":
return baseURL + tag;
case "gifCat":
return baseURL + "/gif";
case "filterCat":
return baseURL + "?filter=sepia" //the default filter
case "memeCat":
if (inputText.length == 0) {
return "http://erbc.org.uk/wp-content/uploads/2016/10/cute_cat_404_error_im_sorry.jpg"
}
return baseURL + "/says/" + inputText
}
}
$('input:radio[name=catRadio]').change(function () {
if (this.value == 'memeCat') {
$("#catText").prop("hidden", false)
}
else {
$("#catText").prop("hidden", true)
}
if (this.value == 'tagCat') {
$("#tagSelect").prop("hidden", false)
console.log("its getting here")
}
else {
$("#tagSelect").prop("hidden", true)
}
});
window.addEventListener("keypress", function (evt) {
var SPACEBAR = 32;
if (evt.which === SPACEBAR) {
playPause();
evt.preventDefault();
}
});
function playPause() {
if ($('#songPlayer').prop("paused"))
$('.play').trigger("play");
else
$('.play').trigger("pause");
}
});
</script>
</body>
</html>