tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-28 02:47:52 +03:00
parent 104db56b48
commit 0e78422f35
10 changed files with 213 additions and 139 deletions

View File

@ -1,7 +1,6 @@
/** vim: et:ts=4:sw=4:sts=4 /** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. * @license RequireJS 2.2.0 Copyright jQuery Foundation and other contributors.
* Available via the MIT or new BSD license. * Released under MIT license, http://github.com/requirejs/requirejs/LICENSE
* see: http://github.com/jrburke/requirejs for details
*/ */
//Not using strict: uneven strict support in browsers, #392, and causes //Not using strict: uneven strict support in browsers, #392, and causes
//problems with requirejs.exec()/transpiler plugins that may not be strict. //problems with requirejs.exec()/transpiler plugins that may not be strict.
@ -12,7 +11,7 @@ var requirejs, require, define;
(function (global) { (function (global) {
var req, s, head, baseElement, dataMain, src, var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath, interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.14', version = '2.2.0',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/, jsSuffixRegExp = /\.js$/,
@ -20,8 +19,6 @@ var requirejs, require, define;
op = Object.prototype, op = Object.prototype,
ostring = op.toString, ostring = op.toString,
hasOwn = op.hasOwnProperty, hasOwn = op.hasOwnProperty,
ap = Array.prototype,
apsp = ap.splice,
isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
isWebWorker = !isBrowser && typeof importScripts !== 'undefined', isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
//PS3 indicates loaded and complete, but need to wait for complete //PS3 indicates loaded and complete, but need to wait for complete
@ -38,6 +35,11 @@ var requirejs, require, define;
globalDefQueue = [], globalDefQueue = [],
useInteractive = false; useInteractive = false;
//Could match something like ')//comment', do not lose the prefix to comment.
function commentReplace(match, multi, multiText, singlePrefix) {
return singlePrefix || '';
}
function isFunction(it) { function isFunction(it) {
return ostring.call(it) === '[object Function]'; return ostring.call(it) === '[object Function]';
} }
@ -244,7 +246,7 @@ var requirejs, require, define;
// still work when converted to a path, even though // still work when converted to a path, even though
// as an ID it is less than ideal. In larger point // as an ID it is less than ideal. In larger point
// releases, may be better to just kick out an error. // releases, may be better to just kick out an error.
if (i === 0 || (i == 1 && ary[2] === '..') || ary[i - 1] === '..') { if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') {
continue; continue;
} else if (i > 0) { } else if (i > 0) {
ary.splice(i - 1, 2); ary.splice(i - 1, 2);
@ -554,11 +556,13 @@ var requirejs, require, define;
function takeGlobalQueue() { function takeGlobalQueue() {
//Push all the globalDefQueue items into the context's defQueue //Push all the globalDefQueue items into the context's defQueue
if (globalDefQueue.length) { if (globalDefQueue.length) {
//Array splice in the values since the context code has a each(globalDefQueue, function(queueItem) {
//local var ref to defQueue, so cannot just reassign the one var id = queueItem[0];
//on context. if (typeof id === 'string') {
apsp.apply(defQueue, context.defQueueMap[id] = true;
[defQueue.length, 0].concat(globalDefQueue)); }
defQueue.push(queueItem);
});
globalDefQueue = []; globalDefQueue = [];
} }
} }
@ -589,7 +593,7 @@ var requirejs, require, define;
id: mod.map.id, id: mod.map.id,
uri: mod.map.url, uri: mod.map.url,
config: function () { config: function () {
return getOwn(config.config, mod.map.id) || {}; return getOwn(config.config, mod.map.id) || {};
}, },
exports: mod.exports || (mod.exports = {}) exports: mod.exports || (mod.exports = {})
}); });
@ -845,7 +849,10 @@ var requirejs, require, define;
factory = this.factory; factory = this.factory;
if (!this.inited) { if (!this.inited) {
this.fetch(); // Only fetch if not already in the defQueue.
if (!hasProp(context.defQueueMap, id)) {
this.fetch();
}
} else if (this.error) { } else if (this.error) {
this.emit('error', this.error); this.emit('error', this.error);
} else if (!this.defining) { } else if (!this.defining) {
@ -905,7 +912,11 @@ var requirejs, require, define;
defined[id] = exports; defined[id] = exports;
if (req.onResourceLoad) { if (req.onResourceLoad) {
req.onResourceLoad(context, this.map, this.depMaps); var resLoadMaps = [];
each(this.depMaps, function (depMap) {
resLoadMaps.push(depMap.normalizedMap || depMap);
});
req.onResourceLoad(context, this.map, resLoadMaps);
} }
} }
@ -964,6 +975,7 @@ var requirejs, require, define;
this.map.parentMap); this.map.parentMap);
on(normalizedMap, on(normalizedMap,
'defined', bind(this, function (value) { 'defined', bind(this, function (value) {
this.map.normalizedMap = normalizedMap;
this.init([], function () { return value; }, null, { this.init([], function () { return value; }, null, {
enabled: true, enabled: true,
ignore: true ignore: true
@ -1117,12 +1129,22 @@ var requirejs, require, define;
this.depCount += 1; this.depCount += 1;
on(depMap, 'defined', bind(this, function (depExports) { on(depMap, 'defined', bind(this, function (depExports) {
if (this.undefed) {
return;
}
this.defineDep(i, depExports); this.defineDep(i, depExports);
this.check(); this.check();
})); }));
if (this.errback) { if (this.errback) {
on(depMap, 'error', bind(this, this.errback)); on(depMap, 'error', bind(this, this.errback));
} else if (this.events.error) {
// No direct errback on this module, but something
// else is listening for errors, so be sure to
// propagate the error correctly.
on(depMap, 'error', bind(this, function(err) {
this.emit('error', err);
}));
} }
} }
@ -1226,13 +1248,15 @@ var requirejs, require, define;
while (defQueue.length) { while (defQueue.length) {
args = defQueue.shift(); args = defQueue.shift();
if (args[0] === null) { if (args[0] === null) {
return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
args[args.length - 1]));
} else { } else {
//args are id, deps, factory. Should be normalized by the //args are id, deps, factory. Should be normalized by the
//define() function. //define() function.
callGetModule(args); callGetModule(args);
} }
} }
context.defQueueMap = {};
} }
context = { context = {
@ -1242,6 +1266,7 @@ var requirejs, require, define;
defined: defined, defined: defined,
urlFetched: urlFetched, urlFetched: urlFetched,
defQueue: defQueue, defQueue: defQueue,
defQueueMap: {},
Module: Module, Module: Module,
makeModuleMap: makeModuleMap, makeModuleMap: makeModuleMap,
nextTick: req.nextTick, nextTick: req.nextTick,
@ -1259,6 +1284,14 @@ var requirejs, require, define;
} }
} }
// Convert old style urlArgs string to a function.
if (typeof cfg.urlArgs === 'string') {
var urlArgs = cfg.urlArgs;
cfg.urlArgs = function(id, url) {
return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;
};
}
//Save off the paths since they require special processing, //Save off the paths since they require special processing,
//they are additive. //they are additive.
var shim = config.shim, var shim = config.shim,
@ -1313,7 +1346,7 @@ var requirejs, require, define;
each(cfg.packages, function (pkgObj) { each(cfg.packages, function (pkgObj) {
var location, name; var location, name;
pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
name = pkgObj.name; name = pkgObj.name;
location = pkgObj.location; location = pkgObj.location;
@ -1340,7 +1373,7 @@ var requirejs, require, define;
//late to modify them, and ignore unnormalized ones //late to modify them, and ignore unnormalized ones
//since they are transient. //since they are transient.
if (!mod.inited && !mod.map.unnormalized) { if (!mod.inited && !mod.map.unnormalized) {
mod.map = makeModuleMap(id); mod.map = makeModuleMap(id, null, true);
} }
}); });
@ -1476,6 +1509,7 @@ var requirejs, require, define;
var map = makeModuleMap(id, relMap, true), var map = makeModuleMap(id, relMap, true),
mod = getOwn(registry, id); mod = getOwn(registry, id);
mod.undefed = true;
removeScript(id); removeScript(id);
delete defined[id]; delete defined[id];
@ -1486,10 +1520,11 @@ var requirejs, require, define;
//in array so that the splices do not //in array so that the splices do not
//mess up the iteration. //mess up the iteration.
eachReverse(defQueue, function(args, i) { eachReverse(defQueue, function(args, i) {
if(args[0] === id) { if (args[0] === id) {
defQueue.splice(i, 1); defQueue.splice(i, 1);
} }
}); });
delete context.defQueueMap[id];
if (mod) { if (mod) {
//Hold on to listeners in case the //Hold on to listeners in case the
@ -1551,6 +1586,7 @@ var requirejs, require, define;
callGetModule(args); callGetModule(args);
} }
context.defQueueMap = {};
//Do this after the cycle of callGetModule in case the result //Do this after the cycle of callGetModule in case the result
//of those calls/init calls changes the registry. //of those calls/init calls changes the registry.
@ -1632,13 +1668,12 @@ var requirejs, require, define;
//Join the path parts together, then figure out if baseUrl is needed. //Join the path parts together, then figure out if baseUrl is needed.
url = syms.join('/'); url = syms.join('/');
url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js')); url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js'));
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
} }
return config.urlArgs ? url + return config.urlArgs && !/^blob\:/.test(url) ?
((url.indexOf('?') === -1 ? '?' : '&') + url + config.urlArgs(moduleName, url) : url;
config.urlArgs) : url;
}, },
//Delegates to req.load. Broken out as a separate function to //Delegates to req.load. Broken out as a separate function to
@ -1686,7 +1721,21 @@ var requirejs, require, define;
onScriptError: function (evt) { onScriptError: function (evt) {
var data = getScriptData(evt); var data = getScriptData(evt);
if (!hasPathFallback(data.id)) { if (!hasPathFallback(data.id)) {
return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id])); var parents = [];
eachProp(registry, function(value, key) {
if (key.indexOf('_@r') !== 0) {
each(value.depMaps, function(depMap) {
if (depMap.id === data.id) {
parents.push(key);
return true;
}
});
}
});
return onError(makeError('scripterror', 'Script error for "' + data.id +
(parents.length ?
'", needed by: ' + parents.join(', ') :
'"'), evt, [data.id]));
} }
} }
}; };
@ -1860,11 +1909,11 @@ var requirejs, require, define;
if (node.attachEvent && if (node.attachEvent &&
//Check if node.attachEvent is artificially added by custom script or //Check if node.attachEvent is artificially added by custom script or
//natively supported by browser //natively supported by browser
//read https://github.com/jrburke/requirejs/issues/187 //read https://github.com/requirejs/requirejs/issues/187
//if we can NOT find [native code] then it must NOT natively supported. //if we can NOT find [native code] then it must NOT natively supported.
//in IE8, node.attachEvent does not have toString() //in IE8, node.attachEvent does not have toString()
//Note the test for "[native code" with no closing brace, see: //Note the test for "[native code" with no closing brace, see:
//https://github.com/jrburke/requirejs/issues/273 //https://github.com/requirejs/requirejs/issues/273
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
!isOpera) { !isOpera) {
//Probably IE. IE (at least 6-8) do not fire //Probably IE. IE (at least 6-8) do not fire
@ -1892,6 +1941,12 @@ var requirejs, require, define;
} }
node.src = url; node.src = url;
//Calling onNodeCreated after all properties on the node have been
//set, but before it is placed in the DOM.
if (config.onNodeCreated) {
config.onNodeCreated(node, config, moduleName, url);
}
//For some cache cases in IE 6-8, the script executes before the end //For some cache cases in IE 6-8, the script executes before the end
//of the appendChild execution, so to tie an anonymous define //of the appendChild execution, so to tie an anonymous define
//call to the module name (which is stored on the node), hold on //call to the module name (which is stored on the node), hold on
@ -1910,9 +1965,14 @@ var requirejs, require, define;
//In a web worker, use importScripts. This is not a very //In a web worker, use importScripts. This is not a very
//efficient use of importScripts, importScripts will block until //efficient use of importScripts, importScripts will block until
//its script is downloaded and evaluated. However, if web workers //its script is downloaded and evaluated. However, if web workers
//are in play, the expectation that a build has been done so that //are in play, the expectation is that a build has been done so
//only one script needs to be loaded anyway. This may need to be //that only one script needs to be loaded anyway. This may need
//reevaluated if other use cases become common. //to be reevaluated if other use cases become common.
// Post a task to the event loop to work around a bug in WebKit
// where the worker gets garbage-collected after calling
// importScripts(): https://webkit.org/b/153317
setTimeout(function() {}, 0);
importScripts(url); importScripts(url);
//Account for anonymous modules //Account for anonymous modules
@ -1958,8 +2018,10 @@ var requirejs, require, define;
//Preserve dataMain in case it is a path (i.e. contains '?') //Preserve dataMain in case it is a path (i.e. contains '?')
mainScript = dataMain; mainScript = dataMain;
//Set final baseUrl if there is not already an explicit one. //Set final baseUrl if there is not already an explicit one,
if (!cfg.baseUrl) { //but only do so if the data-main value is not a loader plugin
//module ID.
if (!cfg.baseUrl && mainScript.indexOf('!') === -1) {
//Pull off the directory of data-main for use as the //Pull off the directory of data-main for use as the
//baseUrl. //baseUrl.
src = mainScript.split('/'); src = mainScript.split('/');
@ -1973,7 +2035,7 @@ var requirejs, require, define;
//like a module name. //like a module name.
mainScript = mainScript.replace(jsSuffixRegExp, ''); mainScript = mainScript.replace(jsSuffixRegExp, '');
//If mainScript is still a path, fall back to dataMain //If mainScript is still a path, fall back to dataMain
if (req.jsExtRegExp.test(mainScript)) { if (req.jsExtRegExp.test(mainScript)) {
mainScript = dataMain; mainScript = dataMain;
} }
@ -2020,7 +2082,7 @@ var requirejs, require, define;
if (callback.length) { if (callback.length) {
callback callback
.toString() .toString()
.replace(commentRegExp, '') .replace(commentRegExp, commentReplace)
.replace(cjsRequireRegExp, function (match, dep) { .replace(cjsRequireRegExp, function (match, dep) {
deps.push(dep); deps.push(dep);
}); });
@ -2052,14 +2114,18 @@ var requirejs, require, define;
//where the module name is not known until the script onload event //where the module name is not known until the script onload event
//occurs. If no context, use the global queue, and get it processed //occurs. If no context, use the global queue, and get it processed
//in the onscript load callback. //in the onscript load callback.
(context ? context.defQueue : globalDefQueue).push([name, deps, callback]); if (context) {
context.defQueue.push([name, deps, callback]);
context.defQueueMap[name] = true;
} else {
globalDefQueue.push([name, deps, callback]);
}
}; };
define.amd = { define.amd = {
jQuery: true jQuery: true
}; };
/** /**
* Executes the text. Normally just uses eval, but can be modified * Executes the text. Normally just uses eval, but can be modified
* to use a better, environment-specific call. Only used for transpiling * to use a better, environment-specific call. Only used for transpiling

View File

@ -54,10 +54,14 @@ var CLIActions = actions.Actions({
path = path || this.location.path path = path || this.location.path
return this.loadImages(path) return this.loadImages(path)
.then(function(){ return that.makePreviews('all') }) .then(function(){
.then(function(){ return that.sortImages() }) that.makePreviews('all')
//.then(function(){ return that.readAllMetadata() }) //that.readAllMetadata()
.then(function(){ return that.saveIndex() }) that
.sortImages()
// XXX for some reason this is not running from cli
.saveIndex(path)
})
}], }],
}) })
@ -209,7 +213,7 @@ module.CLI = core.ImageGridFeatures.Feature({
.arguments('<action> [args]') .arguments('<action> [args]')
.action(function(action, args){ .action(function(action, args){
// XXX // XXX
//console.log('>>>>', action, args, !!that[action]) console.log('>>>>', action, args, !!that[action])
that[action](args) that[action](args)
}) })

View File

@ -11,6 +11,7 @@ define(function(require){ var module = {}
// XXX // XXX
var DEBUG = typeof(DEBUG) != 'undefined' ? DEBUG : true var DEBUG = typeof(DEBUG) != 'undefined' ? DEBUG : true
var util = require('lib/util')
var object = require('lib/object') var object = require('lib/object')
var actions = require('lib/actions') var actions = require('lib/actions')
var features = require('lib/features') var features = require('lib/features')
@ -92,8 +93,8 @@ if(typeof(process) != 'undefined'){
//global.Date = window.Date //global.Date = window.Date
// XXX this is less of a hack but it is still an implicit // XXX this is less of a hack but it is still an implicit
patchDate(global.Date) util.patchDate(global.Date)
patchDate(window.Date) util.patchDate(window.Date)
// node... // node...
} else { } else {

View File

@ -579,6 +579,10 @@ var FileSystemLoaderUIActions = actions.Actions({
// show user the list... // show user the list...
var so = that.Overlay(browse.makeList(null, loaders) var so = that.Overlay(browse.makeList(null, loaders)
.on('update', function(){
// select top element...
so.client.select(0)
})
// close self and parent... // close self and parent...
.open(function(){ .open(function(){
so.close() so.close()
@ -589,8 +593,6 @@ var FileSystemLoaderUIActions = actions.Actions({
//o.parent.focus() //o.parent.focus()
o.select(item) o.select(item)
}) })
// select top element...
so.client.select(0)
return so return so
} }

View File

@ -8,7 +8,7 @@
//var DEBUG = DEBUG != null ? DEBUG : true //var DEBUG = DEBUG != null ? DEBUG : true
var requirejs = require('requirejs') global.requirejs = global.requirejs || require('requirejs')
requirejs.config({ requirejs.config({
nodeRequire: require, nodeRequire: require,
//baseUrl: __dirname, //baseUrl: __dirname,

View File

@ -309,7 +309,7 @@ module.ImagesClassPrototype = {
// XXX stub... // XXX stub...
var i = 0 var i = 0
//var base_pattern = base ? RegExp('^' + base) : null //var base_pattern = base ? RegExp('^' + base) : null
var base_pattern = base ? RegExp('^' + quoteRegExp(base)) : null var base_pattern = base ? RegExp('^' + RegExp.quoteRegExp(base)) : null
data.forEach(function(path){ data.forEach(function(path){
// XXX need to normalize path... // XXX need to normalize path...
var p = (base_pattern ? path.replace(base_pattern, './') : path) var p = (base_pattern ? path.replace(base_pattern, './') : path)

View File

@ -246,8 +246,6 @@ if(window.require && window.nw){
<script src="ext-lib/jquery-ui.js"></script> <script src="ext-lib/jquery-ui.js"></script>
<script src="ext-lib/jquery.ui.touch-punch.min.js"></script> <script src="ext-lib/jquery.ui.touch-punch.min.js"></script>
<!--script src="ext-lib/jquery.transit.min.js"></script-->
<!-- velocity.js --> <!-- velocity.js -->
<script src="ext-lib/velocity.min.js"></script> <script src="ext-lib/velocity.min.js"></script>
@ -255,14 +253,6 @@ if(window.require && window.nw){
<script src="ext-lib/hammer.min.js"></script> <script src="ext-lib/hammer.min.js"></script>
<script src="ext-lib/jquery.hammer.js"></script> <script src="ext-lib/jquery.hammer.js"></script>
<!-- GSAP: remove from production... -->
<!--
<script src="ext-lib/gsap/TweenLite.min.js"></script>
<script src="ext-lib/gsap/jquery.gsap.min.js"></script>
<script src="ext-lib/gsap/utils/Draggable.min.js"></script>
<script src="ext-lib/gsap/plugins/CSSPlugin.min.js"></script>
-->
<script src="lib/jli.js"></script> <script src="lib/jli.js"></script>

View File

@ -1054,89 +1054,6 @@ var cancelAnimationFrame = (window.cancelAnimationFrame
|| clearTimeout) || clearTimeout)
// NOTE: repatching a date should not lead to any side effects as this
// does not add any state...
function patchDate(date){
date = date || Date
date.prototype.toShortDate = function(){
var y = this.getFullYear()
var M = this.getMonth()+1
M = M < 10 ? '0'+M : M
var D = this.getDate()
D = D < 10 ? '0'+D : D
var H = this.getHours()
H = H < 10 ? '0'+H : H
var m = this.getMinutes()
m = m < 10 ? '0'+m : m
var s = this.getSeconds()
s = s < 10 ? '0'+s : s
return ''+y+'-'+M+'-'+D+' '+H+':'+m+':'+s
}
date.prototype.getTimeStamp = function(no_seconds){
var y = this.getFullYear()
var M = this.getMonth()+1
M = M < 10 ? '0'+M : M
var D = this.getDate()
D = D < 10 ? '0'+D : D
var H = this.getHours()
H = H < 10 ? '0'+H : H
var m = this.getMinutes()
m = m < 10 ? '0'+m : m
var s = this.getSeconds()
s = s < 10 ? '0'+s : s
return ''+y+M+D+H+m+s
}
date.prototype.setTimeStamp = function(ts){
ts = ts.replace(/[^0-9]*/g, '')
this.setFullYear(ts.slice(0, 4))
this.setMonth(ts.slice(4, 6)*1-1)
this.setDate(ts.slice(6, 8))
this.setHours(ts.slice(8, 10))
this.setMinutes(ts.slice(10, 12))
this.setSeconds(ts.slice(12, 14))
return this
}
date.timeStamp = function(){
return (new this()).getTimeStamp()
}
date.fromTimeStamp = function(ts){
return (new this()).setTimeStamp(ts)
}
// convert string time period to milliseconds...
date.str2ms = function(str, dfl){
dfl = dfl || 'ms'
if(typeof(str) == typeof(123)){
var val = str
str = dfl
} else {
var val = parseFloat(str)
str = str.trim()
// check if a unit is given...
str = str == val ? dfl : str
}
var c = /(m(illi)?(-)?s(ec(ond(s)?)?)?)$/i.test(str) ? 1
: /s(ec(ond(s)?)?)?$/i.test(str) ? 1000
: /m(in(ute(s)?)?)?$/i.test(str) ? 1000*60
: /h(our(s)?)?$/i.test(str) ? 1000*60*60
: /d(ay(s)?)?$/i.test(str) ? 1000*60*60*24
: null
return c ? val * c : NaN
}
return date
}
// patch the root date...
patchDate()
function logCalls(func, logger){ function logCalls(func, logger){
var that = this var that = this
var _func = function(){ var _func = function(){

View File

@ -141,6 +141,7 @@ Object.defineProperty(Array.prototype, 'len', {
// convert JS arguments to Array... // convert JS arguments to Array...
var args2array = var args2array =
module.args2array = module.args2array =
@ -151,6 +152,7 @@ function(args){
// Quote a string and convert to RegExp to match self literally. // Quote a string and convert to RegExp to match self literally.
var quoteRegExp = var quoteRegExp =
RegExp.quoteRegExp =
module.quoteRegExp = module.quoteRegExp =
function(str){ function(str){
return str.replace(/([\.\\\/\(\)\[\]\$\*\+\-\{\}\@\^\&\?\<\>])/g, '\\$1') return str.replace(/([\.\\\/\(\)\[\]\$\*\+\-\{\}\@\^\&\?\<\>])/g, '\\$1')
@ -217,6 +219,92 @@ module.selectElemText = function(elem){
/*********************************************************************/
// NOTE: repatching a date should not lead to any side effects as this
// does not add any state...
var patchDate =
module.patchDate = function(date){
date = date || Date
date.prototype.toShortDate = function(){
var y = this.getFullYear()
var M = this.getMonth()+1
M = M < 10 ? '0'+M : M
var D = this.getDate()
D = D < 10 ? '0'+D : D
var H = this.getHours()
H = H < 10 ? '0'+H : H
var m = this.getMinutes()
m = m < 10 ? '0'+m : m
var s = this.getSeconds()
s = s < 10 ? '0'+s : s
return ''+y+'-'+M+'-'+D+' '+H+':'+m+':'+s
}
date.prototype.getTimeStamp = function(no_seconds){
var y = this.getFullYear()
var M = this.getMonth()+1
M = M < 10 ? '0'+M : M
var D = this.getDate()
D = D < 10 ? '0'+D : D
var H = this.getHours()
H = H < 10 ? '0'+H : H
var m = this.getMinutes()
m = m < 10 ? '0'+m : m
var s = this.getSeconds()
s = s < 10 ? '0'+s : s
return ''+y+M+D+H+m+s
}
date.prototype.setTimeStamp = function(ts){
ts = ts.replace(/[^0-9]*/g, '')
this.setFullYear(ts.slice(0, 4))
this.setMonth(ts.slice(4, 6)*1-1)
this.setDate(ts.slice(6, 8))
this.setHours(ts.slice(8, 10))
this.setMinutes(ts.slice(10, 12))
this.setSeconds(ts.slice(12, 14))
return this
}
date.timeStamp = function(){
return (new this()).getTimeStamp()
}
date.fromTimeStamp = function(ts){
return (new this()).setTimeStamp(ts)
}
// convert string time period to milliseconds...
date.str2ms = function(str, dfl){
dfl = dfl || 'ms'
if(typeof(str) == typeof(123)){
var val = str
str = dfl
} else {
var val = parseFloat(str)
str = str.trim()
// check if a unit is given...
str = str == val ? dfl : str
}
var c = /(m(illi)?(-)?s(ec(ond(s)?)?)?)$/i.test(str) ? 1
: /s(ec(ond(s)?)?)?$/i.test(str) ? 1000
: /m(in(ute(s)?)?)?$/i.test(str) ? 1000*60
: /h(our(s)?)?$/i.test(str) ? 1000*60*60
: /d(ay(s)?)?$/i.test(str) ? 1000*60*60*24
: null
return c ? val * c : NaN
}
return date
}
// patch the root date...
patchDate()
/*********************************************************************/ /*********************************************************************/
// XXX experiment // XXX experiment

View File

@ -20,8 +20,14 @@ if((typeof(process) != 'undefined' ? process : {}).__nwjs){
// //
// NOTE: no need to do this in browser... // NOTE: no need to do this in browser...
if(typeof(process) != 'undefined'){ if(typeof(process) != 'undefined'){
var requirejs = require('requirejs') var requirejs = require('requirejs')
global.requirejs = requirejs
if(typeof(window) != 'undefined'){
window.requirejs = requirejs
}
requirejs.config({ requirejs.config({
nodeRequire: require, nodeRequire: require,
//baseUrl: __dirname, //baseUrl: __dirname,