If you had JavaScript running server-side...?

Discussion in 'Javascript' started by Peter Michaux, Jan 19, 2008.

  1. I'm writing a server-side web application framework using Mozilla's
    Rhino JavaScript engine. My two primary motivations are so I can write
    code on server and client sides without needing to switch gears
    mentally and so that the server and client can share code.

    The types of code sharing I know I can use immediately are form
    validations and html previews. For form validation, I'll be able to
    specify the regexp for what is an email address in just one language
    rather than in both Perl|Python|Ruby|Java|etc and in JavaScript. For
    something like a blog comment form or a wiki editor, where the user
    can use *bold* or _underline_ syntax, the algorithm to convert this
    code to HTML will only need to be expressed in one language. This
    makes live previews in the editor much easier to implement.

    I'm curious what other bits of common (or uncommon) client-side
    functionality that you would be able to share with the server if you
    had server-side framework running JavaScript.

    Thanks,
    Peter
     
    Peter Michaux, Jan 19, 2008
    #1
    1. Advertising

  2. Peter Michaux

    Guest

    On Jan 19, 3:11 pm, Peter Michaux <> wrote:
    > I'm writing a server-side web application framework using Mozilla's
    > Rhino JavaScript engine. My two primary motivations are so I can write
    > code on server and client sides without needing to switch gears
    > mentally and so that the server and client can share code.
    >
    > The types of code sharing I know I can use immediately are form
    > validations and html previews. For form validation, I'll be able to
    > specify the regexp for what is an email address in just one language
    > rather than in both Perl|Python|Ruby|Java|etc and in JavaScript. For
    > something like a blog comment form or a wiki editor, where the user
    > can use *bold* or _underline_ syntax, the algorithm to convert this
    > code to HTML will only need to be expressed in one language. This
    > makes live previews in the editor much easier to implement.
    >
    > I'm curious what other bits of common (or uncommon) client-side
    > functionality that you would be able to share with the server if you
    > had server-side framework running JavaScript.
    >
    > Thanks,
    > Peter


    I've recreated the Prototype 1.6.0 Library on the server side. Just
    go through the script and pull out references to DOM objects. This
    will give you basic OOP functionality. You may also want to look at
    Base2 or ExtJS for there implementations of inheritance.

    Utilizing the prototype.toString method comes in really handy when
    designing widgets.
    function Tree(){
    this.branches = [];
    };
    Tree.prototype = {
    read: function(sql){
    // run ado query
    // populate tree with branches
    },
    addBranch: function(branch){
    this.branches.push(branch);
    branch.parent = this;
    },
    toString: function(){
    var html = [];
    this.branches.each(function(branch){
    html.push(branch);
    }
    return "<ul>" + html.join("") + "</ul>";
    }
    }

    var itemTree = new Tree();
    itemTree.read(sqlString);

    Response.Write(itemTree);



    You can already do this within ASP, just change your language
    declaration to "Javascript".

    I'm also creating an ASP Framework. It's a port of Fusebox (from the
    ColdFusion community) written in JScript, but it will work with either
    JScript or VBScript applications.
     
    , Jan 20, 2008
    #2
    1. Advertising

  3. wrote:
    > On Jan 19, 3:11 pm, Peter Michaux <> wrote:
    >> [...]
    >> I'm curious what other bits of common (or uncommon) client-side
    >> functionality that you would be able to share with the server if you
    >> had server-side framework running JavaScript.
    >> [...]

    >
    > I've recreated the Prototype 1.6.0 Library on the server side. [...]


    See <news:>


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
     
    Thomas 'PointedEars' Lahn, Jan 20, 2008
    #3
  4. On Jan 20, 10:14 am, Randy Webb <> wrote:
    > Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:49 AM:
    >
    > > wrote:
    > >> On Jan 19, 3:11 pm, Peter Michaux <> wrote:
    > >>> [...]
    > >>> I'm curious what other bits of common (or uncommon) client-side
    > >>> functionality that you would be able to share with the server if you
    > >>> had server-side framework running JavaScript.
    > >>> [...]
    > >> I've recreated the Prototype 1.6.0 Library on the server side. [...]

    >
    > > See <news:>

    >
    > That's nice[1].


    You disagree with Thomas' sentiment or is it the odd way he linked it?

    Just in case anyone has problems with Thomas' link style...

    <URL: http://groups.google.com/group/comp.lang.javascript/msg/76e2debc87edaf10>

    Peter
     
    Peter Michaux, Jan 20, 2008
    #4
  5. Peter Michaux

    Evertjan. Guest

    Peter Michaux wrote on 20 jan 2008 in comp.lang.javascript:

    > On Jan 20, 10:14 am, Randy Webb <> wrote:
    >> Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:49 AM:
    >>
    >> > wrote:
    >> >> On Jan 19, 3:11 pm, Peter Michaux <> wrote:
    >> >>> [...]
    >> >>> I'm curious what other bits of common (or uncommon) client-side
    >> >>> functionality that you would be able to share with the server if
    >> >>> you had server-side framework running JavaScript.
    >> >>> [...]
    >> >> I've recreated the Prototype 1.6.0 Library on the server side.
    >> >> [...]

    >>
    >> > See <news:>

    >>
    >> That's nice[1].

    >
    > You disagree with Thomas' sentiment or is it the odd way he linked it?


    It is not an odd way to link a News Article, but the standard way.

    My and most other mail readers support it.

    > Just in case anyone has problems with Thomas' link style...
    >
    > <URL:
    > http://groups.google.com/group/comp.lang.javascript/msg/76e2debc87edaf1
    > 0>


    That is not the link to the News article,
    but [perhaps, not tested] to the archived version of it.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jan 20, 2008
    #5
  6. Peter Michaux wrote:
    > On Jan 20, 10:14 am, Randy Webb <> wrote:
    >> Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:49 AM:
    >>> wrote:
    >>>> On Jan 19, 3:11 pm, Peter Michaux <> wrote:
    >>>>> [...]
    >>>>> I'm curious what other bits of common (or uncommon) client-side
    >>>>> functionality that you would be able to share with the server if you
    >>>>> had server-side framework running JavaScript.
    >>>>> [...]
    >>>> I've recreated the Prototype 1.6.0 Library on the server side. [...]
    >>> See <news:>

    >> That's nice[1].

    >
    > You disagree with Thomas' sentiment


    There is no sentiment that can be found there, but is an explanation why an
    approach is misguided and the result of following it is ultimately bad.

    > or is it the odd way he linked it?


    The way it is being referred to is not at all odd; it is the way that is
    supported by most newsreaders, including Windows' built-in Outlook express
    and Google Groups. (Just click the link that OE and GG create from it.)

    > Just in case anyone has problems with Thomas' link style...


    It is not my link style. It is not even really a link, that is what some
    newsreaders make of it. (Think of what would have happened if I had posted
    a proper Message-ID header value instead ...)

    > <URL: http://groups.google.com/group/comp.lang.javascript/msg/76e2debc87edaf10>


    It works, but it makes little sense, if any. Despite what Google Groups and
    other mirrors want you to believe, Usenet is not on the Web.

    http://en.wikipedia.org/wiki/Usenet


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Jan 20, 2008
    #6
  7. Randy Webb wrote:
    > Thomas 'PointedEars' Lahn said the following on 1/20/2008 2:24 PM:
    >> Peter Michaux wrote:
    >>> <URL: http://groups.google.com/group/comp.lang.javascript/msg/76e2debc87edaf10>

    >> It works, but it makes little sense, if any. Despite what Google Groups and
    >> other mirrors want you to believe, Usenet is not on the Web.

    >
    > Nobody said Usenet is on the Web. The archives for Usenet are on the Web
    > though. And that is what Peter linked to was the archive of that post.


    Several, but not all, Usenet archives are available via the Web. Those that
    are on the Web are neither complete, nor do they always present the original
    article. Google Groups in its current form makes no exception.

    Furthermore, Web archives are not required to access an article that was
    posted only a few days ago; there is no public news server that has such a
    short expiration setting.

    And if my articles eventually expire, both will only be available in the
    archives, be they public or private. In fact, my (Google) research showed
    that providers of public Usenet archives have been going to great lengths to
    support `news:' URIs in the way I posted as being rewritten to links to
    their archives.


    EOD

    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
     
    Thomas 'PointedEars' Lahn, Jan 20, 2008
    #7
  8. [snip regarding linking to news archives]

    So do you guys have any thoughts about sharing code on the client and
    server sides? ;-)

    Peter
     
    Peter Michaux, Jan 21, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Qw==?=
    Replies:
    1
    Views:
    3,274
    Hermit Dave
    Jan 16, 2004
  2. George Ter-Saakov
    Replies:
    1
    Views:
    352
    Curt_C [MVP]
    May 6, 2004
  3. Uno

    if you had a C gnome ...

    Uno, Aug 11, 2010, in forum: C Programming
    Replies:
    9
    Views:
    300
  4. Replies:
    1
    Views:
    168
    Turkbear
    Sep 15, 2006
  5. Noah Cutler
    Replies:
    14
    Views:
    234
    Noah Cutler
    Feb 1, 2011
Loading...

Share This Page