forked from 0x2620/oxjs
'use strict';
This commit is contained in:
parent
291b75c43b
commit
56370aa0a7
113 changed files with 207 additions and 15 deletions
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.compact <f> Returns an array w/o <code>null</code> or <code>undefined</code>
|
||||
> Ox.compact([null,,1,,2,,3])
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.avg <f> Returns the average of an array's values, or an object's properties
|
||||
(collection) -> <n> Average value
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.hsl <f> Takes RGB values and returns HSL values
|
||||
(rgb) <[n]> HSL values
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
//@ Ox.AMPM <[str]> ['AM', 'PM']
|
||||
Ox.AMPM = ['AM', 'PM'];
|
||||
//@ Ox.BASE_32_ALIASES <o> Base 32 aliases
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
// OxJS (c) 2011 0x2620, dual-licensed GPL/MIT, see http://oxjs.org for details
|
||||
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Some conventions:
|
||||
Functions
|
||||
|
|
@ -113,6 +115,7 @@ Ox.load = function() {
|
|||
length = Ox.len(modules);
|
||||
Ox.forEach(modules, function(options, module) {
|
||||
Ox.loadFile(Ox.PATH + 'Ox.' + module + '/Ox.' + module + '.js', function() {
|
||||
Ox.print('?', module)
|
||||
Ox.load[module](options, function(s) {
|
||||
success += s;
|
||||
++counter == length && callback(success == counter);
|
||||
|
|
@ -172,9 +175,9 @@ Ox.Log = (function() {
|
|||
if (!log.filterEnabled || log.filter.indexOf(args[0]) > -1) {
|
||||
date = new Date();
|
||||
args.unshift(
|
||||
Ox.formatDate(date, '%H:%M:%S.') + (+date).toString().substr(-3),
|
||||
Ox.formatDate(date, '%H:%M:%S.') + (+date).toString().substr(-3)/*,
|
||||
(arguments.callee.caller && arguments.callee.caller.name)
|
||||
|| '(anonymous)'
|
||||
|| '(anonymous)'*/
|
||||
);
|
||||
window.console && window.console.log.apply(window.console, args);
|
||||
ret = args.join(' ');
|
||||
|
|
@ -198,9 +201,9 @@ Ox.print = function() {
|
|||
var args = Ox.makeArray(arguments),
|
||||
date = new Date();
|
||||
args.unshift(
|
||||
Ox.formatDate(date, '%H:%M:%S.') + (+date).toString().substr(-3),
|
||||
Ox.formatDate(date, '%H:%M:%S.') + (+date).toString().substr(-3)/*,
|
||||
(arguments.callee.caller && arguments.callee.caller.name)
|
||||
|| '(anonymous)'
|
||||
|| '(anonymous)'*/
|
||||
);
|
||||
window.console && window.console.log.apply(window.console, args);
|
||||
return args.join(' ');
|
||||
|
|
@ -248,7 +251,11 @@ Ox.wrap = function(val, chained) {
|
|||
}
|
||||
};
|
||||
Object.getOwnPropertyNames(Ox).forEach(function(name) {
|
||||
if (name[0] == name[0].toLowerCase() && Ox.isFunction(Ox[name])) {
|
||||
if (
|
||||
['arguments', 'callee', 'caller', 'length'].indexOf(name) == -1
|
||||
&& name[0] == name[0].toLowerCase()
|
||||
&& Ox.isFunction(Ox[name])
|
||||
) {
|
||||
wrapper[name] = function() {
|
||||
var args = Array.prototype.slice.call(arguments), ret;
|
||||
args.unshift(val);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.canvas <function> Generic canvas object
|
||||
Returns an object with the properties: <code>canvas</code>,
|
||||
|
|
@ -39,7 +41,7 @@ Ox.documentReady = (function() {
|
|||
callbacks.forEach(function(callback) {
|
||||
callback();
|
||||
});
|
||||
delete callbacks;
|
||||
//delete callbacks;
|
||||
}
|
||||
};
|
||||
return function(callback) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
//@ Ox.getDate <f> Get the day of a date, optionally UTC
|
||||
// see Ox.setSeconds for source code
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
(function() {
|
||||
|
||||
function cap(width, height) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
// see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter
|
||||
if (!Array.prototype.filter) {
|
||||
Array.prototype.filter = function(fn, that) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.formatArea <f> Formats a number of meters as square meters or kilometers
|
||||
> Ox.formatArea(1000)
|
||||
|
|
@ -268,7 +270,6 @@ Ox.formatDateRange = function(start, end, utc) {
|
|||
if (isOneUnit) {
|
||||
strings = [Ox.formatDate(dates[0], formats[precision[0] - 1], utc)];
|
||||
} else {
|
||||
format = formats[precision[0] - 1];
|
||||
strings = [
|
||||
Ox.formatDate(dates[0], formats[precision[0] - 1], utc),
|
||||
Ox.formatDate(dates[1], formats[precision[1] - 1], utc)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
(function() {
|
||||
|
||||
// fixme: make all this work with different types of "points"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.parseEmailAddresses <f> Takes HTML and turns e-mail addresses into links
|
||||
@*/
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.doc <f> Generates documentation for annotated JavaScript
|
||||
(file, callback) -> <u> undefined
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.asinh <f> Inverse hyperbolic sine
|
||||
Strangely missing from <code>Math</code>.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.extend <function> Extends an object with one or more other objects
|
||||
> Ox.extend({a: 1, b: 1, c: 1}, {b: 2, c: 2}, {c: 3})
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.get <f> Get a remote file
|
||||
# fixme: remote? same-origin-policy? jsonp?
|
||||
|
|
@ -54,7 +56,7 @@ Ox.loadFile = (function() {
|
|||
return function (file, callback) {
|
||||
var element,
|
||||
request,
|
||||
type = file.split('.').pop();
|
||||
type = file.split('.').pop(),
|
||||
isImage = type != 'css' && type != 'js';
|
||||
if (!cache[file]) {
|
||||
if (isImage) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
Ox.basename = function(str) {
|
||||
/*
|
||||
fixme: deprecate
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.isArguments <f> Tests if a value is an arguments "array"
|
||||
(value) -> <b> True if the value is an arguments "array"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue