-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5c87854
Showing
11 changed files
with
589 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#chuck-norries-joke-generator |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | ||
<meta content="utf-8" http-equiv="encoding"> | ||
</head> | ||
<body> | ||
<header> | ||
<div class="hero-content"> | ||
<img class="hero-pic" src="assets/chucknorriespic.jpg" alt="Pic of chuck"> | ||
<h1>The Awesome Chuck Norris Jokes Project</h1> | ||
</div> | ||
<div id="menuebar"> | ||
<a href="./index.html">Home</a> | ||
<a href="./search.html">Search</a> | ||
<a href="#" onclick="myFunction()" >Categories</a> | ||
</div> | ||
<div id="myDropdown" class="dropdown-content"> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=explicit">Explicit</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=dev">Dev</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=movie">Movie</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=food">Food</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=celebrity">Celebrity</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=science">Science</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=sport">Sport</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=political">Political</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=religion">Religion</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=animal">Animal</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=history">History</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=music">Music</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=travel">Travel</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=career">Career</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=money">Money</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=fashion">Fashion</a> | ||
</div> | ||
</header> | ||
|
||
<section id="gallery"> | ||
<div id="categoryHeader"> | ||
|
||
</div> | ||
|
||
<div id="results"> | ||
|
||
</div> | ||
</section> | ||
|
||
<script type='text/javascript'> var url = window.location.href;</script> | ||
<script src="category.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
function myFunction() { | ||
document.getElementById("myDropdown").classList.toggle("show"); | ||
} | ||
|
||
|
||
|
||
function parseURLParams( url ) { | ||
var queryStart = url.indexOf( "?" ) + 1; | ||
var queryEnd = url.indexOf( "#" ) + 1 || url.length + 1; | ||
var query = url.slice( queryStart, queryEnd - 1 ); | ||
var pairs = query.replace( /\+/g, " " ).split( "&" ); | ||
var object = { }; | ||
var name, value, pair; | ||
|
||
|
||
if( query === url || query === "" ) | ||
return null; | ||
|
||
for( var i = 0; i < pairs.length; i++ ) { | ||
pair = pairs[i].split( "=", 2 ); | ||
name = decodeURIComponent( pair[0] ); | ||
value = decodeURIComponent( pair[1] ); | ||
|
||
if( object.hasOwnProperty( name ) ) { | ||
|
||
if( typeof ( object[name] ) != "array" ) | ||
object[name] = [ object[name] ]; | ||
|
||
object[name].push( pair.length === 2 ? value : null ); | ||
|
||
} else { | ||
object[name] = value; | ||
} | ||
} | ||
return object; | ||
} | ||
|
||
var category = parseURLParams(url).search; | ||
|
||
|
||
/// API Request /// | ||
|
||
|
||
|
||
for( var i = 0; i < 9; i++){ | ||
var categoryJoke = new XMLHttpRequest(); | ||
|
||
categoryJoke.onreadystatechange = function(){ | ||
if( this.readyState == 4 && this.status == 200) { | ||
|
||
var joke = JSON.parse(this.responseText); | ||
|
||
var resPara = document.createElement("p"); | ||
|
||
resPara.className = "search-text"; | ||
|
||
var txtNode = document.createTextNode(joke.value); | ||
|
||
resPara.appendChild(txtNode); | ||
|
||
var resBx = document.getElementById("results"); | ||
|
||
resBx.appendChild(resPara); | ||
|
||
|
||
|
||
} | ||
}; | ||
|
||
|
||
categoryJoke.open("GET", "https://api.chucknorris.io/jokes/random?category="+ category, true); | ||
|
||
|
||
categoryJoke.send(); | ||
|
||
} | ||
|
||
console.log(category); | ||
|
||
//// Header | ||
|
||
var upperCat = category.charAt(0).toUpperCase()+category.substr(1); | ||
|
||
var catHead = document.getElementById("categoryHeader"); | ||
|
||
var headerTxt = document.createTextNode("Category: " + upperCat); | ||
|
||
catHead.appendChild(headerTxt); | ||
|
||
console.log(headerTxt); | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
function myFunction() { | ||
document.getElementById("myDropdown").classList.toggle("show"); | ||
} | ||
|
||
////// HOME ////// | ||
|
||
|
||
for( var i = 0; i < 9; i++ ){ | ||
var randomJoke = new XMLHttpRequest(); | ||
|
||
randomJoke.onreadystatechange = function(){ | ||
|
||
if( this.readyState == 4 && this.status == 200) { | ||
|
||
var joke = JSON.parse(this.responseText); | ||
|
||
var resTxt = document.createElement('p'); | ||
|
||
var txtNode = document.createTextNode(joke.value); | ||
|
||
resTxt.appendChild(txtNode); | ||
|
||
var resBox = document.getElementById("results"); | ||
|
||
resBox.appendChild(resTxt); | ||
|
||
resTxt.className = "search-text"; | ||
|
||
} | ||
}; | ||
randomJoke.open("GET", "https://api.chucknorris.io/jokes/random", true); | ||
randomJoke.send(); | ||
}; | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<html> | ||
<head> | ||
<script src="http://localhost:80/home.js"></script> | ||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | ||
<meta content="utf-8" http-equiv="encoding"> | ||
</head> | ||
<body> | ||
<header> | ||
<div class="hero-content"> | ||
<img class="hero-pic" src="assets/chucknorriespic.jpg" alt="Pic of chuck"> | ||
<h1>The Awesome Chuck Norris Jokes Project</h1> | ||
</div> | ||
<div id="menuebar"> | ||
<a href="./index.html">Home</a> | ||
<a href="./search.html">Search</a> | ||
<a href="#" onclick="myFunction()" >Categories</a> | ||
</div> | ||
<div id="myDropdown" class="dropdown-content"> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=explicit">Explicit</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=dev">Dev</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=movie">Movie</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=food">Food</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=celebrity">Celebrity</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=science">Science</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=sport">Sport</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=political">Political</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=religion">Religion</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=animal">Animal</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=history">History</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=music">Music</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=travel">Travel</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=career">Career</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=money">Money</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=fashion">Fashion</a> | ||
</div> | ||
|
||
|
||
</header> | ||
<div class="category-header"> | ||
<h2>A few random jokes:</h2> | ||
</div> | ||
<section id="gallery"> | ||
<div id="results"></div> | ||
</section> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<html> | ||
<head> | ||
|
||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | ||
<meta content="utf-8" http-equiv="encoding"> | ||
</head> | ||
<body> | ||
<header> | ||
<div class="hero-content"> | ||
<img class="hero-pic" src="assets/chucknorriespic.jpg" alt="Pic of chuck"> | ||
<h1>The Awesome Chuck Norris Jokes Project</h1> | ||
</div> | ||
<div id="menuebar"> | ||
<a href="./index.html">Home</a> | ||
<a href="./search.html">Search</a> | ||
<a href="#" onclick="myFunction()" >Categories</a> | ||
</div> | ||
<div id="myDropdown" class="dropdown-content"> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=explicit">Explicit</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=dev">Dev</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=movie">Movie</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=food">Food</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=celebrity">Celebrity</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=science">Science</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=sport">Sport</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=political">Political</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=religion">Religion</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=animal">Animal</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=history">History</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=music">Music</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=travel">Travel</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=career">Career</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=money">Money</a> | ||
<a href="http://127.0.0.1:56729/ChuckNorrisProject/category.html?search=fashion">Fashion</a> | ||
</div> | ||
</header> | ||
<div class="category-header"> | ||
<h2>Search Chuck Norris Jokes</h2> | ||
</div> | ||
|
||
<form method="GET" > | ||
<input name="search" class="search-bar" type="text" placeholder="Search.."> | ||
<button class="search-button" type="submit" onclick='loadMore()'>Go!</button> | ||
</form> | ||
|
||
|
||
<div id="searchResults"></div> | ||
|
||
<div id="moreSearchResults"></div> | ||
|
||
<div id="load-more"> | ||
<button class='load-more-btn' onclick="loadMore()">Load More Results</button> | ||
</div> | ||
|
||
<script type='text/javascript'> var url = window.location.href;</script> | ||
<script type='text/javascript' src="http://localhost:80/search.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.