Last active
February 17, 2019 22:38
-
-
Save emrekizildas/f56ce703436b1f6d637f5923078eaf9c to your computer and use it in GitHub Desktop.
Chat yükleme fonksiyonu
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
function chatYukle() { | |
var query = firebase.database().ref("chats"); | |
var kadi = $("#kadi").val(); | |
query.on('value', function (snapshot) { | |
$("#mesajAlani").html(""); | |
snapshot.forEach(function (childSnapshot) { | |
var data = childSnapshot.val(); | |
if (data.from == kadi) { | |
//Mesaj bizim tarafımızdan gönderilmişse bu alan çalışacak | |
var mesaj = `<div class="d-flex justify-content-end"> | |
<div class="alert alert-info" role="alert"> | |
`+ data.message + ` <b>@` + data.from + `</b> | |
</div> | |
</div>`; | |
$("#mesajAlani").append(mesaj); | |
} else { | |
//Mesaj başkası tarafından gönderilmişse bu alan çalışacak | |
var mesaj = `<div class="d-flex"> | |
<div class="alert alert-dark" role="alert"> | |
<b>@`+ data.from + `</b> ` + data.message + ` | |
</div> | |
</div>`; | |
$("#mesajAlani").append(mesaj); | |
} | |
$(".card-body").scrollTop($('.card-body')[0].scrollHeight - $('.card-body')[0].clientHeight); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment