Fix defalt value

This commit is contained in:
Dennis Eichhorn 2018-04-24 22:55:52 +02:00
parent e2555e7b0d
commit a5474c68cb
8 changed files with 24 additions and 63 deletions

View File

@ -39,10 +39,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Config.Options.prototype.set = function (key, value, overwrite) jsOMS.Config.Options.prototype.set = function (key, value, overwrite = false)
{ {
overwrite = typeof overwrite === 'undefined' ? overwrite : false;
if (overwrite || typeof this.options[key] === 'undefined') { if (overwrite || typeof this.options[key] === 'undefined') {
this.options[key] = value; this.options[key] = value;

View File

@ -165,15 +165,12 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Event.EventManager.prototype.attach = function (group, callback, remove, reset) jsOMS.Event.EventManager.prototype.attach = function (group, callback, remove = false, reset = false)
{ {
if (this.callbacks.hasOwnProperty(group)) { if (this.callbacks.hasOwnProperty(group)) {
return false; return false;
} }
remove = typeof remove === 'undefined' ? false : remove;
reset = typeof reset === 'undefined' ? false : reset;
this.callbacks[group] = {remove: remove, reset: reset, func: callback}; this.callbacks[group] = {remove: remove, reset: reset, func: callback};
return true; return true;

View File

@ -180,10 +180,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.emergency = function (message, context) jsOMS.Log.Logger.prototype.emergency = function (message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.EMERGENCY); this.write(message, context, jsOMS.Log.LogLevel.EMERGENCY);
}; };
@ -199,10 +197,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.alert = function (message, context) jsOMS.Log.Logger.prototype.alert = function (message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.ALERT); this.write(message, context, jsOMS.Log.LogLevel.ALERT);
}; };
@ -218,10 +214,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.critical = function (message, context) jsOMS.Log.Logger.prototype.critical = function (message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.CRITICAL); this.write(message, context, jsOMS.Log.LogLevel.CRITICAL);
}; };
@ -237,10 +231,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.error = function (message, context) jsOMS.Log.Logger.prototype.error = function (message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.ERROR); this.write(message, context, jsOMS.Log.LogLevel.ERROR);
}; };
@ -256,10 +248,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.warning = function (message, context) jsOMS.Log.Logger.prototype.warning = function (message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.WARNING); this.write(message, context, jsOMS.Log.LogLevel.WARNING);
}; };
@ -275,10 +265,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.notice = function (message, context) jsOMS.Log.Logger.prototype.notice = function (message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.NOTICE); this.write(message, context, jsOMS.Log.LogLevel.NOTICE);
}; };
@ -294,10 +282,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.info = function (message, context) jsOMS.Log.Logger.prototype.info = function (message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.INFO); this.write(message, context, jsOMS.Log.LogLevel.INFO);
}; };
@ -313,10 +299,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.debug = function (message, context) jsOMS.Log.Logger.prototype.debug = function (message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.DEBUG); this.write(message, context, jsOMS.Log.LogLevel.DEBUG);
}; };
@ -333,10 +317,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.log = function (level, message, context) jsOMS.Log.Logger.prototype.log = function (level, message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, level); this.write(message, context, level);
}; };
@ -353,10 +335,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Log.Logger.prototype.console = function (level, message, context) jsOMS.Log.Logger.prototype.console = function (level, message, context = {})
{ {
context = typeof context === 'undefined' ? {} : context;
this.write(message, context, jsOMS.Log.LogLevel.INFO); this.write(message, context, jsOMS.Log.LogLevel.INFO);
}; };
}(window.jsOMS = window.jsOMS || {})); }(window.jsOMS = window.jsOMS || {}));

View File

@ -31,11 +31,11 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.UI.Input.Voice.ReadManager = function (lang) jsOMS.UI.Input.Voice.ReadManager = function (lang = 'en-US')
{ {
this.pitch = 1; this.pitch = 1;
this.rate = 1; this.rate = 1;
this.lang = typeof lang === 'undefined' ? 'en-US' : lang; this.lang = lang;
this.voices = []; this.voices = [];
this.voice = null; this.voice = null;

View File

@ -31,11 +31,11 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.UI.Input.Voice.VoiceManager = function (app, commands, lang) jsOMS.UI.Input.Voice.VoiceManager = function (app, commands = {}, lang = 'en-US')
{ {
this.app = app; this.app = app;
this.commands = typeof commands === 'undefined' ? {} : commands; this.commands = commands;
this.lang = typeof lang === 'undefined' ? 'en-US' : lang; this.lang = lang;
this.recognition = null; this.recognition = null;
this.speechRecognitionList = null; this.speechRecognitionList = null;

View File

@ -51,10 +51,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Uri.Http.parseUrl = function (str, mode) jsOMS.Uri.Http.parseUrl = function (str, mode = 'php')
{ {
mode = typeof mode === 'undefined' ? 'php' : mode;
const key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port', const key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
'relative', 'path', 'directory', 'file', 'query', 'fragment' 'relative', 'path', 'directory', 'file', 'query', 'fragment'
], ],

View File

@ -24,10 +24,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.trim = function(str, char) jsOMS.trim = function(str, char = ' ')
{ {
char = typeof char === 'undefined' ? ' ' : char;
return jsOMS.ltrim(jsOMS.rtrim(str, char), char); return jsOMS.ltrim(jsOMS.rtrim(str, char), char);
}; };
@ -43,10 +41,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.rtrim = function(str, char) jsOMS.rtrim = function(str, char = ' ')
{ {
char = typeof char === 'undefined' ? ' ' : char;
return str.replace(new RegExp("[" + char + "]*$"), ''); return str.replace(new RegExp("[" + char + "]*$"), '');
}; };
@ -62,10 +58,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.ltrim = function(str, char) jsOMS.ltrim = function(str, char = ' ')
{ {
char = typeof char === 'undefined' ? ' ' : char;
return str.replace(new RegExp("^[" + char + "]*"), ''); return str.replace(new RegExp("^[" + char + "]*"), '');
}; };

View File

@ -57,10 +57,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.trim = function(str, char) jsOMS.trim = function(str, char = ' ')
{ {
char = typeof char === 'undefined' ? ' ' : char;
return jsOMS.ltrim(jsOMS.rtrim(str, char), char); return jsOMS.ltrim(jsOMS.rtrim(str, char), char);
}; };
@ -76,10 +74,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.rtrim = function(str, char) jsOMS.rtrim = function(str, char = ' ')
{ {
char = typeof char === 'undefined' ? ' ' : char;
return str.replace(new RegExp("[" + char + "]*$"), ''); return str.replace(new RegExp("[" + char + "]*$"), '');
}; };
@ -95,10 +91,8 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.ltrim = function(str, char) jsOMS.ltrim = function(str, char = ' ')
{ {
char = typeof char === 'undefined' ? ' ' : char;
return str.replace(new RegExp("^[" + char + "]*"), ''); return str.replace(new RegExp("^[" + char + "]*"), '');
}; };