Created
May 16, 2016 02:20
-
-
Save wordyallen/16c7cdbbf8a3ca460b92c7f9a0d491fd to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<link rel="shortcut icon" href="https://cdn0.iconfinder.com/data/icons/kameleon-free-pack-rounded/110/Chat-2-128.png" type="image/x-icon"> | |
<!-- Compiled and minified CSS --> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css"> | |
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!-- Compiled and minified JavaScript --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"> | |
<title>Twitter Chat</title> | |
<style> | |
.login{ | |
display: flex; | |
flex-direction: column; | |
justify-content: center; | |
align-items: center; | |
height: 80vh; | |
} | |
#errorMsg{ | |
margin: 1%; | |
} | |
.authButton{ | |
margin: 1%; | |
} | |
</style> | |
</head> | |
<body> | |
<div class='login'> | |
<h1 class="grey-text">Twitter Chat</h1> | |
<a class="authButton waves-effect waves-light btn-large"> | |
<span class="icon"><i class="fa fa-twitter"></i></span> | |
</a> | |
<a class="authButton waves-effect blue waves-light btn-large"> | |
<span class="icon"><i class="fa fa-facebook"></i></span> | |
</a> | |
<a class="authButton red waves-effect waves-light btn-large"> | |
<span class="icon"><i class="fa fa-google"></i></span> | |
google | |
</a> | |
<div id="modal1" class="modal"> | |
<div class="modal-content"> | |
<h4> Could Not Log In</h4> | |
</div> | |
<div class="modal-footer"> | |
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Try Again</a> | |
</div> | |
</div> | |
</div> | |
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/js/materialize.min.js"></script> | |
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> | |
<script type="text/javascript" > | |
const ref = new Firebase("https://chatapp2334.firebaseio.com/") | |
$(".authButton").click(function(){ | |
const site = this.id | |
ref.authWithOAuthPopup(this.id, function(error, authData) { | |
if (error) handlesError() | |
else handlesSuccess(authData, site) | |
}) | |
}) | |
function handlesError(){ | |
$('#modal1').openModal(); | |
} | |
function handlesSuccess(authData, site){ | |
let {displayName, profileImageURL, username } = authData[site] | |
username ? username : username='' | |
console.log(username) | |
const auth = {displayName, profileImageURL,username } | |
localStorage.setItem("auth", JSON.stringify(auth)) | |
window.location.replace("app.html"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment