473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
Jan 19 '08 #1
12 1691
On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:
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 '08 #2
st**********@gmail.com wrote:
On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:
>[...]
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:47************@PointedEars.de>
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jan 20 '08 #3
Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:49 AM:
st**********@gmail.com wrote:
>On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:
>>[...]
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:47************@PointedEars.de>
That's nice[1].

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 20 '08 #4
On Jan 20, 10:14 am, Randy Webb <HikksNotAtH...@aol.comwrote:
Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:49 AM:
stevenmob...@gmail.com wrote:
On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:
[...]
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:47************@PointedEars.de>

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
Jan 20 '08 #5
Peter Michaux wrote on 20 jan 2008 in comp.lang.javascript:
On Jan 20, 10:14 am, Randy Webb <HikksNotAtH...@aol.comwrote:
>Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:49 AM:
stevenmob...@gmail.com wrote:
On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:
[...]
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:47************@PointedEars.de>

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....6e2debc87edaf1
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)
Jan 20 '08 #6
Peter Michaux said the following on 1/20/2008 1:53 PM:
On Jan 20, 10:14 am, Randy Webb <HikksNotAtH...@aol.comwrote:
>Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:49 AM:
>>stevenmob...@gmail.com wrote:
On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:
[...]
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:47************@PointedEars.de>
That's nice[1].

You disagree with Thomas' sentiment or is it the odd way he linked it?
I have explained to Thomas, many times, with the flaws in that style link.

Perhaps someone can tell me how to get Thunderbird to honor that link?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 20 '08 #7
Peter Michaux wrote:
On Jan 20, 10:14 am, Randy Webb <HikksNotAtH...@aol.comwrote:
>Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:49 AM:
>>stevenmob...@gmail.com wrote:
On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:
[...]
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:47************@PointedEars.de>
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
Jan 20 '08 #8
Thomas 'PointedEars' Lahn said the following on 1/20/2008 2:24 PM:
Peter Michaux wrote:
<snip>
><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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 20 '08 #9
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
Jan 20 '08 #10
Thomas 'PointedEars' Lahn said the following on 1/20/2008 6:32 PM:
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.
Nobody said there weren't any available on the Web.
Those that are on the Web are neither complete, nor do they always present the original
article.
Can you show an instance where Google Groups didn't present the original
article?
Google Groups in its current form makes no exception.
Example? I am not referring to you trying to cancel a message and it
getting archived anyway. I am asking you for an instance where GG did
not present the original article. Meaning, Google Groups modified it in
some way.

There is one thing GG does, and that is adding trailing spaces.
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.
We are not discussing "Web archives" and some that won't "show an
article a few days ago". We are discussing Google Groups and the ability
to use Google Groups as a reference to an older article.
And if my articles eventually expire, both will only be available in the
archives, be they public or private.
Nobody said any differently.

Nothing you have said is any more true/false about web archives than
Usenet servers.
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.
Nobody said any differently. What I said was that your style of
referring to old posts is unreliable. Posting a URL to a Google copy of
it is.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 21 '08 #11
[snip regarding linking to news archives]

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

Peter
Jan 21 '08 #12
Peter Michaux said the following on 1/21/2008 2:35 AM:
[snip regarding linking to news archives]

So do you guys have any thoughts about sharing code on the client and
server sides? ;-)
I tried ASP once with JScript, gave me more headaches than I care to
remember. I kept getting confused about where I was, client or server.
Switched to PHP and haven't looked back.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 21 '08 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: john woo | last post by:
Hi in JSP, it's easy to pass value from java-variable to javascript-variable, like js_function(a) { a=<%java-class.A%> } I'm wondering how is the other way around? I tried
2
by: Kenneth | last post by:
Hi, In a document I have three lines that detects and redirects to another page is a session variable is 0 If Session("Customer_ID")=0 Then Response.Redirect("myPage.aspx") End If What I...
2
by: Jimmy | last post by:
Hi How do you refer from you webpage to a usercontrol which contains a n html control with javascript? usercontrol contains: <input id="tb1" name="tb1" type=text>
19
by: The Numerator | last post by:
I was just wondering that if it is possible to do almost anything you can do in JavaScript in PHP.
9
by: Boris Yeltsin | last post by:
I use Master Pages, so I make use of URL rebasing through the ~ operator, like this in the <head>: <link runat="server" href="~/Root.master.css" media="screen" rel="stylesheet" type="text/css" />...
4
by: Eric.Thomas.Moore | last post by:
Hey, My old boss wrote an extensive work tracking system in php for internal use. He left and the server he is running it on is very outdated so I have been given the task of transfering it...
7
by: Rob | last post by:
Hi, I'm getting an error on my login page when using Javascript session object. It works on the development server so I'm wondering if there is a setting in IIS to allow using sessions on the...
6
by: Venkatesh | last post by:
Hello All, I have couple of doubts regarding the concept of on-demand javascript loading using javascript code. I could see on the net different techniques for achieving this - techniques like:...
4
by: Epictitus | last post by:
I am trying to write a script which will allow me to read the contents of an HTTP web page into memory, parse the data, and output a calculated value. The HTTP page is on a web enable appliance -...
2
by: an96su | last post by:
Hi, I'm new to php. i'm trying to send information from my php (client) script to a website that is running javascript. Here is an extract of the server's response to my initial http request. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.