论坛首页 Web前端技术论坛

Javascript On Rails

浏览 2029 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-04-13   最后修改:2010-04-13
我滴最新开源项目 Javascript On Rails
项目地址:http://code.google.com/p/javascript-on-rails/

不像Jquery 或是 Dojo 针对于DOM 进行封装,
Javascript On Rails 是对javascript 语言进行再次封装,类似于ruby,让javascript更加敏捷和面向对象。
并且结合Jquery 和 图表Flot,组合为强大的客户前端Lib,code for fun


#Hash操作
var a = new HashTable();
a.add("k","v");
true
a.get()
a.get("k")
v
a.clear();
props(a);
Methods: add, clear, contains, count, items, remove
Fields: _hash

#日期操作
var d = new Date();
d.wday();
星期二
props(d);
Methods of prototype: _toString, add, addDays, addHours, addMilliseconds, addMinutes, addMonths, addSeconds, addWeeks, addYears, apr, april, aug, august, between, clearTime, clone, compareTo, day, days, dec, december, equals, feb, february, fri, friday, getDayName, getDayOfYear, getDaysInMonth, getMonthName, getOrdinal, getTimezone, getUTCOffset, getWeekOfYear, hour, hours, is, isDST, isLeapYear, isWeekday, jan, january, jul, july, jun, june, last, mar, march, may, millisecond, milliseconds, minute, minutes, mon, monday, month, months, moveToDayOfWeek, moveToFirstDayOfMonth, moveToLastDayOfMonth, moveToMonth, next, nov, november, oct, october, prev, previous, sat, saturday, second, seconds, sep, september, set, setTimezone, setTimezoneOffset, sun, sunday, thu, thursday, toJSONString, toLongDateString, toLongTimeString, toShortDateString, toShortTimeString, tue, tuesday, wday, wed, wednesday, week, weeks, year, years
Fields of prototype: _is, _orient

compare
var today = Date.today();
var past = Date.today().add(-6).days(); 
var future = Date.today().add(6).days();

Date.compare(today, future);                    // -1
Date.compare(today, new Date().clearTime());    // 0
Date.compare(today, past)                       // 1
d.toJSONString()
#other doc
http://code.google.com/p/datejs/wiki/APIDocumentation


#Queue
var q = new Queue();
q.getSize();
0
q.isEmpty()
true
q.enqueue("a")
q.getSize();
1
q.dequeue();
a 
for(var i=0;i<1000;i++) { q.enqueue("aaaaa" + i)}
for(var i=0;i<1000;i++) { print(q.dequeue())}
q.getOldestElement()

#Array 数组操作
for(var i=0;i<1000;i++){a.append(i)};
TypeError on line 1: a.append is not a function
for(var i=0;i<1000;i++){a.push(i)};
1000

props(a)
Fields: 0, 1, 2
Methods of prototype: avg, high, jsGrep, low, shrink, truncate

a.avg()
499.5
a.high()
999
a.low()
0
var a = ["a","ab","abc"]
a.jsGrep(/a/,"!")
!,!b,!bc

#Number 操作
typeof(d)
number

var d = 123456789;
props(d);
d.addCommas()
123,456,789

#String 操作
var s = "你好!"
s.escape();
%u4F60%u597D%21
t = s.escape();
%u4F60%u597D%21
t.unescape()
你好!

var s = "abababab";
s.replaceAll("a","A")
AbAbAbAb

var s= "a";
s.len()
1
s = "好";
好
s.len
function () { var str = this; return str.replace(/[^\x00-\xff]/g, "**").length; }
s.len()
2

var s = "你好 {0}";
s.format("柳争");
   发表时间:2010-04-18  
正准入学习JavaScript中~~不过对于使用rails来说,还是ruby吧
0 请登录后投票
   发表时间:2010-04-19  
weijizg 写道
正准入学习JavaScript中~~不过对于使用rails来说,还是ruby吧

这个库是类似于 ruby on rails javascript 库,不是ruby的rails底层,是纯javascript的底层实现。 :)
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics