How can I make a log box always show the last line?

0

Hi, I have a log file of other codes that keeps updating. I made a javascript code that shows this file and it is a code that updates the live text on the page inside a textarea but it keeps updating and always returns to the first line, there is never how to see the final part, I wanted to know if it's css thing that has to move or javascript msm.

JS Code:

var url  = "wget-log";
var textarea_id = "textarea";

setInterval(function(){

$.ajax({
url : "wget-log",
type : "POST",
success : function(data){
$(".textarea").html(data);

}

});
}, 1000); 

Log format:

     0K .......... .......... .......... .......... ..........  0%  116K 31m1s
    50K .......... .......... .......... .......... ..........  0%  454K 19m27s
   100K .......... .......... .......... .......... ..........  0% 92.1K 25m56s
   150K .......... .......... .......... .......... ..........  0%  184K 24m18s
   200K .......... .......... .......... .......... ..........  0% 44.4K 35m34s
   250K .......... .......... .......... .......... ..........  0%  620K 30m36s
   300K .......... .......... .......... .......... ..........  0% 93.5K 31m41s
   350K .......... .......... .......... .......... ..........  0% 70.0K 34m7s
   400K .......... .......... .......... .......... ..........  0% 57.5K 37m14s
   450K .......... .......... .......... .......... ..........  0% 71.1K 38m32s
   500K .......... .......... .......... .......... ..........  0%  788K 35m26s
   550K .......... .......... .......... .......... ..........  0%  553K 33m1s
   600K .......... .......... .......... .......... ..........  0% 66.5K 34m36s
   650K .......... .......... .......... .......... ..........  0% 1.29M 32m19s
   700K .......... .......... .......... .......... ..........  0%  565K 30m34s
   750K .......... .......... .......... .......... ..........  0%  652K 29m0s
   800K .......... .......... .......... .......... ..........  0% 55.8K 31m3s
   850K .......... .......... .......... .......... ..........  0% 71.7K 32m5s
   900K .......... .......... .......... .......... ..........  0%  103K 32m12s
   950K .......... .......... .......... .......... ..........  0%  101K 32m21s
  1000K .......... .......... .......... .......... ..........  0% 33.5K 35m52s

Because of this format I can never read what is really happening since the last updates are at the end

    
asked by anonymous 03.06.2017 / 00:32

1 answer

0

You can try a regular expression to capture the last line and display it.

Try this regex: \r?\n?[^\r\n]*$

    
03.06.2017 / 02:01