nodejs fixes
This commit is contained in:
parent
dd5237e4ed
commit
7ed524517d
7 changed files with 32 additions and 15 deletions
|
|
@ -1,8 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "@0x2620/oxjs",
|
"name": "@0x2620/oxjs",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"module": "min/Ox.esm.js",
|
"main": "min/Ox/Ox.js",
|
||||||
|
"module": "min/Ox/Ox.js",
|
||||||
"browser": "min/Ox.js",
|
"browser": "min/Ox.js",
|
||||||
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
|
|
|
||||||
|
|
@ -466,6 +466,7 @@ Ox.slice = Ox.toArray = function(collection, start, stop) {
|
||||||
// value. Firefox 3.6 returns an array of undefined values if a string is passed
|
// value. Firefox 3.6 returns an array of undefined values if a string is passed
|
||||||
// as value.
|
// as value.
|
||||||
if (
|
if (
|
||||||
|
typeof document !== 'undefined' && (
|
||||||
Ox.slice([0]).length == 0
|
Ox.slice([0]).length == 0
|
||||||
|| Ox.slice('0')[0] === null
|
|| Ox.slice('0')[0] === null
|
||||||
|| Ox.slice('0')[0] === void 0
|
|| Ox.slice('0')[0] === void 0
|
||||||
|
|
@ -474,7 +475,7 @@ if (
|
||||||
return Ox.slice(document.getElementsByTagName('a'));
|
return Ox.slice(document.getElementsByTagName('a'));
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}())
|
}())
|
||||||
) {
|
)) {
|
||||||
// FIXME: remove toArray alias
|
// FIXME: remove toArray alias
|
||||||
Ox.slice = Ox.toArray = function(collection, start, stop) {
|
Ox.slice = Ox.toArray = function(collection, start, stop) {
|
||||||
var args = stop === void 0 ? [start] : [start, stop],
|
var args = stop === void 0 ? [start] : [start, stop],
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,15 @@ Ox.SHORT_MONTHS = Ox.MONTHS.map(function(val) {
|
||||||
});
|
});
|
||||||
//@ Ox.PATH <s> Path of Ox.js
|
//@ Ox.PATH <s> Path of Ox.js
|
||||||
Ox.PATH = (function() {
|
Ox.PATH = (function() {
|
||||||
// IE8 can't apply slice to NodeLists, see Ox.slice
|
if (typeof document !== 'undefined') {
|
||||||
var index, regexp = /Ox\.js(\?.+|)$/,
|
// IE8 can't apply slice to NodeLists, see Ox.slice
|
||||||
scripts = document.getElementsByTagName('script'), src;
|
var index, regexp = /Ox\.js(\?.+|)$/,
|
||||||
for (index = scripts.length - 1; index >= 0; index--) {
|
scripts = document.getElementsByTagName('script'), src;
|
||||||
src = scripts[index].src;
|
for (index = scripts.length - 1; index >= 0; index--) {
|
||||||
if (regexp.test(src)) {
|
src = scripts[index].src;
|
||||||
return src.replace(regexp, '');
|
if (regexp.test(src)) {
|
||||||
|
return src.replace(regexp, '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FIXME: fix path detection
|
// FIXME: fix path detection
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ Ox.load = function() {
|
||||||
callback(true);
|
callback(true);
|
||||||
} else {
|
} else {
|
||||||
let fn = Ox.noop
|
let fn = Ox.noop
|
||||||
console.log("!!", modules)
|
|
||||||
if ('UI' in modules) {
|
if ('UI' in modules) {
|
||||||
fn = function(callback) {
|
fn = function(callback) {
|
||||||
var path = Ox.PATH + 'UI/jquery/jquery-1.7.1.min.js?' + Ox.VERSION;
|
var path = Ox.PATH + 'UI/jquery/jquery-1.7.1.min.js?' + Ox.VERSION;
|
||||||
|
|
|
||||||
|
|
@ -829,6 +829,13 @@ Ox.documentReady <function> Calls a callback function once the DOM is ready
|
||||||
@*/
|
@*/
|
||||||
Ox.documentReady = (function() {
|
Ox.documentReady = (function() {
|
||||||
var callbacks = [];
|
var callbacks = [];
|
||||||
|
if (typeof document === 'undefined') {
|
||||||
|
return function(callback) {
|
||||||
|
callback();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.onreadystatechange = globalThis.onload = function() {
|
document.onreadystatechange = globalThis.onload = function() {
|
||||||
if (document.readyState == 'complete') {
|
if (document.readyState == 'complete') {
|
||||||
callbacks.forEach(function(callback) {
|
callbacks.forEach(function(callback) {
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,10 @@ Ox.getAsync = function(urls, get, callback) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
if (typeof document == 'undefined') {
|
||||||
|
console.log("running in node, disable some things in Requets.js")
|
||||||
|
return
|
||||||
|
}
|
||||||
var cache = {},
|
var cache = {},
|
||||||
head = document.head
|
head = document.head
|
||||||
|| document.getElementsByTagName('head')[0]
|
|| document.getElementsByTagName('head')[0]
|
||||||
|
|
|
||||||
|
|
@ -443,11 +443,13 @@ Ox.typeOf = function(value) {
|
||||||
// Mobile Safari returns 'DOMWindow' for null and undefined
|
// Mobile Safari returns 'DOMWindow' for null and undefined
|
||||||
// Firefox 30+ returns 'window' for window
|
// Firefox 30+ returns 'window' for window
|
||||||
if (
|
if (
|
||||||
Ox.typeOf((function() { return arguments; }())) != 'arguments'
|
(typeof document != 'undefined') && (
|
||||||
|| Ox.typeOf(document.getElementsByTagName('a')) != 'nodelist'
|
Ox.typeOf((function() { return arguments; }())) != 'arguments'
|
||||||
|| Ox.typeOf(null) != 'null'
|
|| Ox.typeOf(document.getElementsByTagName('a')) != 'nodelist'
|
||||||
|| Ox.typeOf(window) != 'global'
|
|| Ox.typeOf(null) != 'null'
|
||||||
|| Ox.typeOf() != 'undefined'
|
|| Ox.typeOf(window) != 'global'
|
||||||
|
|| Ox.typeOf() != 'undefined'
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Ox.typeOf = function(value) {
|
Ox.typeOf = function(value) {
|
||||||
var type = Object.prototype.toString.call(
|
var type = Object.prototype.toString.call(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue