forked from 0x2620/oxjs
request controller
This commit is contained in:
parent
274c2f436a
commit
a19578af35
3 changed files with 369 additions and 87 deletions
|
|
@ -11,6 +11,39 @@ Core functions
|
|||
================================================================================
|
||||
*/
|
||||
|
||||
Ox.getset = function(obj, args, callback, context) {
|
||||
/*
|
||||
generic getter and setter function
|
||||
Ox.getset(obj) returns obj
|
||||
Ox.getset(obj, str) returns obj.str
|
||||
Ox.getset(obj, {key: val, ...}, callback, context) sets obj.key to val,
|
||||
calls callback(key, val),
|
||||
returns context
|
||||
*/
|
||||
var args = args || {},
|
||||
callback = callback || function() {},
|
||||
context = context || {},
|
||||
length = args.length,
|
||||
ret;
|
||||
if (length == 0) {
|
||||
// getset()
|
||||
ret = obj;
|
||||
} else if (length == 1 && typeof arguments[0] == "string") {
|
||||
// getset(str)
|
||||
ret = obj[args[0]]
|
||||
} else {
|
||||
// getset(str, val) or getset({str: val, ...})
|
||||
// translate (str, val) to ({str: val})
|
||||
args = Ox.makeObject(args);
|
||||
obj = $.extend(obj, args);
|
||||
$.each(args, function(k, v) {
|
||||
callback(k, v);
|
||||
});
|
||||
ret = context;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Ox.print = function() {
|
||||
/*
|
||||
*/
|
||||
|
|
@ -523,6 +556,10 @@ Ox.getISOYear = function(date) {
|
|||
return date_.getFullYear();
|
||||
};
|
||||
|
||||
Ox.getTime = function() {
|
||||
return +new Date();
|
||||
}
|
||||
|
||||
Ox.getTimezoneOffsetString = function(date) {
|
||||
/*
|
||||
Time zone offset string (-1200 - +1200)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue