Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function updateLog(){
- $.get('getLog.php',
- function(response){
- $('#container-log').each(function(){
- // get DOM element
- var div = $(this);
- //$(this).html("Hejsa");
- var scrolledDown = false;
- // check if div is scrolled down
- if((div.scrollTop - div.scrollHeight) < 12 && (div.scrollTop - div.scrollHeight) > -12){
- scrolledDown = true; // if already near bottom
- }
- var wasEmpty = false;
- if($(this).text().length<12){
- // div doesnt overflow
- wasEmpty = true;
- }
- if(response){
- $(this).html(response);
- }
- else{
- $(this).html("");
- }
- if(scrolledDown || wasEmpty){
- // scroll divs down to the last line after refresh
- div.scrollTop = div.scrollHeight;
- }
- });
- }
- );
- };
- $(function(){
- updateLog();
- setInterval("updateLog()", 5000);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement