How does the console work at codecademy.com/tryruby.org?

The websites I'm talking about are codecademy.com and tryruby.org .

My guess would be that the console is a simple div with key listeners connected to it. Whenever the user presses any key and sends it by pressing enter, the console simply adds everything that he typed after the last letter in the div , and β€œmoves” the >> [type here to the last line of the div .

However, I am not sure that it is that simple, so I would like to know what other people think. I believe that this would be too inefficient - especially when we are talking about a situation where the entire console is too full of text - adding any character to the last line and moving the rest of the text, then it takes too much time for the browser to process.

+8
javascript jquery ruby
source share
1 answer

Commands are sent via AJAX to the actual Ruby interpreter, the explanation you provided is correct, but does not take into account the fact that the commands provide any reasonable results in Ruby.

+5
source share

All Articles