files with the .js extension

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pierre

    #1

    files with the .js extension

    I have recently bought the book: JavaScript & DHTML Cookbook. As I
    opened the .js files with note pad, I asked myself why was the code
    formated in such a way. The code looks as if it had been produced by
    some kind of programs instead of a person. I also noticed a lot of
    little squared zeros; what are those all about?

    I have also noticed code formated in a similar way, when viewing some
    of the source code of the web pages on the MSN web site. If someone
    knows anything about this machine-like formating, I would love to hear
    from you.
  • Michael Winter

    #2
    [OT] Re: files with the .js extension

    On 27 Feb 2004 13:21:52 -0800, Pierre <pfaucher66@sym patico.ca> wrote:
    [color=blue]
    > I have recently bought the book: JavaScript & DHTML Cookbook. As I
    > opened the .js files with note pad, I asked myself why was the code
    > formated in such a way. The code looks as if it had been produced by
    > some kind of programs instead of a person. I also noticed a lot of
    > little squared zeros; what are those all about?
    >
    > I have also noticed code formated in a similar way, when viewing some
    > of the source code of the web pages on the MSN web site. If someone
    > knows anything about this machine-like formating, I would love to hear
    > from you.[/color]

    You will usually see this when a text file has been created on another
    operating system. Windows, Macs and Unix-based OSs all use different
    combinations of two characters to represent new lines. When programs like
    notepad don't recognise the combination, they display that character you
    see[1].

    It's nothing to worry about, but it does make reading difficult.

    You could try using a different editor. There are many free ones available
    designed for Web development. I use HTML-Kit. If you search the Google
    Groups archives, you find that editor recommendations have been asked
    frequently in the past. You might want to try some of the ones listed in
    those threads.

    Mike


    [1] The character used, a square (filled or outlined, depending on the
    font), is used in Windows to represent non-printable characters.

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: files with the .js extension

      Pierre wrote:
      [color=blue]
      > I have recently bought the book: JavaScript & DHTML Cookbook. As I
      > opened the .js files with note pad, I asked myself why was the code
      > formated in such a way. The code looks as if it had been produced by
      > some kind of programs instead of a person. I also noticed a lot of
      > little squared zeros; what are those all about?[/color]

      The file is likely to have been saved under UNIX, a UNIX derivative
      (short: *n*x, e.g. GNU/Linux) or under MacOS (Apple Macintosh).
      Those operating systems use different newline delimiters than Windows
      (Windows: \r\n; Unix: \n; Mac: \r). Notepad is unable to read the
      UNIX and Mac format (thus displayes the "squared zeroes" for those
      undisplayable control characters), use an editor that is capable, like
      metapad (freeware) or UltraEdit (shareware). If you have installed
      Cygwin or have (SSH/Telnet) access to a *n*x system, you can also use
      the `unix2dos' program (a `recode' wrapper) on those files.

      Another possibility is that the code has been "line-optimized" or
      "uglified" (which is bad for a tutorial); you can use a JavaScript
      beautifier to make it readable. Ask Google about "JavaScript formatter".


      HTH

      PointedEars

      Comment

      • Dr John Stockton

        #4
        Re: files with the .js extension

        JRS: In article <40744F23.80000 04@PointedEars. de>, seen in
        news:comp.lang. javascript, Thomas 'PointedEars' Lahn
        <PointedEars@we b.de> posted at Wed, 7 Apr 2004 20:57:39 :[color=blue]
        >Pierre wrote:
        >[color=green]
        >> I have recently bought the book: JavaScript & DHTML Cookbook. As I
        >> opened the .js files with note pad, I asked myself why was the code
        >> formated in such a way. The code looks as if it had been produced by
        >> some kind of programs instead of a person. I also noticed a lot of
        >> little squared zeros; what are those all about?[/color]
        >
        >The file is likely to have been saved under UNIX, a UNIX derivative
        >(short: *n*x, e.g. GNU/Linux) or under MacOS (Apple Macintosh).
        >Those operating systems use different newline delimiters than Windows
        >(Windows: \r\n; Unix: \n; Mac: \r). Notepad is unable to read the
        >UNIX and Mac format (thus displayes the "squared zeroes" for those
        >undisplayabl e control characters), use an editor that is capable, like
        >metapad (freeware) or UltraEdit (shareware). If you have installed
        >Cygwin or have (SSH/Telnet) access to a *n*x system, you can also use
        >the `unix2dos' program (a `recode' wrapper) on those files.
        >
        >Another possibility is that the code has been "line-optimized" or
        >"uglified" (which is bad for a tutorial); you can use a JavaScript
        >beautifier to make it readable. Ask Google about "JavaScript formatter".[/color]

        In attempting to give a complete explanation, Pointy-Head has again
        demonstrated limits of his experience by giving only a partial answer.
        A full answer would be encyclopaedic; but an adequate answer would be
        more useful.

        WordPad - at least in Win98 - transforms both CR & LF endings to CRLF;
        given that Notepad is available, WordPad could well be the best
        solution.

        MiniTrue, for DOS-16, Win32, UNIX, has line-end correction as an example
        (and is a very useful tool in general, and so worth fetching, for those
        who can operate at the command-line).

        The stated conditions for UNIX2DOS are unnecessarily limited; it is
        *IIRC* distributed with other software, and one can surely get it over
        the Net from FTP archives such as Garbo.

        It is better not to fully reformat code provided as an example if there
        is any prospect of the associated material referring to it in a layout-
        dependent manner,

        --
        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
        Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
        I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
        free, DOS/Win/UNIX, <URL:http://www.idiotsdelig ht.net/minitrue/> Update hope?

        Comment

        Working...