javascript - Echo content on the same line in jQuery Terminal -
i've been looking through documentation jquery terminal found nothing. basically, i'm trying echo following:
here v0.8.7
should link, when seek echo string using .echo(string,{raw:true})
ascii fine art gets distorted:
term.echo( ' __ _____ ________ __\n'+ ' / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / /\n'+ ' __ / // // // // // _ // _// // / / // _ // _// // // \\/ // _ \\/ /\n'+ '/ / // // // // // ___// / / // / / // ___// / / / / // // /\\ // // / /__\n'+ '\\___//____ \\\\___//____//_/ _\\_ / /_//____//_/ /_/_/_//_//_/ /_/ \\__\\_\\___/\n'+ ' \\/ /____/ <a href="http://terminal.jcubic.pl/" target="_blank" title="jqueryterminal website">v'+term.version()+'</a>', {raw:true} );
i tried using 2 separate echo calls, version number pushed new line. how can add together version number @ end of ascii fine art without going new line?
here current code:
term.echo( ' __ _____ ________ __\n'+ ' / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / /\n'+ ' __ / // // // // // _ // _// // / / // _ // _// // // \\/ // _ \\/ /\n'+ '/ / // // // // // ___// / / // / / // ___// / / / / // // /\\ // // / /__\n'+ '\\___//____ \\\\___//____//_/ _\\_ / /_//____//_/ /_/ /_//_//_/ /_/ \\__\\_\\___/\n'+ ' \\/ /____/ ' ); term.echo('<a href="http://terminal.jcubic.pl/" target="_blank" title="jqueryterminal website">v'+term.version()+'</a>',{raw:true});
live demo: http://suchmail.eu/hunpony/djdavid98/cli(use command ver
)
okay quite interesting. jquery terminal
echo
function operates in few different modes don’t mix methods within echo
call.
but there way looking using finalize
callback function explained in the documentation echo
:
finalize — callback function 1 argument div container
that key. if @ source html output jquery terminal
when echo
’s content can see pile of <div>
elements width of 100%
, ascii within of it.
<div style="width: 100%;"> __ _____ ________ __</div>
so when seek echo
on next line line this:
term.echo('<a href="http://terminal.jcubic.pl/" target="_blank" title="jqueryterminal website">v'+term.version()+'</a>',{raw:true});
what happens <div style="width: 100%;">
generated knocks line down. , because raw:true
means cannot mixed echo
above it.
but using finalize
, acting on div
contains link can this:
term.echo('<a href="http://terminal.jcubic.pl/" target="_blank" title="jqueryterminal website">v'+term.version()+'</a>', { raw:true, finalize: function(div) { div .css("width", "720px") .css("text-align", "right") .css("margin-top", "-1em") ; } });
the magic css & jquery setting css. width gets set 720px
, text-align
set right , margin-top
set -1em
line pushed 1 line. here screenshot of looks these adjustments in place:
so intents & purposes, visually looks same. caveat of method can never tell how browsers behave css this. sure test in few browsers. if chokes, tweak css gets set in finalize
, should able come combo works across browsers.
javascript jquery jquery-terminal
No comments:
Post a Comment