[TASK] Move polyfills and test properties
This commit is contained in:
parent
e1f118fb33
commit
ebc3ca4804
@ -19,5 +19,8 @@
|
||||
"wc": {
|
||||
"limit": 5000
|
||||
}
|
||||
}
|
||||
},
|
||||
"ignore": [
|
||||
"polyfill.js"
|
||||
]
|
||||
}
|
||||
|
53
app.js
53
app.js
@ -1,57 +1,4 @@
|
||||
'use strict';
|
||||
// Node search polyfill for mobile browsers and IE
|
||||
if (!String.prototype.includes) {
|
||||
String.prototype.includes = function () {
|
||||
return String.prototype.indexOf.apply(this, arguments) !== -1;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.startsWith) {
|
||||
String.prototype.startsWith = function (searchString, position) {
|
||||
position = position || 0;
|
||||
return this.substr(position, searchString.length) === searchString;
|
||||
};
|
||||
}
|
||||
if (!String.prototype.repeat) {
|
||||
String.prototype.repeat = function (count) {
|
||||
'use strict';
|
||||
if (this === null) {
|
||||
throw new TypeError('can\'t convert ' + this + ' to object');
|
||||
}
|
||||
var str = '' + this;
|
||||
count = +count;
|
||||
if (count < 0) {
|
||||
throw new RangeError('repeat count must be non-negative');
|
||||
}
|
||||
if (count === Infinity) {
|
||||
throw new RangeError('repeat count must be less than infinity');
|
||||
}
|
||||
count = Math.floor(count);
|
||||
if (str.length === 0 || count === 0) {
|
||||
return '';
|
||||
}
|
||||
// Ensuring count is a 31-bit integer allows us to heavily optimize the
|
||||
// main part. But anyway, most current (August 2014) browsers can't handle
|
||||
// strings 1 << 28 chars or longer, so:
|
||||
if (str.length * count >= 1 << 28) {
|
||||
throw new RangeError('repeat count must not overflow maximum string size');
|
||||
}
|
||||
var rpt = '';
|
||||
for (; ;) {
|
||||
if ((count & 1) === 1) {
|
||||
rpt += str;
|
||||
}
|
||||
count >>>= 1;
|
||||
if (count === 0) {
|
||||
break;
|
||||
}
|
||||
str += str;
|
||||
}
|
||||
// Could we try:
|
||||
// return Array(count + 1).join(this);
|
||||
return rpt;
|
||||
};
|
||||
}
|
||||
|
||||
require.config({
|
||||
baseUrl: 'lib',
|
||||
|
@ -4,7 +4,7 @@ module.exports = function (gulp, plugins, config) {
|
||||
.pipe(gulp.dest(config.build));
|
||||
gulp.src(['assets/logo.svg'])
|
||||
.pipe(gulp.dest(config.build));
|
||||
gulp.src('node_modules/promise-polyfill/promise.js')
|
||||
gulp.src(['node_modules/promise-polyfill/promise.js', 'polyfill.js'])
|
||||
.pipe(gulp.dest(config.build + '/vendor'));
|
||||
return gulp.src(['assets/fonts/*', 'assets/icons/fonts/*'])
|
||||
.pipe(gulp.dest(config.build + '/fonts'));
|
||||
|
@ -8,6 +8,7 @@
|
||||
<!-- inject:config -->
|
||||
<!-- contents of html partials will be injected here -->
|
||||
<!-- endinject -->
|
||||
<script src="vendor/polyfill.js" inline></script>
|
||||
<script src="vendor/promise.js" inline></script>
|
||||
<script src="app.js"></script>
|
||||
</head>
|
||||
|
@ -7,7 +7,9 @@ define(function () {
|
||||
n.nodes = {};
|
||||
|
||||
for (var key in data.nodes) {
|
||||
n.nodes[key] = data.nodes[key].filter(filter);
|
||||
if (data.nodes.hasOwnProperty(key)) {
|
||||
n.nodes[key] = data.nodes[key].filter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
var filteredIds = new Set();
|
||||
|
@ -140,8 +140,10 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
|
||||
}
|
||||
|
||||
for (var i in config.dataPath) {
|
||||
urls.push(config.dataPath[i] + 'nodes.json');
|
||||
urls.push(config.dataPath[i] + 'graph.json');
|
||||
if (config.dataPath.hasOwnProperty(i)) {
|
||||
urls.push(config.dataPath[i] + 'nodes.json');
|
||||
urls.push(config.dataPath[i] + 'graph.json');
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
@ -68,8 +68,10 @@ define({
|
||||
|
||||
listReplace: function listReplace(s, subst) {
|
||||
for (var key in subst) {
|
||||
var re = new RegExp(key, 'g');
|
||||
s = s.replace(re, subst[key]);
|
||||
if (subst.hasOwnProperty(key)) {
|
||||
var re = new RegExp(key, 'g');
|
||||
s = s.replace(re, subst[key]);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
},
|
||||
|
80
polyfill.js
Normal file
80
polyfill.js
Normal file
@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
// Polyfills for (old) mobile browsers and IE 11
|
||||
// From https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/
|
||||
if (!String.prototype.includes) {
|
||||
String.prototype.includes = function () {
|
||||
return String.prototype.indexOf.apply(this, arguments) !== -1;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.startsWith) {
|
||||
String.prototype.startsWith = function (searchString, position) {
|
||||
position = position || 0;
|
||||
return this.substr(position, searchString.length) === searchString;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.repeat) {
|
||||
String.prototype.repeat = function (count) {
|
||||
'use strict';
|
||||
if (this === null) {
|
||||
throw new TypeError('can\'t convert ' + this + ' to object');
|
||||
}
|
||||
var str = '' + this;
|
||||
count = +count;
|
||||
if (count < 0) {
|
||||
throw new RangeError('repeat count must be non-negative');
|
||||
}
|
||||
if (count === Infinity) {
|
||||
throw new RangeError('repeat count must be less than infinity');
|
||||
}
|
||||
count = Math.floor(count);
|
||||
if (str.length === 0 || count === 0) {
|
||||
return '';
|
||||
}
|
||||
// Ensuring count is a 31-bit integer allows us to heavily optimize the
|
||||
// main part. But anyway, most current (August 2014) browsers can't handle
|
||||
// strings 1 << 28 chars or longer, so:
|
||||
if (str.length * count >= 1 << 28) {
|
||||
throw new RangeError('repeat count must not overflow maximum string size');
|
||||
}
|
||||
var rpt = '';
|
||||
for (; ;) {
|
||||
if ((count & 1) === 1) {
|
||||
rpt += str;
|
||||
}
|
||||
count >>>= 1;
|
||||
if (count === 0) {
|
||||
break;
|
||||
}
|
||||
str += str;
|
||||
}
|
||||
// Could we try:
|
||||
// return Array(count + 1).join(this);
|
||||
return rpt;
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof Object.assign !== 'function') {
|
||||
Object.assign = function(target, varArgs) { // .length of function is 2
|
||||
if (target == null) { // TypeError if undefined or null
|
||||
throw new TypeError('Cannot convert undefined or null to object');
|
||||
}
|
||||
|
||||
var to = Object(target);
|
||||
|
||||
for (var index = 1; index < arguments.length; index++) {
|
||||
var nextSource = arguments[index];
|
||||
|
||||
if (nextSource != null) { // Skip over if undefined or null
|
||||
for (var nextKey in nextSource) {
|
||||
// Avoid bugs when hasOwnProperty is shadowed
|
||||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
||||
to[nextKey] = nextSource[nextKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return to;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user