-
Notifications
You must be signed in to change notification settings - Fork 83
Testing Exercise Commit #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amarcjones
wants to merge
10
commits into
rithmschool:master
Choose a base branch
from
amarcjones:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
69906a6
Testing Exercise Commit
d74b388
recursion exercises
7f2a1b1
080317 Commits
f6bc5f7
Shapes exercise
amarcjones 70fd941
Completed assignments - still working on bonus questions
amarcjones e462c63
Includes basic functionality - will improve page this weekend.
amarcjones 6af2244
Implemented recommeneded changes
amarcjones 0ec0783
Call Bind Apply Exercise
amarcjones 061737f
Hacker Snooze commit - currently includes functionality to authentica…
amarcjones a8852b8
Prototypes Exercises - still working on last problem (bind)
amarcjones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,93 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Hacker News Clone</title> | ||
| <!-- Link to stylesheet --> | ||
| <link rel="stylesheet" type="text/css" href="style.css"> | ||
|
|
||
| <!-- Latest compiled and minified CSS --> | ||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
| <!-- Optional theme --> | ||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> | ||
|
|
||
| <!-- jQuery script link --> | ||
| <!-- jQuery should be included before JavaScript script --> | ||
| <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | ||
| <!-- Latest compiled and minified JavaScript --> | ||
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> | ||
|
|
||
| <!-- script to main.js --> | ||
| <script src="main.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="container"> | ||
| <div class="row"> | ||
|
|
||
| <div class="col col-md-10" style="height: 100px; background-color: #e65c00;"> | ||
| <h3>Hack or Snooze</h3> | ||
| </div> | ||
| <div class="col col-md-1" style="height: 100px; background-color: yellow;"> | ||
| <a href="#login" data-toggle="collapse">Log In</a> | ||
| </div> | ||
| <div class="col col-md-1" style="height: 100px; background-color: lightgray;"> | ||
| <a href="#login" data-toggle="collapse">Sign Up</a> | ||
| </div> | ||
|
|
||
|
|
||
| </div> | ||
|
|
||
| <form action=""> | ||
| <div class="row collapse" id='login'> | ||
| <!-- <div class="col col-md-12" style="height: 200px; background-color: yellow;"> --> | ||
|
|
||
| <div class="form-group row"> | ||
| <label for="email" class="col-md-2 col-form-label">Email</label> | ||
| <div class="col-md-12"> | ||
| <input class="form-control" type="email" value="bootstrap@example.com" id="email"> | ||
| </div> | ||
| </div> | ||
| <div class="form-group row"> | ||
| <label for="password" class="col-md-2 col-form-label">Title</label> | ||
| <div class="col-md-6"> | ||
| <input class="form-control" type="text" value="Input new title..." id="password"> | ||
| </div> | ||
|
|
||
|
|
||
| </div> | ||
|
|
||
| <div class="form-group row"> | ||
| <button type="submit" class="btn btn-primary">Submit</button> | ||
| </div> | ||
|
|
||
| <!-- </div> --> | ||
| </div> | ||
| <div class="row"> | ||
| <div class="col col-md-12" id="top20" style="height: 200px; background-color: #fff0e6;"> | ||
| <!-- <h3>Ordered List</h3> --> | ||
| <ol> | ||
| </ol> | ||
| </div> | ||
| </div> | ||
| </form> | ||
|
|
||
| </div> | ||
|
|
||
|
|
||
|
|
||
| </body> | ||
| </html> | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or 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,167 @@ | ||
| $(function() { | ||
|
|
||
| $("form").on("submit", function(e) { | ||
| e.preventDefault(); | ||
|
|
||
| topStories() | ||
| signUpUser() | ||
|
|
||
| // var $newTitle = $('#newTitle').val() | ||
| // var $newURL = $('#urlToAdd').val() | ||
| // var icon = "<span class=\"glyphicon glyphicon-star-empty\" aria-hidden=\"true\"></span>" | ||
| // var $newLi = $("<li>" + icon + " " + $newTitle + " " + $newURL + "</li>"); | ||
| // $("ol").append($newLi); | ||
|
|
||
| // $newTitle.val(""); | ||
| // $newURL.val(""); | ||
| }); | ||
|
|
||
|
|
||
| $('ol').click(function(event){ | ||
| $(event.target).toggleClass('glyphicon-star-empty glyphicon-star'); | ||
|
|
||
| addToFavorites() | ||
|
|
||
|
|
||
| }); | ||
|
|
||
| $("btnFavs").on("click", function(e) { | ||
| e.preventDefault(); | ||
|
|
||
| addToFavorites(); | ||
| retrieveFavorites(); | ||
|
|
||
| } ) | ||
|
|
||
|
|
||
| //----------------------------------------------------------------------- | ||
| // Create the Top Stories List | ||
| var icon = "<span class=\"glyphicon glyphicon-star-empty\" aria-hidden=\"true\"></span>" | ||
|
|
||
| function topStories() { | ||
| $.get( "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty", function( data ) { | ||
| var arrIDs = []; | ||
| //create array of Top 20 story IDs, that push a complete url to the array | ||
| for (var i = 0; i < 20; i++) { | ||
| arrIDs.push("https://hacker-news.firebaseio.com/v0/item/" + data[i] + ".json") | ||
| } | ||
| //use the url's from above to run another get funtion to get the details for each story ID | ||
| for (var i = 0; i < arrIDs.length; i++) { | ||
| $.get(arrIDs[i]) | ||
| .then(function (data) { | ||
| // $('ol').append("<li>" + icon + "<h5>" + data.title + "</h5> (" + data.url + ") </li>") | ||
| $('ol').append("<li>" + icon + "<h5>" + data.title + "</h5> </li>") | ||
|
|
||
| }) | ||
| .fail(function(err) { | ||
| console.log(err); | ||
| }); | ||
| } | ||
| }) | ||
| } | ||
|
|
||
|
|
||
|
|
||
| var $email = $('#email').val(); | ||
| // console.log($email); | ||
| var $password = $('#password').val(); | ||
| // console.log($password); | ||
| var authKy = ""; | ||
|
|
||
|
|
||
| function signUpUser(email, password) { | ||
|
|
||
| $.ajax({ | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json" | ||
| }, | ||
| url: "https://hn-favorites.herokuapp.com/signup", | ||
| data: JSON.stringify({ | ||
| email: $email, | ||
| password: $password | ||
| }) | ||
| }) | ||
| .then(function(data) { authKy = (data.auth_token) }) | ||
| .fail(err => console.warn(err)) | ||
|
|
||
| } | ||
|
|
||
| function logInUser(email, password) { | ||
| $.ajax({ | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json" | ||
| }, | ||
| url: "https://hn-favorites.herokuapp.com/signup", | ||
| data: JSON.stringify({ | ||
| email: $email, | ||
| password: $password | ||
| }) | ||
| }) | ||
| .then(function(data) { authKy = (data.auth_token)}) | ||
| .fail(err => console.warn(err)) | ||
| } | ||
|
|
||
| //If a story is clicked, do addToFavorites() function that will add it to the favorites list | ||
| function addToFavorites() { | ||
| $.ajax({ | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| "Authorization": authKy | ||
| }, | ||
| url: "https://hn-favorites.herokuapp.com/stories.json", | ||
| data: JSON.stringify({ | ||
| hacker_news_story: { | ||
| by: "aj", | ||
| story_id: "123", | ||
| title: "Test story", | ||
| url: "abc.com" | ||
| } | ||
| }) | ||
| }) | ||
| .then(function(data) { console.log(data) }) | ||
| .fail(err => console.warn(err)) | ||
| } | ||
|
|
||
| function retrieveFavorites() { | ||
| $.ajax({ | ||
| method: "GET", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| "Authorization": authKy | ||
| }, | ||
| url: "https://hn-favorites.herokuapp.com/stories.json", | ||
| data: JSON.stringify({ | ||
| hacker_news_story: { | ||
| by: "aj", | ||
| story_id: "123", | ||
| title: "Test story", | ||
| url: "abc.com" | ||
| } | ||
| }) | ||
| }) | ||
| .then(function(data) { console.log("fav's response: " + data) }) | ||
| .fail(err => console.warn(err)) | ||
| } | ||
|
|
||
|
|
||
|
|
||
| }); | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or 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,66 @@ | ||
| function sumEvenArguments() { | ||
| var result = 0; | ||
| for(var i = 0; i < arguments.length; i++) { | ||
| if(arguments[i] % 2 === 0) { | ||
| result += arguments[i]; | ||
| } | ||
| } | ||
| return result | ||
| } | ||
|
|
||
|
|
||
| function arrayFrom() { | ||
| var finalArr = []; | ||
| for(var i = 0; i < arguments.length; i++) { | ||
| finalArr.push(arguments[i]); | ||
| } | ||
| return finalArr; | ||
| } | ||
|
|
||
| function invokeMax(fn, maxAmount) { | ||
|
|
||
| var counter = 0; | ||
|
|
||
| return function() { | ||
| counter++; | ||
|
|
||
| if(counter > maxAmount) { | ||
| return "Maxed Out!" | ||
| } else { | ||
| return fn.apply(this, [].slice.call(arguments)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| var addOnlyThreeTimes = invokeMax(add,3); | ||
| addOnlyThreeTimes(1,2); // 3 | ||
| addOnlyThreeTimes(2,2); // 4 | ||
| addOnlyThreeTimes(1,2); // 3 | ||
| addOnlyThreeTimes(1,2); // "Maxed Out!" | ||
|
|
||
|
|
||
|
|
||
| function guessingGame(amount) { | ||
|
|
||
| var answer = Math.round(Math.random()*10) | ||
| var guesses = 0; | ||
|
|
||
|
|
||
| return function(guess) { | ||
| if(guesses < amount) { | ||
| guesses++ | ||
| } else { | ||
| return "Game Over!" | ||
| } | ||
|
|
||
| if(guess === answer){ | ||
| return "You got it!"; | ||
| } else if(guess > answer) { | ||
| return "You're too high!"; | ||
| } else if(guess < answer) { | ||
| return "You're too low!" | ||
| } | ||
|
|
||
| } | ||
| } | ||
This file contains hidden or 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
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can skip the new array and the loop by using slice: