2
0
Fork 0

Added jshint

This commit is contained in:
Willem 2016-04-23 03:17:50 +02:00
parent 3e1ddaf6eb
commit f37d735890
3 changed files with 129 additions and 101 deletions

View file

@ -21,7 +21,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* jslint browser: true */
/* global angular,define,sqlitePlugin */
/* global angular,define,module,sqlitePlugin */
/**
* FFSpaLoader is an assets loader for single page applications.
@ -147,6 +147,18 @@
*/
var askUrlSubmitLock = false;
/**
* Prints the debug message with prefix to the options.debug.handler if options.debug.enable is true.
* @param {String} message The message to log.
* @private
*/
var utilDebug = function (message) {
if (options.debug.enable !== true) {
return;
}
options.debug.handler(options.debug.prefix+message);
};
/**
* The factory which contains detection helpers and cache backend builders.
*/
@ -290,18 +302,6 @@
}
};
/**
* Prints the debug message with prefix to the options.debug.handler if options.debug.enable is true.
* @param {String} message The message to log.
* @private
*/
var utilDebug = function (message) {
if (options.debug.enable !== true) {
return;
}
options.debug.handler(options.debug.prefix+message);
};
/**
* The default error handler which renders the error in the browser.
* @param {Error|String} err The error object or message.
@ -452,7 +452,11 @@
};
var cacheCheckType = function (type, cb, action) {
cacheHasService(type)?action():cb(new Error('No caching for '+type));
if (cacheHasService(type)) {
action();
} else {
cb(new Error('No caching for '+type));
}
};
/**
@ -1061,6 +1065,91 @@
});
};
/**
* Boots angular modules if enabled.
*
* @param {function} cb Error first callback gets called done.
* @private
*/
var bootAngular = function(cb) {
if (options.boot.angular.enable !== true) {
utilDebug('bootAngular disabled by options');
return cb(null);
}
if (options.boot.angular.modules.length === 0) {
utilDebug('bootAngular disabled by no modules');
return cb(null);
}
utilDebug('bootAngular start '+options.boot.angular.modules);
angular.bootstrap(document, options.boot.angular.modules);
cb(null);
};
/**
* Boot cleanup removed the html tags by id after the timeout.
*
* @private
*/
var bootCleanup = function() {
if (options.boot.cleanup.enable !== true) {
utilDebug('bootCleanup disabled by options');
return;
}
if (options.boot.cleanup.tags.length === 0) {
utilDebug('bootCleanup disabled by no tags ids.');
return;
}
utilDebug('bootCleanup after '+options.boot.cleanup.timeout+' ms.');
setTimeout ( function () {
for (var tagIdx in options.boot.cleanup.tags) {
var tagId = options.boot.cleanup.tags[tagIdx];
var tag = document.getElementById(tagId);
if (tag !== null) {
tag.parentNode.removeChild(tag);
utilDebug('bootCleanup removed '+tagId);
}
}
}, options.boot.cleanup.timeout);
};
/**
* Boots cordova applications which want to use the sqllite plugin as cache.
* Note: On none cordova page it will callback directly.
* Note: On none cordova device page is will timeout if option is set.
*
* @param {function} cb Error first callback gets called device is ready.
* @private
*/
var bootCordova = function(cb) {
if (options.boot.cordova.enable !== true) {
utilDebug('bootCordova disabled by options');
return cb(null);
}
if (factory.detect.cordova() !== true) {
utilDebug('bootCordova disabled by detect');
return cb(null);
}
var startTime = new Date().getTime();
var bootOnce = function() {
var callback = cb;
cb = null;
utilDebug('bootCordova done in '+(new Date().getTime()-startTime)+' ms.');
callback(null);
};
if (options.boot.cordova.timeout > 0) {
utilDebug('bootCordova timeout '+options.boot.cordova.timeout);
setTimeout ( function () {
utilDebug('bootCordova timeout');
bootOnce();
}, options.boot.cordova.timeout);
}
document.addEventListener('deviceready', function () {
rootWindow[options.boot.cordova.flag] = true;
utilDebug('bootCordova '+options.boot.cordova.flag);
bootOnce();
}, false);
};
/**
* Starts the loader.
*
@ -1179,91 +1268,6 @@
}
};
/**
* Boot cleanup removed the html tags by id after the timeout.
*
* @private
*/
var bootCleanup = function() {
if (options.boot.cleanup.enable !== true) {
utilDebug('bootCleanup disabled by options');
return;
}
if (options.boot.cleanup.tags.length === 0) {
utilDebug('bootCleanup disabled by no tags ids.');
return;
}
utilDebug('bootCleanup after '+options.boot.cleanup.timeout+' ms.');
setTimeout ( function () {
for (var tagIdx in options.boot.cleanup.tags) {
var tagId = options.boot.cleanup.tags[tagIdx];
var tag = document.getElementById(tagId);
if (tag !== null) {
tag.parentNode.removeChild(tag);
utilDebug('bootCleanup removed '+tagId);
}
}
}, options.boot.cleanup.timeout);
};
/**
* Boots angular modules if enabled.
*
* @param {function} cb Error first callback gets called done.
* @private
*/
var bootAngular = function(cb) {
if (options.boot.angular.enable !== true) {
utilDebug('bootAngular disabled by options');
return cb(null);
}
if (options.boot.angular.modules.length === 0) {
utilDebug('bootAngular disabled by no modules');
return cb(null);
}
utilDebug('bootAngular start '+options.boot.angular.modules);
angular.bootstrap(document, options.boot.angular.modules);
cb(null);
};
/**
* Boots cordova applications which want to use the sqllite plugin as cache.
* Note: On none cordova page it will callback directly.
* Note: On none cordova device page is will timeout if option is set.
*
* @param {function} cb Error first callback gets called device is ready.
* @private
*/
var bootCordova = function(cb) {
if (options.boot.cordova.enable !== true) {
utilDebug('bootCordova disabled by options');
return cb(null);
}
if (factory.detect.cordova() !== true) {
utilDebug('bootCordova disabled by detect');
return cb(null);
}
var startTime = new Date().getTime();
var bootOnce = function() {
var callback = cb;
cb = null;
utilDebug('bootCordova done in '+(new Date().getTime()-startTime)+' ms.');
callback(null);
};
if (options.boot.cordova.timeout > 0) {
utilDebug('bootCordova timeout '+options.boot.cordova.timeout);
setTimeout ( function () {
utilDebug('bootCordova timeout');
bootOnce();
}, options.boot.cordova.timeout);
}
document.addEventListener('deviceready', function () {
rootWindow[options.boot.cordova.flag] = true;
utilDebug('bootCordova '+options.boot.cordova.flag);
bootOnce();
}, false);
};
// Auto fill handlers and return public object.
options.debug.handler = function(msg) {console.log(msg);};
options.error.handler = utilErrorHandler;

View file

@ -51,6 +51,7 @@
"karma-jasmine": "0.3.8",
"karma-phantomjs-launcher": "1.0.0",
"karma-requirejs": "0.2.6",
"karma-jshint": "0.1.0",
"karma-mocha-reporter": "2.0.1",
"karma-junit-reporter": "0.4.2",
"angular": "^1.4.8",

View file

@ -12,7 +12,7 @@ module.exports = function(config) {
'test/spec-runner.js'],
preprocessors: {
'es5-ff-spa-loader.js': ['coverage']
'es5-ff-spa-loader.js': ['jshint','coverage']
},
reporters: ['coverage', 'mocha', 'junit'],
@ -27,11 +27,34 @@ module.exports = function(config) {
properties: {} // key value pair of properties to add to the <properties> section of the report
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
devel: true,
eqnull: true,
browser: true,
globals: {
cordova: true,
jQuery: true
}
},
summary: true
},
plugins: [
'karma-requirejs',
'karma-coverage',
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-jshint',
'karma-mocha-reporter',
'karma-junit-reporter'
],