Skip to content
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

irsyadpahlapi #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
104 changes: 104 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
ol{
list-style-type: i;
}
</style>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
</head>
<body>
<div class="posting">
<input type="text" name="pesan" id="pesan" value="">
<button type="button" id="kirim">send message twitter</button>
</div>

<div class="searching">
<input type="text" name="key" id="key" value="">
<button type="button" id="search">search tweet</button>
</div>
<div class="timeline">

</div>
<div class="trending">

</div>

</body>
<script type="text/javascript">
$.ajax({
url:'http://localhost:3000/users',
method:'GET',
dataType:"JSON",
success:(datas)=>{
console.log(datas);
datas.map((value)=>{
$(".timeline").append('<b>'+value.user.name+' </b> '+value.text+'<br />')
})
},
error:(err)=>{
console.log(err);
}
});
$.ajax({
url:'http://localhost:3000/users/trends',
method:'GET',
dataType:"JSON",
success:(datas)=>{
datas.map((value)=>{
value.trends.forEach((values,i)=>{
$(".trending").append(`${i+1}.${values.name}<br>`)
})
})
},
error:(err)=>{
console.log(err);
}
});
$( "#kirim" ).click(function() {
var obj = {
pesan : $('#pesan').val()
}
$.ajax({
url:'http://localhost:3000/users',
method:'POST',
dataType:"JSON",
data:obj,
success:(datas)=>{
console.log(datas);
location.reload();
},
error:(err)=>{
console.log(err);
}
});
});
$( "#search" ).click(function() {
var obj = {
key : $('#key').val()
}
$.ajax({
url:`http://localhost:3000/users/search?tweet=${obj.key}`,
method:'GET',
dataType:"JSON",
success:(datas)=>{
console.log(datas);
// datas.map((value)=>{
// // $(".searching").append(`${i+1}.${values.name}<br>`)
// })
},
error:(err)=>{
console.log(err);
}
});
});


</script>
</html>
94 changes: 94 additions & 0 deletions client/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<fb:login-button
scope="public_profile,email"
onlogin="checkLoginState();"
id="login">
</fb:login-button>
<button type="button" name="button" id="logout" onclick="logouts()">logout</button>
</body>




<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script>
//initialize fb
//fb.api('/me') informasi berupa email dll
// insert
window.fbAsyncInit = function() {
FB.init({
appId : '592784331071735',
cookie : true,
xfbml : true,
version : 'v2.12'
});

FB.AppEvents.logPageView();

FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};



(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}

function statusChangeCallback(response){
if(response.status === 'connected'){
console.log(response);
axios.get('http://localhost:3000/facebook/signin',{
headers:{
accessToken:response.authResponse.accessToken
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});

console.log('conect');
$('#logout').show()
$('#login').hide()

}else{
$('#logout').hide()
$('#login').show()
}
}

function logouts(){
FB.logout(function(response) {
statusChangeCallback(response)
});
}
</script>




</html>
Loading