如果你有运行服务器端的JavaScript ......? [英] If you had JavaScript running server-side...?

查看:66
本文介绍了如果你有运行服务器端的JavaScript ......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Mozilla的
Rhino JavaScript引擎编写服务器端Web应用程序框架。我的两个主要动机是,我可以在服务器和客户端编写

代码而无需在心理上切换齿轮,以便服务器和客户端可以共享代码。 />

我知道我可以立即使用的代码共享类型是

验证和html预览。对于表单验证,我将能够使用一种语言指定正则表达式的电子邮件地址

而不是Perl | Python | Ruby | Java | etc和JavaScript。对于

类似于博客评论表或wiki编辑器,其中用户可以使用* bold *或_underline_语法,算法转换此

代码到HTML只需要用一种语言表达。这个

使编辑器中的实时预览更容易实现。


我很好奇其他常见的(或不常见的)客户端<如果您使用运行JavaScript的服务器端框架,那么您可以与服务器共享的
功能。


谢谢,

Peter

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

推荐答案

1月19日下午3:11,Peter Michaux< petermich ... @ gmail。编写:
On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:

我正在使用Mozilla的
Rhino JavaScript引擎编写服务器端Web应用程序框架。我的两个主要动机是,我可以在服务器和客户端编写

代码而无需在心理上切换齿轮,以便服务器和客户端可以共享代码。 />

我知道我可以立即使用的代码共享类型是

验证和html预览。对于表单验证,我将能够使用一种语言指定正则表达式的电子邮件地址

而不是Perl | Python | Ruby | Java | etc和JavaScript。对于

类似于博客评论表或wiki编辑器,其中用户可以使用* bold *或_underline_语法,算法转换此

代码到HTML只需要用一种语言表达。这个

使编辑器中的实时预览更容易实现。


我很好奇其他常见的(或不常见的)客户端<如果您使用运行JavaScript的服务器端框架,那么您可以与服务器共享的
功能。


谢谢,

Peter
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



我在服务器端重新创建了Prototype 1.6.0库。只需

遍历脚本并提取对DOM对象的引用。这个

将为您提供基本的OOP功能。您可能还想查看

Base2或ExtJS以获得继承的实现。


使用prototype.toString方法非常方便

设计小部件。

函数树(){

this.branches = [];

};

Tree.prototype = {

读取:function(sql){

//运行ado查询

//填充树分支

},

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);


您已经可以使用i执行此操作n ASP,只需更改您的语言

声明为Javascript。


我也在创建一个ASP框架。它是用JScript编写的Fusebox(来自

ColdFusion社区)的端口,但它可以与

JScript或VBScript应用程序一起使用。

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.


st ********** @ gmail .com 写道:

1月19日下午3:11,Peter Michaux< petermich ... @ gmail.comwrote:
On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:

> [...]
我很好奇你可以使用的其他一些常见(或不常见)的客户端
功能如果你有运行JavaScript的服务器端框架,请与服务器共享。
[...]
>[...]
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.
[...]



我已经重新创建了服务器端的Prototype 1.6.0库。 [...]


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



见< news:47 ************ @ PointedEars.de>

PointedEars

-

现实主义:HTML 4.01严格

福音传播:XHTML 1.0严格

疯狂:XHTML 1.1作为application / xhtml + xml

- Bjoern Hoehrmann

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


Thomas''PointedEars''Lahn在2008年1月20日发表以下文章6:49 AM:
Thomas ''PointedEars'' Lahn said the following on 1/20/2008 6:49 AM:
st ******** **@gmail.com 写道:

> 1月19日下午3:11,Peter Michaux< petermich ... @ gmail。 comwrote:
>On Jan 19, 3:11 pm, Peter Michaux <petermich...@gmail.comwrote:

>> [...]
我很好奇其他常见的(或不常见的)客户端是什么? />如果你有服务器端框架运行JavaScript,你可以与服务器共享的功能。
[...]
>>[...]
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.
[...]


我'已经在服务器端重新创建了Prototype 1.6.0库。 [...]

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



见< news:47 ************ @ PointedEars.de>


See <news:47************@PointedEars.de>



那很好[1]。


-

Randy

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq/index.html

Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/


这篇关于如果你有运行服务器端的JavaScript ......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆