Advanced Search

Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Emulating a terminal-like caret with javascript and css.

  1. #11
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    made some more changes... used to scroll to the top when you type. now it stays with the cursor.
    same URL.

    but twey, your code outputs some odd behavior. for some reason the last character is outputted when a new one is typed...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hmm? Output? What output?

    That was just an example of caret code using an expanding textbox, there's no output involved.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Oh i thought it was an addon for sachi's code. NVM then...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  4. #14
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    $ is a terrible name for a function. Prototype was evidently written by a deranged Perl scripter.
    Sorry Twey, but I've got this habit of using the $ function because of firebug. I will try to avoid it as much as possible.

    Quote Originally Posted by Twey
    It would be nice to avoid innerHTML, especially since writing directly to innerHTML in this case would break the script in KHTML (deleting any spaces as soon as they're written).
    What should I use then? I guess I should use <element>.firstChild.firstChild.textValue but I don't usually use that because of the extra #text nodes netscape browsers insert instead of a newline.

    I was about to use the same technique but unfortunately, I couldn't make the default caret disappear so ... I had to think of a new technique.

    EDIT: boxxertrumps: Here's the function to send a request when the user hits enter:

    Add the following code after the

    Code:
    if(e.ctrlKey && e.keyCode == 65){
    
    					$("writer").style.backgroundColor = "#99ccff";
    
    				} else {
    
    					$("writer").style.backgroundColor = "";
    
    				}
    part:

    Code:
    if(e.keyCode == 13){
    sendAjaxRequest(document.getElementById("your_textarea_id").value);
    document.getElementById("your_textarea_id").value = "";
    return false;
    }
    That should work.
    Last edited by shachi; 02-17-2007 at 12:24 PM.

  5. #15
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What should I use then? I guess I should use <element>.firstChild.firstChild.textValue but I don't usually use that because of the extra #text nodes netscape browsers insert instead of a newline.
    It would be appropriate to use separate <code> elements for each line, or replace linebreaks with <br> elements as you have been doing.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #16
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Twey: I am sorry but, I didn't get what you meant by:

    Quote Originally Posted by Twey
    It would be appropriate to use separate <code> elements for each line.
    How would using code elements help me write the data into the div?

  7. #17
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    php doc i have so far... no error support, ill have to add that later.
    http://www.freewebs.com/boxxertrumps/carret.phps

    EDIT: the code at the top is assuming there are multiple lines being sent and can be replaced with
    $final = $_POST["com"];
    Last edited by boxxertrumps; 02-17-2007 at 05:17 PM.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  8. #18
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    How would using code elements help me write the data into the div?
    You don't. You write the data into <code> elements inside the <div>, which are styled to be block-level, thus solving the line-break problem.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #19
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Twey: Ah ha!! My bad, sorry. I'll try to implement that right away. Thanks Twey!!

    By the way I've found a bug and is listed in the original post. You can check it out if you want.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •