self-timer
Advanced tools
Comparing version 1.4.1 to 1.4.2
# self-timer.js Change log | ||
## version 1.4.1 2017/03/12 | ||
## version 1.4.2 [ 2017/03/12 ] | ||
enhanced `is().Lang*` methods. | ||
now you can use insensitive characters for detect browser-language, like `**en-us** or **en-US**`. | ||
## version 1.4.1 [ 2017/03/12 ] | ||
added `info()` method | ||
@@ -5,0 +10,0 @@ |
@@ -193,6 +193,15 @@ !function(e){function n(){}function t(e,n){return function(){e.apply(n,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(e,this)}function i(e,n){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(n):(e._handled=!0,void o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null===t)return void(1===e._state?r:u)(n.promise,e._value);var o;try{o=t(e._value)}catch(i){return void u(n.promise,i)}r(n.promise,o)}))}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var i=n.then;if(n instanceof o)return e._state=3,e._value=n,void f(e);if("function"==typeof i)return void s(t(i,n),e)}e._state=1,e._value=n,f(e)}catch(r){u(e,r)}}function u(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n<t;n++)i(e,e._deferreds[n]);e._deferreds=null}function c(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}function s(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,u(n,e))})}catch(o){if(t)return;t=!0,u(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var o=new this.constructor(n);return i(this,new c(e,t,o)),o},o.all=function(e){var n=Array.prototype.slice.call(e);return new o(function(e,t){function o(r,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var f=u.then;if("function"==typeof f)return void f.call(u,function(e){o(r,e)},t)}n[r]=u,0===--i&&e(n)}catch(c){t(c)}}if(0===n.length)return e([]);for(var i=n.length,r=0;r<n.length;r++)o(r,n[r])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(n,t){for(var o=0,i=e.length;o<i;o++)e[o].then(n,t)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},o._setImmediateFn=function(e){o._immediateFn=e},o._setUnhandledRejectionFn=function(e){o._unhandledRejectionFn=e},"undefined"!=typeof module&&module.exports?module.exports=o:e.Promise||(e.Promise=o)}(this); | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -208,3 +217,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -917,3 +927,3 @@ | ||
return lang == _helper.__detectLang() | ||
return lang.toLowerCase() == _helper.__detectLang() | ||
? resolve(true) | ||
@@ -941,3 +951,3 @@ : _Condition === true ? reject(false) : false; | ||
return lang == detect.slice(0, 2) | ||
return lang.toLowerCase() == detect.slice(0, 2) | ||
? resolve(true) | ||
@@ -965,3 +975,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(languages, _helper.__detectLang()) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -990,3 +1003,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(lang, detect.slice(0, 2)) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1012,3 +1028,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(languages, _helper.__detectLang()) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -1036,3 +1055,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(lang, detect.slice(0, 2)) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1039,0 +1061,0 @@ : _Condition === true ? reject(false) : false; |
@@ -1,1 +0,1 @@ | ||
!function(e){function t(){}function r(e,t){return function(){e.apply(t,arguments)}}function n(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(e,this)}function o(e,t){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(t):(e._handled=!0,void n._immediateFn(function(){var r=1===e._state?t.onFulfilled:t.onRejected;if(null===r)return void(1===e._state?i:u)(t.promise,e._value);var n;try{n=r(e._value)}catch(e){return void u(t.promise,e)}i(t.promise,n)}))}function i(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var o=t.then;if(t instanceof n)return e._state=3,e._value=t,void a(e);if("function"==typeof o)return void c(r(o,t),e)}e._state=1,e._value=t,a(e)}catch(t){u(e,t)}}function u(e,t){e._state=2,e._value=t,a(e)}function a(e){2===e._state&&0===e._deferreds.length&&n._immediateFn(function(){e._handled||n._unhandledRejectionFn(e._value)});for(var t=0,r=e._deferreds.length;t<r;t++)o(e,e._deferreds[t]);e._deferreds=null}function s(e,t,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=r}function c(e,t){var r=!1;try{e(function(e){r||(r=!0,i(t,e))},function(e){r||(r=!0,u(t,e))})}catch(e){if(r)return;r=!0,u(t,e)}}var f=setTimeout;n.prototype.catch=function(e){return this.then(null,e)},n.prototype.then=function(e,r){var n=new this.constructor(t);return o(this,new s(e,r,n)),n},n.all=function(e){var t=Array.prototype.slice.call(e);return new n(function(e,r){function n(i,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var a=u.then;if("function"==typeof a)return void a.call(u,function(e){n(i,e)},r)}t[i]=u,0===--o&&e(t)}catch(e){r(e)}}if(0===t.length)return e([]);for(var o=t.length,i=0;i<t.length;i++)n(i,t[i])})},n.resolve=function(e){return e&&"object"==typeof e&&e.constructor===n?e:new n(function(t){t(e)})},n.reject=function(e){return new n(function(t,r){r(e)})},n.race=function(e){return new n(function(t,r){for(var n=0,o=e.length;n<o;n++)e[n].then(t,r)})},n._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){f(e,0)},n._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},n._setImmediateFn=function(e){n._immediateFn=e},n._setUnhandledRejectionFn=function(e){n._unhandledRejectionFn=e},"undefined"!=typeof module&&module.exports?module.exports=n:e.Promise||(e.Promise=n)}(this),function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.SelfTimer=t()}(this,function(){"use strict";function e(e){this.D=e}return e.prototype.helpers=function(){var e=this.D,t=(this.D.getDay(),function(e){return"function"==typeof e||void 0==e}),r=function(e,t){for(var r=e.length;r--;)if(e[r]===t)return!0;return!1},n=function(e){return e.map(function(e){return e.replace(/Sun/g,0)}).map(function(e){return e.replace(/Mon/g,1)}).map(function(e){return e.replace(/Tue/g,2)}).map(function(e){return e.replace(/Wed/g,3)}).map(function(e){return e.replace(/Thu/g,4)}).map(function(e){return e.replace(/Fri/g,5)}).map(function(e){return e.replace(/Sat/g,6)}).map(function(e){return parseInt(e)})},o=function(e){var t=e.split(/:|\s/),r=new Date;return"pm"==t.pop().toLowerCase()&&(t[0]=+t[0]+12),r.setHours(+t.shift()),r.setMinutes(+t.shift()),r},i=function(e,t){1==arguments.length&&(t=e,e=0);for(var r=[],n=0;n<t;n++)r.push(e-n);return r},u=function(e,t,r){return r<t.setDate(t.getDate()+1)&&r>e},a=function(){var t=e.getMonth()+1,r=e.getDate();return t.length<2&&(t="0"+t),r.length<2&&(r="0"+r),[t,r].join("-")},s=function(e){var t;switch(e){case"s":case"sec":case"second":case"seconds":t=1e3;break;case"m":case"min":case"minute":case"minutes":t=6e4;break;default:t=!1}return t},c=function(){return"undefined"===navigator.userLanguage?navigator.userLanguage:navigator.language},f={__checkIsValid:t,__contains:r,__dayOfTheWeekStringToNumber:n,__timeObject:o,__range:i,__dateCompare:u,__dateString:a,__typeToMilliseconds:s,__detectLang:c};return f},e.prototype.messages=function(e){return{day:"Error: A day should be less than 31",month:"Error: month should be untll 12",date:"Error: date format shoud be MM-DD",year:"Error: date format shoud be 20YY",monthBetween:"Error: start of month should be less than end of month",startHour:"Error: start hour should be less than 23",endHour:"Error: end hour should be until 23",hourFormat:"Error: hours should be numberic",isNotValidHour:"Error: hour should be until 23",startDay:"Error: start day should be less than 30",endDay:"Error: end day should be untill 31",time:"Error: invalid time format. time should be [hh:mm AM or PM]",isNotArray:"Error: first argument shold be Array",dateGrater:"start date should not be grater than end-of -date",dateSameDay:"start and end date are should not be same date ",timeFormat:"Error: time of type formats",numFormat:"Error: num should be numberic",taskFormat:"Error: "+e+" should be object or function",notExist:"Error: "+e+" not exist",shouldBeFunction:"Error: "+e+" is shold be function",onlyBrowser:"Error: "+e+" is just supported web-browser"}},e.prototype.formats=function(){return{date:/^(1[0-2]|[1-9])-([1-9]|[12]\d|3[0-1])$/,year:/^[2][0][1-9]{2}$/,annual:/^[2]{1}[0]{1}[1-3]{1}[0-9]{1}-[01]{1}[0-9]{1}-[0-3]{1}[0-9]{1}$/,time:/^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$/}},e.prototype.info=function(){return{version:"1.4.1",method:{on:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Weekdays","Weekend","Selects","Annual","DatesBetween","DatesContain"],at:["Between","Unless","Hour","HoursBetween","HourSelects"],in:["Day","Days","DaysBetween","Month","MonthSelects","Year"],is:["True","False","Language","Lang","LanguageSelects","LangSelects","LanguageExcepts","LangExcepts"],timer:["After"]}}},e.prototype.on=function(e){var t=e,r=this.D,n=this.D.getDay(),o=this.messages(),i=this.helpers(),u=this.formats(),a=function(){return new Promise(function(e,r){return 0===n?e(!0):t===!0&&r(!1)})},s=function(){return new Promise(function(e,r){return 1===n?e(!0):t===!0&&r(!1)})},c=function(){return new Promise(function(e,r){return 2===n?e(!0):t===!0&&r(!1)})},f=function(){return new Promise(function(e,r){return 3===n?e(!0):t===!0&&r(!1)})},h=function(){return new Promise(function(e,r){return 4===n?e(!0):t===!0&&r(!1)})},d=function(){return new Promise(function(e,r){return 5===n?e(!0):t===!0&&r(!1)})},l=function(){return new Promise(function(e,r){return 6===n?e(!0):t===!0&&r(!1)})},m=function(e){return new Promise(function(r,u){try{if(!Array.isArray(e))throw o.isNotArray;var a=i.__dayOfTheWeekStringToNumber(e);return i.__contains(a,n)?r(!0):t===!0&&u(!1)}catch(e){return void console.error(e)}})},y=function(){return new Promise(function(e,r){var o=[1,2,3,4,5];return i.__contains(o,n)?e(!0):t===!0&&r(!1)})},w=function(){return new Promise(function(e,r){var o=[0,6];return i.__contains(o,n)?e(!0):t===!0&&r(!1)})},_=function(e){return new Promise(function(r,n){try{if(!e.match(u.date))throw o.date;return e==i.__dateString()?r(!0):t===!0&&n(!1)}catch(e){return void console.error(e)}})},p=function(e,n){return new Promise(function(u,a){var s=new Date(e),c=new Date(n);try{if(s>c)throw o.dateGrater;if(s==c)throw o.dateSameDay;return i.__dateCompare(s,c,r)?u(!0):t===!0&&a(!1)}catch(e){return void console.error(e)}})},g=function(e){return new Promise(function(n,u){try{if(!Array.isArray(e))throw o.isNotArray;return i.__contains(e,r.toISOString().slice(0,10))?n(!0):t===!0&&u(!1)}catch(e){return void console.error(e)}})},v={Sunday:a,Monday:s,Tuesday:c,Wednesday:f,Thursday:h,Friday:d,Saturday:l,Selects:m,Weekdays:y,Weekend:w,Annual:_,DatesBetween:p,DatesContain:g};return v},e.prototype.at=function(e){var t=e,r=this.D,n=(this.D.getDay(),this.D.getHours()),o=this.messages(),i=this.helpers(),u=this.formats(),a=function(e,n){return new Promise(function(a,s){try{if(!e.match(u.time))throw o.time+"at start";if(!n.match(u.time))throw o.time+" at end";var c=r<i.__timeObject(n)&&r>i.__timeObject(e);return c?a(!0):t===!0&&s(!1)}catch(e){return void console.error(e)}})},s=function(e,n){return new Promise(function(a,s){try{if(!e.match(u.time))throw o.time+"at start";if(!n.match(u.time))throw o.time+" at end";var c=r<i.__timeObject(n)&&r>i.__timeObject(e);return c?t===!0&&s(!1):a(!0)}catch(e){return void console.error(e)}})},c=function(e){return new Promise(function(r,i){var u=parseInt(e);try{if(u>23)throw o.startHour;return u===n?r(!0):t===!0&&i(!1)}catch(e){return void console.error(e)}})},f=function(e,r){return new Promise(function(u,a){var s=parseInt(e),c=parseInt(r);try{if(s>23)throw o.startHour;if(c>23)throw o.endHour;var f=i.__range(c,c-s);return f.push(e),i.__contains(f,n)?u(!0):t===!0&&a(!1)}catch(e){return void console.error(e)}})},h=function(e,r){return new Promise(function(r,u){try{if(!Array.isArray(e))throw o.isNotArray;if(1!=!e.some(isNaN))throw o.hourFormat;var a=e.map(function(e){return parseInt(e)});return a.map(function(e){if(e>23)throw o.isNotValidHour}),i.__contains(a,n)?r(!0):t===!0&&u(!1)}catch(e){return void console.error(e)}})},d={Between:a,Unless:s,Hour:c,HoursBetween:f,HourSelects:h};return d},e.prototype.in=function(e){var t=e,r=this.messages(),n=this.helpers(),o=this.formats(),i=(this.D,this.D.getDate()),u=this.D.getMonth()+1,a=this.D.getFullYear(),s=function(e){return new Promise(function(r,n){try{if(parseInt(e)>31)throw __message.day;return e==i?r(!0):t===!0&&n(!1)}catch(e){return void console.error(e)}})},c=function(e){return new Promise(function(o,u){try{if(!Array.isArray(e))throw r.isNotArray;var a=e.map(function(e){return parseInt(e)});return n.__contains(a,i)?o(!0):t===!0&&u(!1)}catch(e){return void console.error(e)}})},f=function(e,o){return new Promise(function(u,a){try{var s=parseInt(e),c=parseInt(o);if(s>30)throw r.startDay;if(c>31)throw r.endDay;var f=n.__range(c,c-s);return f.push(e),n.__contains(f,i)?u(!0):t===!0&&a(!1)}catch(e){return void console.error(e)}})},h=function(e){return new Promise(function(n,o){try{if(parseInt(e)>12)throw r.month;var i=e<10?"0"+e:e;return i==u?n(!0):t===!0&&o(!1)}catch(e){return void console.error(e)}})},d=function(e){return new Promise(function(o,i){try{if(!Array.isArray(e))throw r.isNotArray;return n.__contains(e,u)?o(!0):t===!0&&i(!1)}catch(e){return void console.error(e)}})},l=function(e){return new Promise(function(n,i){try{if(!e.toString().match(o.year))throw r.year;return e==a?n(!0):t===!0&&i(!1)}catch(e){return void console.error(e)}})},m={Day:s,Days:c,DaysBetween:f,Month:h,MonthSelects:d,Year:l};return m},e.prototype.is=function(e){var t=e,r=this.helpers(),n=this.messages(),o=function(e){return new Promise(function(r,n){return e?r(!0):t===!0&&n(!1)})},i=function(e){return new Promise(function(r,n){return e?t===!0&&n(!1):r(!0)})},u=function(e){return new Promise(function(n,o){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;return e==r.__detectLang()?n(!0):t===!0&&o(!1)}catch(e){return void console.error(e)}})},a=function(e){return new Promise(function(n,o){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;var i=r.__detectLang();return e==i.slice(0,2)?n(!0):t===!0&&o(!1)}catch(e){return void console.error(e)}})},s=function(e){return new Promise(function(o,i){try{if("undefined"===window)throw this.messages("LanguageSelects").onlyBrowser;if(!Array.isArray(e))throw n.isNotArray;return r.__contains(e,r.__detectLang())?o(!0):t===!0&&i(!1)}catch(e){return void console.error(e)}})},c=function(e){try{if("undefined"===window)throw this.messages("LangSelects").onlyBrowser;if(!Array.isArray(e))throw n.isNotArray;var o=r.__detectLang();return r.__contains(e,o.slice(0,2))?resolve(!0):t===!0&&reject(!1)}catch(e){return void console.error(e)}},f=function(e){try{if("undefined"===window)throw this.messages("LanguageExcepts").onlyBrowser;if(!Array.isArray(e))throw n.isNotArray;return r.__contains(e,r.__detectLang())?t===!0&&reject(!1):resolve(!0)}catch(e){return void console.error(e)}},h=function(e){try{if("undefined"===window)throw this.messages("LangExcepts").onlyBrowser;if(!Array.isArray(e))throw n.isNotArray;var o=r.__detectLang();return r.__contains(e,o.slice(0,2))?t===!0&&reject(!1):resolve(!0)}catch(e){return void console.error(e)}},d={True:o,False:i,Language:u,Lang:a,LanguageSelects:s,LangSelects:c,LanguageExcepts:f,LangExcepts:h};return d},e.prototype.timer=function(){var e=this.messages(),t=this.helpers(),r=function(r,n,o){return new Promise(function(i){var u=t.__typeToMilliseconds(r),a=typeof o;try{if(!u)throw e.timeFormat;if(isNaN(n))throw e.numFormat;if(0===n||"0"===n)throw e.numFormat;if(!t.__contains(["object","function","undefined"],a))throw this.messages("type").taskFormat;if("object"===a){if(!("before"in o))throw this.messages("key:before").notExist;if("function"!=typeof o.before)throw this.messages("before").shouldBeFunction;return o.before(),setTimeout(function(){return i(!0)},n*u)}return setTimeout(function(){return i(!0)},n*u)}catch(e){return void console.error(e)}})},n={After:r};return n},e}); | ||
!function(e){function r(){}function t(e,r){return function(){e.apply(r,arguments)}}function n(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(e,this)}function o(e,r){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(r):(e._handled=!0,void n._immediateFn(function(){var t=1===e._state?r.onFulfilled:r.onRejected;if(null===t)return void(1===e._state?i:a)(r.promise,e._value);var n;try{n=t(e._value)}catch(e){return void a(r.promise,e)}i(r.promise,n)}))}function i(e,r){try{if(r===e)throw new TypeError("A promise cannot be resolved with itself.");if(r&&("object"==typeof r||"function"==typeof r)){var o=r.then;if(r instanceof n)return e._state=3,e._value=r,void u(e);if("function"==typeof o)return void c(t(o,r),e)}e._state=1,e._value=r,u(e)}catch(r){a(e,r)}}function a(e,r){e._state=2,e._value=r,u(e)}function u(e){2===e._state&&0===e._deferreds.length&&n._immediateFn(function(){e._handled||n._unhandledRejectionFn(e._value)});for(var r=0,t=e._deferreds.length;r<t;r++)o(e,e._deferreds[r]);e._deferreds=null}function s(e,r,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof r?r:null,this.promise=t}function c(e,r){var t=!1;try{e(function(e){t||(t=!0,i(r,e))},function(e){t||(t=!0,a(r,e))})}catch(e){if(t)return;t=!0,a(r,e)}}var f=setTimeout;n.prototype.catch=function(e){return this.then(null,e)},n.prototype.then=function(e,t){var n=new this.constructor(r);return o(this,new s(e,t,n)),n},n.all=function(e){var r=Array.prototype.slice.call(e);return new n(function(e,t){function n(i,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var u=a.then;if("function"==typeof u)return void u.call(a,function(e){n(i,e)},t)}r[i]=a,0===--o&&e(r)}catch(e){t(e)}}if(0===r.length)return e([]);for(var o=r.length,i=0;i<r.length;i++)n(i,r[i])})},n.resolve=function(e){return e&&"object"==typeof e&&e.constructor===n?e:new n(function(r){r(e)})},n.reject=function(e){return new n(function(r,t){t(e)})},n.race=function(e){return new n(function(r,t){for(var n=0,o=e.length;n<o;n++)e[n].then(r,t)})},n._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){f(e,0)},n._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},n._setImmediateFn=function(e){n._immediateFn=e},n._setUnhandledRejectionFn=function(e){n._unhandledRejectionFn=e},"undefined"!=typeof module&&module.exports?module.exports=n:e.Promise||(e.Promise=n)}(this),function(e,r){"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():e.SelfTimer=r()}(this,function(){"use strict";function e(e){this.D=e}return e.prototype.helpers=function(){var e=this.D,r=(this.D.getDay(),function(e){return"function"==typeof e||void 0==e}),t=function(e,r){for(var t=e.length;t--;)if(e[t]===r)return!0;return!1},n=function(e){return e.map(function(e){return e.replace(/Sun/g,0)}).map(function(e){return e.replace(/Mon/g,1)}).map(function(e){return e.replace(/Tue/g,2)}).map(function(e){return e.replace(/Wed/g,3)}).map(function(e){return e.replace(/Thu/g,4)}).map(function(e){return e.replace(/Fri/g,5)}).map(function(e){return e.replace(/Sat/g,6)}).map(function(e){return parseInt(e)})},o=function(e){var r=e.split(/:|\s/),t=new Date;return"pm"==r.pop().toLowerCase()&&(r[0]=+r[0]+12),t.setHours(+r.shift()),t.setMinutes(+r.shift()),t},i=function(e,r){1==arguments.length&&(r=e,e=0);for(var t=[],n=0;n<r;n++)t.push(e-n);return t},a=function(e,r,t){return t<r.setDate(r.getDate()+1)&&t>e},u=function(){var r=e.getMonth()+1,t=e.getDate();return r.length<2&&(r="0"+r),t.length<2&&(t="0"+t),[r,t].join("-")},s=function(e){var r;switch(e){case"s":case"sec":case"second":case"seconds":r=1e3;break;case"m":case"min":case"minute":case"minutes":r=6e4;break;default:r=!1}return r},c=function(){return"undefined"===navigator.userLanguage?navigator.userLanguage.toLowerCase():navigator.language.toLowerCase()},f=function(e){return e.map(function(e){return e.toLowerCase()})},h={__checkIsValid:r,__contains:t,__dayOfTheWeekStringToNumber:n,__timeObject:o,__range:i,__dateCompare:a,__dateString:u,__typeToMilliseconds:s,__detectLang:c,__arrayToLower:f};return h},e.prototype.messages=function(e){return{day:"Error: A day should be less than 31",month:"Error: month should be untll 12",date:"Error: date format shoud be MM-DD",year:"Error: date format shoud be 20YY",monthBetween:"Error: start of month should be less than end of month",startHour:"Error: start hour should be less than 23",endHour:"Error: end hour should be until 23",hourFormat:"Error: hours should be numberic",isNotValidHour:"Error: hour should be until 23",startDay:"Error: start day should be less than 30",endDay:"Error: end day should be untill 31",time:"Error: invalid time format. time should be [hh:mm AM or PM]",isNotArray:"Error: first argument shold be Array",dateGrater:"start date should not be grater than end-of -date",dateSameDay:"start and end date are should not be same date ",timeFormat:"Error: time of type formats",numFormat:"Error: num should be numberic",taskFormat:"Error: "+e+" should be object or function",notExist:"Error: "+e+" not exist",shouldBeFunction:"Error: "+e+" is shold be function",onlyBrowser:"Error: "+e+" is just supported web-browser"}},e.prototype.formats=function(){return{date:/^(1[0-2]|[1-9])-([1-9]|[12]\d|3[0-1])$/,year:/^[2][0][1-9]{2}$/,annual:/^[2]{1}[0]{1}[1-3]{1}[0-9]{1}-[01]{1}[0-9]{1}-[0-3]{1}[0-9]{1}$/,time:/^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$/}},e.prototype.info=function(){return{version:"1.4.1",method:{on:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Weekdays","Weekend","Selects","Annual","DatesBetween","DatesContain"],at:["Between","Unless","Hour","HoursBetween","HourSelects"],in:["Day","Days","DaysBetween","Month","MonthSelects","Year"],is:["True","False","Language","Lang","LanguageSelects","LangSelects","LanguageExcepts","LangExcepts"],timer:["After"]}}},e.prototype.on=function(e){var r=e,t=this.D,n=this.D.getDay(),o=this.messages(),i=this.helpers(),a=this.formats(),u=function(){return new Promise(function(e,t){return 0===n?e(!0):r===!0&&t(!1)})},s=function(){return new Promise(function(e,t){return 1===n?e(!0):r===!0&&t(!1)})},c=function(){return new Promise(function(e,t){return 2===n?e(!0):r===!0&&t(!1)})},f=function(){return new Promise(function(e,t){return 3===n?e(!0):r===!0&&t(!1)})},h=function(){return new Promise(function(e,t){return 4===n?e(!0):r===!0&&t(!1)})},d=function(){return new Promise(function(e,t){return 5===n?e(!0):r===!0&&t(!1)})},l=function(){return new Promise(function(e,t){return 6===n?e(!0):r===!0&&t(!1)})},m=function(e){return new Promise(function(t,a){try{if(!Array.isArray(e))throw o.isNotArray;var u=i.__dayOfTheWeekStringToNumber(e);return i.__contains(u,n)?t(!0):r===!0&&a(!1)}catch(e){return void console.error(e)}})},y=function(){return new Promise(function(e,t){var o=[1,2,3,4,5];return i.__contains(o,n)?e(!0):r===!0&&t(!1)})},w=function(){return new Promise(function(e,t){var o=[0,6];return i.__contains(o,n)?e(!0):r===!0&&t(!1)})},_=function(e){return new Promise(function(t,n){try{if(!e.match(a.date))throw o.date;return e==i.__dateString()?t(!0):r===!0&&n(!1)}catch(e){return void console.error(e)}})},p=function(e,n){return new Promise(function(a,u){var s=new Date(e),c=new Date(n);try{if(s>c)throw o.dateGrater;if(s==c)throw o.dateSameDay;return i.__dateCompare(s,c,t)?a(!0):r===!0&&u(!1)}catch(e){return void console.error(e)}})},g=function(e){return new Promise(function(n,a){try{if(!Array.isArray(e))throw o.isNotArray;return i.__contains(e,t.toISOString().slice(0,10))?n(!0):r===!0&&a(!1)}catch(e){return void console.error(e)}})},v={Sunday:u,Monday:s,Tuesday:c,Wednesday:f,Thursday:h,Friday:d,Saturday:l,Selects:m,Weekdays:y,Weekend:w,Annual:_,DatesBetween:p,DatesContain:g};return v},e.prototype.at=function(e){var r=e,t=this.D,n=(this.D.getDay(),this.D.getHours()),o=this.messages(),i=this.helpers(),a=this.formats(),u=function(e,n){return new Promise(function(u,s){try{if(!e.match(a.time))throw o.time+"at start";if(!n.match(a.time))throw o.time+" at end";var c=t<i.__timeObject(n)&&t>i.__timeObject(e);return c?u(!0):r===!0&&s(!1)}catch(e){return void console.error(e)}})},s=function(e,n){return new Promise(function(u,s){try{if(!e.match(a.time))throw o.time+"at start";if(!n.match(a.time))throw o.time+" at end";var c=t<i.__timeObject(n)&&t>i.__timeObject(e);return c?r===!0&&s(!1):u(!0)}catch(e){return void console.error(e)}})},c=function(e){return new Promise(function(t,i){var a=parseInt(e);try{if(a>23)throw o.startHour;return a===n?t(!0):r===!0&&i(!1)}catch(e){return void console.error(e)}})},f=function(e,t){return new Promise(function(a,u){var s=parseInt(e),c=parseInt(t);try{if(s>23)throw o.startHour;if(c>23)throw o.endHour;var f=i.__range(c,c-s);return f.push(e),i.__contains(f,n)?a(!0):r===!0&&u(!1)}catch(e){return void console.error(e)}})},h=function(e,t){return new Promise(function(t,a){try{if(!Array.isArray(e))throw o.isNotArray;if(1!=!e.some(isNaN))throw o.hourFormat;var u=e.map(function(e){return parseInt(e)});return u.map(function(e){if(e>23)throw o.isNotValidHour}),i.__contains(u,n)?t(!0):r===!0&&a(!1)}catch(e){return void console.error(e)}})},d={Between:u,Unless:s,Hour:c,HoursBetween:f,HourSelects:h};return d},e.prototype.in=function(e){var r=e,t=this.messages(),n=this.helpers(),o=this.formats(),i=(this.D,this.D.getDate()),a=this.D.getMonth()+1,u=this.D.getFullYear(),s=function(e){return new Promise(function(t,n){try{if(parseInt(e)>31)throw __message.day;return e==i?t(!0):r===!0&&n(!1)}catch(e){return void console.error(e)}})},c=function(e){return new Promise(function(o,a){try{if(!Array.isArray(e))throw t.isNotArray;var u=e.map(function(e){return parseInt(e)});return n.__contains(u,i)?o(!0):r===!0&&a(!1)}catch(e){return void console.error(e)}})},f=function(e,o){return new Promise(function(a,u){try{var s=parseInt(e),c=parseInt(o);if(s>30)throw t.startDay;if(c>31)throw t.endDay;var f=n.__range(c,c-s);return f.push(e),n.__contains(f,i)?a(!0):r===!0&&u(!1)}catch(e){return void console.error(e)}})},h=function(e){return new Promise(function(n,o){try{if(parseInt(e)>12)throw t.month;var i=e<10?"0"+e:e;return i==a?n(!0):r===!0&&o(!1)}catch(e){return void console.error(e)}})},d=function(e){return new Promise(function(o,i){try{if(!Array.isArray(e))throw t.isNotArray;return n.__contains(e,a)?o(!0):r===!0&&i(!1)}catch(e){return void console.error(e)}})},l=function(e){return new Promise(function(n,i){try{if(!e.toString().match(o.year))throw t.year;return e==u?n(!0):r===!0&&i(!1)}catch(e){return void console.error(e)}})},m={Day:s,Days:c,DaysBetween:f,Month:h,MonthSelects:d,Year:l};return m},e.prototype.is=function(e){var r=e,t=this.helpers(),n=this.messages(),o=function(e){return new Promise(function(t,n){return e?t(!0):r===!0&&n(!1)})},i=function(e){return new Promise(function(t,n){return e?r===!0&&n(!1):t(!0)})},a=function(e){return new Promise(function(n,o){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;return e.toLowerCase()==t.__detectLang()?n(!0):r===!0&&o(!1)}catch(e){return void console.error(e)}})},u=function(e){return new Promise(function(n,o){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;var i=t.__detectLang();return e.toLowerCase()==i.slice(0,2)?n(!0):r===!0&&o(!1)}catch(e){return void console.error(e)}})},s=function(e){return new Promise(function(o,i){try{if("undefined"===window)throw this.messages("LanguageSelects").onlyBrowser;if(!Array.isArray(e))throw n.isNotArray;return t.__contains(t.__arrayToLower(e),t.__detectLang())?o(!0):r===!0&&i(!1)}catch(e){return void console.error(e)}})},c=function(e){try{if("undefined"===window)throw this.messages("LangSelects").onlyBrowser;if(!Array.isArray(e))throw n.isNotArray;var o=t.__detectLang();return t.__contains(t.__arrayToLower(e),o.slice(0,2))?resolve(!0):r===!0&&reject(!1)}catch(e){return void console.error(e)}},f=function(e){try{if("undefined"===window)throw this.messages("LanguageExcepts").onlyBrowser;if(!Array.isArray(e))throw n.isNotArray;return t.__contains(t.__arrayToLower(e),t.__detectLang())?r===!0&&reject(!1):resolve(!0)}catch(e){return void console.error(e)}},h=function(e){try{if("undefined"===window)throw this.messages("LangExcepts").onlyBrowser;if(!Array.isArray(e))throw n.isNotArray;var o=t.__detectLang();return t.__contains(t.__arrayToLower(e),o.slice(0,2))?r===!0&&reject(!1):resolve(!0)}catch(e){return void console.error(e)}},d={True:o,False:i,Language:a,Lang:u,LanguageSelects:s,LangSelects:c,LanguageExcepts:f,LangExcepts:h};return d},e.prototype.timer=function(){var e=this.messages(),r=this.helpers(),t=function(t,n,o){return new Promise(function(i){var a=r.__typeToMilliseconds(t),u=typeof o;try{if(!a)throw e.timeFormat;if(isNaN(n))throw e.numFormat;if(0===n||"0"===n)throw e.numFormat;if(!r.__contains(["object","function","undefined"],u))throw this.messages("type").taskFormat;if("object"===u){if(!("before"in o))throw this.messages("key:before").notExist;if("function"!=typeof o.before)throw this.messages("before").shouldBeFunction;return o.before(),setTimeout(function(){return i(!0)},n*a)}return setTimeout(function(){return i(!0)},n*a)}catch(e){return void console.error(e)}})},n={After:t};return n},e}); |
@@ -192,6 +192,15 @@ ;(function(root, factory) { | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -207,3 +216,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -916,3 +926,3 @@ | ||
return lang == _helper.__detectLang() | ||
return lang.toLowerCase() == _helper.__detectLang() | ||
? resolve(true) | ||
@@ -940,3 +950,3 @@ : _Condition === true ? reject(false) : false; | ||
return lang == detect.slice(0, 2) | ||
return lang.toLowerCase() == detect.slice(0, 2) | ||
? resolve(true) | ||
@@ -964,3 +974,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(languages, _helper.__detectLang()) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -989,3 +1002,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(lang, detect.slice(0, 2)) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1011,3 +1027,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(languages, _helper.__detectLang()) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -1035,3 +1054,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(lang, detect.slice(0, 2)) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1038,0 +1060,0 @@ : _Condition === true ? reject(false) : false; |
@@ -1,1 +0,1 @@ | ||
!function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.SelfTimer=e()}(this,function(){"use strict";function r(r){this.D=r}return r.prototype.helpers=function(){var r=this.D,e=(this.D.getDay(),function(r){return"function"==typeof r||void 0==r}),t=function(r,e){for(var t=r.length;t--;)if(r[t]===e)return!0;return!1},n=function(r){return r.map(function(r){return r.replace(/Sun/g,0)}).map(function(r){return r.replace(/Mon/g,1)}).map(function(r){return r.replace(/Tue/g,2)}).map(function(r){return r.replace(/Wed/g,3)}).map(function(r){return r.replace(/Thu/g,4)}).map(function(r){return r.replace(/Fri/g,5)}).map(function(r){return r.replace(/Sat/g,6)}).map(function(r){return parseInt(r)})},o=function(r){var e=r.split(/:|\s/),t=new Date;return"pm"==e.pop().toLowerCase()&&(e[0]=+e[0]+12),t.setHours(+e.shift()),t.setMinutes(+e.shift()),t},i=function(r,e){1==arguments.length&&(e=r,r=0);for(var t=[],n=0;n<e;n++)t.push(r-n);return t},a=function(r,e,t){return t<e.setDate(e.getDate()+1)&&t>r},s=function(){var e=r.getMonth()+1,t=r.getDate();return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),[e,t].join("-")},u=function(r){var e;switch(r){case"s":case"sec":case"second":case"seconds":e=1e3;break;case"m":case"min":case"minute":case"minutes":e=6e4;break;default:e=!1}return e},c=function(){return"undefined"===navigator.userLanguage?navigator.userLanguage:navigator.language},f={__checkIsValid:e,__contains:t,__dayOfTheWeekStringToNumber:n,__timeObject:o,__range:i,__dateCompare:a,__dateString:s,__typeToMilliseconds:u,__detectLang:c};return f},r.prototype.messages=function(r){return{day:"Error: A day should be less than 31",month:"Error: month should be untll 12",date:"Error: date format shoud be MM-DD",year:"Error: date format shoud be 20YY",monthBetween:"Error: start of month should be less than end of month",startHour:"Error: start hour should be less than 23",endHour:"Error: end hour should be until 23",hourFormat:"Error: hours should be numberic",isNotValidHour:"Error: hour should be until 23",startDay:"Error: start day should be less than 30",endDay:"Error: end day should be untill 31",time:"Error: invalid time format. time should be [hh:mm AM or PM]",isNotArray:"Error: first argument shold be Array",dateGrater:"start date should not be grater than end-of -date",dateSameDay:"start and end date are should not be same date ",timeFormat:"Error: time of type formats",numFormat:"Error: num should be numberic",taskFormat:"Error: "+r+" should be object or function",notExist:"Error: "+r+" not exist",shouldBeFunction:"Error: "+r+" is shold be function",onlyBrowser:"Error: "+r+" is just supported web-browser"}},r.prototype.formats=function(){return{date:/^(1[0-2]|[1-9])-([1-9]|[12]\d|3[0-1])$/,year:/^[2][0][1-9]{2}$/,annual:/^[2]{1}[0]{1}[1-3]{1}[0-9]{1}-[01]{1}[0-9]{1}-[0-3]{1}[0-9]{1}$/,time:/^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$/}},r.prototype.info=function(){return{version:"1.4.1",method:{on:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Weekdays","Weekend","Selects","Annual","DatesBetween","DatesContain"],at:["Between","Unless","Hour","HoursBetween","HourSelects"],in:["Day","Days","DaysBetween","Month","MonthSelects","Year"],is:["True","False","Language","Lang","LanguageSelects","LangSelects","LanguageExcepts","LangExcepts"],timer:["After"]}}},r.prototype.on=function(r){var e=r,t=this.D,n=this.D.getDay(),o=this.messages(),i=this.helpers(),a=this.formats(),s=function(){return new Promise(function(r,t){return 0===n?r(!0):e===!0&&t(!1)})},u=function(){return new Promise(function(r,t){return 1===n?r(!0):e===!0&&t(!1)})},c=function(){return new Promise(function(r,t){return 2===n?r(!0):e===!0&&t(!1)})},f=function(){return new Promise(function(r,t){return 3===n?r(!0):e===!0&&t(!1)})},h=function(){return new Promise(function(r,t){return 4===n?r(!0):e===!0&&t(!1)})},d=function(){return new Promise(function(r,t){return 5===n?r(!0):e===!0&&t(!1)})},m=function(){return new Promise(function(r,t){return 6===n?r(!0):e===!0&&t(!1)})},y=function(r){return new Promise(function(t,a){try{if(!Array.isArray(r))throw o.isNotArray;var s=i.__dayOfTheWeekStringToNumber(r);return i.__contains(s,n)?t(!0):e===!0&&a(!1)}catch(r){return void console.error(r)}})},l=function(){return new Promise(function(r,t){var o=[1,2,3,4,5];return i.__contains(o,n)?r(!0):e===!0&&t(!1)})},w=function(){return new Promise(function(r,t){var o=[0,6];return i.__contains(o,n)?r(!0):e===!0&&t(!1)})},g=function(r){return new Promise(function(t,n){try{if(!r.match(a.date))throw o.date;return r==i.__dateString()?t(!0):e===!0&&n(!1)}catch(r){return void console.error(r)}})},p=function(r,n){return new Promise(function(a,s){var u=new Date(r),c=new Date(n);try{if(u>c)throw o.dateGrater;if(u==c)throw o.dateSameDay;return i.__dateCompare(u,c,t)?a(!0):e===!0&&s(!1)}catch(r){return void console.error(r)}})},_=function(r){return new Promise(function(n,a){try{if(!Array.isArray(r))throw o.isNotArray;return i.__contains(r,t.toISOString().slice(0,10))?n(!0):e===!0&&a(!1)}catch(r){return void console.error(r)}})},v={Sunday:s,Monday:u,Tuesday:c,Wednesday:f,Thursday:h,Friday:d,Saturday:m,Selects:y,Weekdays:l,Weekend:w,Annual:g,DatesBetween:p,DatesContain:_};return v},r.prototype.at=function(r){var e=r,t=this.D,n=(this.D.getDay(),this.D.getHours()),o=this.messages(),i=this.helpers(),a=this.formats(),s=function(r,n){return new Promise(function(s,u){try{if(!r.match(a.time))throw o.time+"at start";if(!n.match(a.time))throw o.time+" at end";var c=t<i.__timeObject(n)&&t>i.__timeObject(r);return c?s(!0):e===!0&&u(!1)}catch(r){return void console.error(r)}})},u=function(r,n){return new Promise(function(s,u){try{if(!r.match(a.time))throw o.time+"at start";if(!n.match(a.time))throw o.time+" at end";var c=t<i.__timeObject(n)&&t>i.__timeObject(r);return c?e===!0&&u(!1):s(!0)}catch(r){return void console.error(r)}})},c=function(r){return new Promise(function(t,i){var a=parseInt(r);try{if(a>23)throw o.startHour;return a===n?t(!0):e===!0&&i(!1)}catch(r){return void console.error(r)}})},f=function(r,t){return new Promise(function(a,s){var u=parseInt(r),c=parseInt(t);try{if(u>23)throw o.startHour;if(c>23)throw o.endHour;var f=i.__range(c,c-u);return f.push(r),i.__contains(f,n)?a(!0):e===!0&&s(!1)}catch(r){return void console.error(r)}})},h=function(r,t){return new Promise(function(t,a){try{if(!Array.isArray(r))throw o.isNotArray;if(1!=!r.some(isNaN))throw o.hourFormat;var s=r.map(function(r){return parseInt(r)});return s.map(function(r){if(r>23)throw o.isNotValidHour}),i.__contains(s,n)?t(!0):e===!0&&a(!1)}catch(r){return void console.error(r)}})},d={Between:s,Unless:u,Hour:c,HoursBetween:f,HourSelects:h};return d},r.prototype.in=function(r){var e=r,t=this.messages(),n=this.helpers(),o=this.formats(),i=(this.D,this.D.getDate()),a=this.D.getMonth()+1,s=this.D.getFullYear(),u=function(r){return new Promise(function(t,n){try{if(parseInt(r)>31)throw __message.day;return r==i?t(!0):e===!0&&n(!1)}catch(r){return void console.error(r)}})},c=function(r){return new Promise(function(o,a){try{if(!Array.isArray(r))throw t.isNotArray;var s=r.map(function(r){return parseInt(r)});return n.__contains(s,i)?o(!0):e===!0&&a(!1)}catch(r){return void console.error(r)}})},f=function(r,o){return new Promise(function(a,s){try{var u=parseInt(r),c=parseInt(o);if(u>30)throw t.startDay;if(c>31)throw t.endDay;var f=n.__range(c,c-u);return f.push(r),n.__contains(f,i)?a(!0):e===!0&&s(!1)}catch(r){return void console.error(r)}})},h=function(r){return new Promise(function(n,o){try{if(parseInt(r)>12)throw t.month;var i=r<10?"0"+r:r;return i==a?n(!0):e===!0&&o(!1)}catch(r){return void console.error(r)}})},d=function(r){return new Promise(function(o,i){try{if(!Array.isArray(r))throw t.isNotArray;return n.__contains(r,a)?o(!0):e===!0&&i(!1)}catch(r){return void console.error(r)}})},m=function(r){return new Promise(function(n,i){try{if(!r.toString().match(o.year))throw t.year;return r==s?n(!0):e===!0&&i(!1)}catch(r){return void console.error(r)}})},y={Day:u,Days:c,DaysBetween:f,Month:h,MonthSelects:d,Year:m};return y},r.prototype.is=function(r){var e=r,t=this.helpers(),n=this.messages(),o=function(r){return new Promise(function(t,n){return r?t(!0):e===!0&&n(!1)})},i=function(r){return new Promise(function(t,n){return r?e===!0&&n(!1):t(!0)})},a=function(r){return new Promise(function(n,o){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;return r==t.__detectLang()?n(!0):e===!0&&o(!1)}catch(r){return void console.error(r)}})},s=function(r){return new Promise(function(n,o){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;var i=t.__detectLang();return r==i.slice(0,2)?n(!0):e===!0&&o(!1)}catch(r){return void console.error(r)}})},u=function(r){return new Promise(function(o,i){try{if("undefined"===window)throw this.messages("LanguageSelects").onlyBrowser;if(!Array.isArray(r))throw n.isNotArray;return t.__contains(r,t.__detectLang())?o(!0):e===!0&&i(!1)}catch(r){return void console.error(r)}})},c=function(r){try{if("undefined"===window)throw this.messages("LangSelects").onlyBrowser;if(!Array.isArray(r))throw n.isNotArray;var o=t.__detectLang();return t.__contains(r,o.slice(0,2))?resolve(!0):e===!0&&reject(!1)}catch(r){return void console.error(r)}},f=function(r){try{if("undefined"===window)throw this.messages("LanguageExcepts").onlyBrowser;if(!Array.isArray(r))throw n.isNotArray;return t.__contains(r,t.__detectLang())?e===!0&&reject(!1):resolve(!0)}catch(r){return void console.error(r)}},h=function(r){try{if("undefined"===window)throw this.messages("LangExcepts").onlyBrowser;if(!Array.isArray(r))throw n.isNotArray;var o=t.__detectLang();return t.__contains(r,o.slice(0,2))?e===!0&&reject(!1):resolve(!0)}catch(r){return void console.error(r)}},d={True:o,False:i,Language:a,Lang:s,LanguageSelects:u,LangSelects:c,LanguageExcepts:f,LangExcepts:h};return d},r.prototype.timer=function(){var r=this.messages(),e=this.helpers(),t=function(t,n,o){return new Promise(function(i){var a=e.__typeToMilliseconds(t),s=typeof o;try{if(!a)throw r.timeFormat;if(isNaN(n))throw r.numFormat;if(0===n||"0"===n)throw r.numFormat;if(!e.__contains(["object","function","undefined"],s))throw this.messages("type").taskFormat;if("object"===s){if(!("before"in o))throw this.messages("key:before").notExist;if("function"!=typeof o.before)throw this.messages("before").shouldBeFunction;return o.before(),setTimeout(function(){return i(!0)},n*a)}return setTimeout(function(){return i(!0)},n*a)}catch(r){return void console.error(r)}})},n={After:t};return n},r}); | ||
!function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.SelfTimer=e()}(this,function(){"use strict";function r(r){this.D=r}return r.prototype.helpers=function(){var r=this.D,e=(this.D.getDay(),function(r){return"function"==typeof r||void 0==r}),t=function(r,e){for(var t=r.length;t--;)if(r[t]===e)return!0;return!1},n=function(r){return r.map(function(r){return r.replace(/Sun/g,0)}).map(function(r){return r.replace(/Mon/g,1)}).map(function(r){return r.replace(/Tue/g,2)}).map(function(r){return r.replace(/Wed/g,3)}).map(function(r){return r.replace(/Thu/g,4)}).map(function(r){return r.replace(/Fri/g,5)}).map(function(r){return r.replace(/Sat/g,6)}).map(function(r){return parseInt(r)})},o=function(r){var e=r.split(/:|\s/),t=new Date;return"pm"==e.pop().toLowerCase()&&(e[0]=+e[0]+12),t.setHours(+e.shift()),t.setMinutes(+e.shift()),t},i=function(r,e){1==arguments.length&&(e=r,r=0);for(var t=[],n=0;n<e;n++)t.push(r-n);return t},a=function(r,e,t){return t<e.setDate(e.getDate()+1)&&t>r},s=function(){var e=r.getMonth()+1,t=r.getDate();return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),[e,t].join("-")},u=function(r){var e;switch(r){case"s":case"sec":case"second":case"seconds":e=1e3;break;case"m":case"min":case"minute":case"minutes":e=6e4;break;default:e=!1}return e},c=function(){return"undefined"===navigator.userLanguage?navigator.userLanguage.toLowerCase():navigator.language.toLowerCase()},f=function(r){return r.map(function(r){return r.toLowerCase()})},h={__checkIsValid:e,__contains:t,__dayOfTheWeekStringToNumber:n,__timeObject:o,__range:i,__dateCompare:a,__dateString:s,__typeToMilliseconds:u,__detectLang:c,__arrayToLower:f};return h},r.prototype.messages=function(r){return{day:"Error: A day should be less than 31",month:"Error: month should be untll 12",date:"Error: date format shoud be MM-DD",year:"Error: date format shoud be 20YY",monthBetween:"Error: start of month should be less than end of month",startHour:"Error: start hour should be less than 23",endHour:"Error: end hour should be until 23",hourFormat:"Error: hours should be numberic",isNotValidHour:"Error: hour should be until 23",startDay:"Error: start day should be less than 30",endDay:"Error: end day should be untill 31",time:"Error: invalid time format. time should be [hh:mm AM or PM]",isNotArray:"Error: first argument shold be Array",dateGrater:"start date should not be grater than end-of -date",dateSameDay:"start and end date are should not be same date ",timeFormat:"Error: time of type formats",numFormat:"Error: num should be numberic",taskFormat:"Error: "+r+" should be object or function",notExist:"Error: "+r+" not exist",shouldBeFunction:"Error: "+r+" is shold be function",onlyBrowser:"Error: "+r+" is just supported web-browser"}},r.prototype.formats=function(){return{date:/^(1[0-2]|[1-9])-([1-9]|[12]\d|3[0-1])$/,year:/^[2][0][1-9]{2}$/,annual:/^[2]{1}[0]{1}[1-3]{1}[0-9]{1}-[01]{1}[0-9]{1}-[0-3]{1}[0-9]{1}$/,time:/^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$/}},r.prototype.info=function(){return{version:"1.4.1",method:{on:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Weekdays","Weekend","Selects","Annual","DatesBetween","DatesContain"],at:["Between","Unless","Hour","HoursBetween","HourSelects"],in:["Day","Days","DaysBetween","Month","MonthSelects","Year"],is:["True","False","Language","Lang","LanguageSelects","LangSelects","LanguageExcepts","LangExcepts"],timer:["After"]}}},r.prototype.on=function(r){var e=r,t=this.D,n=this.D.getDay(),o=this.messages(),i=this.helpers(),a=this.formats(),s=function(){return new Promise(function(r,t){return 0===n?r(!0):e===!0&&t(!1)})},u=function(){return new Promise(function(r,t){return 1===n?r(!0):e===!0&&t(!1)})},c=function(){return new Promise(function(r,t){return 2===n?r(!0):e===!0&&t(!1)})},f=function(){return new Promise(function(r,t){return 3===n?r(!0):e===!0&&t(!1)})},h=function(){return new Promise(function(r,t){return 4===n?r(!0):e===!0&&t(!1)})},d=function(){return new Promise(function(r,t){return 5===n?r(!0):e===!0&&t(!1)})},m=function(){return new Promise(function(r,t){return 6===n?r(!0):e===!0&&t(!1)})},y=function(r){return new Promise(function(t,a){try{if(!Array.isArray(r))throw o.isNotArray;var s=i.__dayOfTheWeekStringToNumber(r);return i.__contains(s,n)?t(!0):e===!0&&a(!1)}catch(r){return void console.error(r)}})},l=function(){return new Promise(function(r,t){var o=[1,2,3,4,5];return i.__contains(o,n)?r(!0):e===!0&&t(!1)})},w=function(){return new Promise(function(r,t){var o=[0,6];return i.__contains(o,n)?r(!0):e===!0&&t(!1)})},g=function(r){return new Promise(function(t,n){try{if(!r.match(a.date))throw o.date;return r==i.__dateString()?t(!0):e===!0&&n(!1)}catch(r){return void console.error(r)}})},_=function(r,n){return new Promise(function(a,s){var u=new Date(r),c=new Date(n);try{if(u>c)throw o.dateGrater;if(u==c)throw o.dateSameDay;return i.__dateCompare(u,c,t)?a(!0):e===!0&&s(!1)}catch(r){return void console.error(r)}})},p=function(r){return new Promise(function(n,a){try{if(!Array.isArray(r))throw o.isNotArray;return i.__contains(r,t.toISOString().slice(0,10))?n(!0):e===!0&&a(!1)}catch(r){return void console.error(r)}})},v={Sunday:s,Monday:u,Tuesday:c,Wednesday:f,Thursday:h,Friday:d,Saturday:m,Selects:y,Weekdays:l,Weekend:w,Annual:g,DatesBetween:_,DatesContain:p};return v},r.prototype.at=function(r){var e=r,t=this.D,n=(this.D.getDay(),this.D.getHours()),o=this.messages(),i=this.helpers(),a=this.formats(),s=function(r,n){return new Promise(function(s,u){try{if(!r.match(a.time))throw o.time+"at start";if(!n.match(a.time))throw o.time+" at end";var c=t<i.__timeObject(n)&&t>i.__timeObject(r);return c?s(!0):e===!0&&u(!1)}catch(r){return void console.error(r)}})},u=function(r,n){return new Promise(function(s,u){try{if(!r.match(a.time))throw o.time+"at start";if(!n.match(a.time))throw o.time+" at end";var c=t<i.__timeObject(n)&&t>i.__timeObject(r);return c?e===!0&&u(!1):s(!0)}catch(r){return void console.error(r)}})},c=function(r){return new Promise(function(t,i){var a=parseInt(r);try{if(a>23)throw o.startHour;return a===n?t(!0):e===!0&&i(!1)}catch(r){return void console.error(r)}})},f=function(r,t){return new Promise(function(a,s){var u=parseInt(r),c=parseInt(t);try{if(u>23)throw o.startHour;if(c>23)throw o.endHour;var f=i.__range(c,c-u);return f.push(r),i.__contains(f,n)?a(!0):e===!0&&s(!1)}catch(r){return void console.error(r)}})},h=function(r,t){return new Promise(function(t,a){try{if(!Array.isArray(r))throw o.isNotArray;if(1!=!r.some(isNaN))throw o.hourFormat;var s=r.map(function(r){return parseInt(r)});return s.map(function(r){if(r>23)throw o.isNotValidHour}),i.__contains(s,n)?t(!0):e===!0&&a(!1)}catch(r){return void console.error(r)}})},d={Between:s,Unless:u,Hour:c,HoursBetween:f,HourSelects:h};return d},r.prototype.in=function(r){var e=r,t=this.messages(),n=this.helpers(),o=this.formats(),i=(this.D,this.D.getDate()),a=this.D.getMonth()+1,s=this.D.getFullYear(),u=function(r){return new Promise(function(t,n){try{if(parseInt(r)>31)throw __message.day;return r==i?t(!0):e===!0&&n(!1)}catch(r){return void console.error(r)}})},c=function(r){return new Promise(function(o,a){try{if(!Array.isArray(r))throw t.isNotArray;var s=r.map(function(r){return parseInt(r)});return n.__contains(s,i)?o(!0):e===!0&&a(!1)}catch(r){return void console.error(r)}})},f=function(r,o){return new Promise(function(a,s){try{var u=parseInt(r),c=parseInt(o);if(u>30)throw t.startDay;if(c>31)throw t.endDay;var f=n.__range(c,c-u);return f.push(r),n.__contains(f,i)?a(!0):e===!0&&s(!1)}catch(r){return void console.error(r)}})},h=function(r){return new Promise(function(n,o){try{if(parseInt(r)>12)throw t.month;var i=r<10?"0"+r:r;return i==a?n(!0):e===!0&&o(!1)}catch(r){return void console.error(r)}})},d=function(r){return new Promise(function(o,i){try{if(!Array.isArray(r))throw t.isNotArray;return n.__contains(r,a)?o(!0):e===!0&&i(!1)}catch(r){return void console.error(r)}})},m=function(r){return new Promise(function(n,i){try{if(!r.toString().match(o.year))throw t.year;return r==s?n(!0):e===!0&&i(!1)}catch(r){return void console.error(r)}})},y={Day:u,Days:c,DaysBetween:f,Month:h,MonthSelects:d,Year:m};return y},r.prototype.is=function(r){var e=r,t=this.helpers(),n=this.messages(),o=function(r){return new Promise(function(t,n){return r?t(!0):e===!0&&n(!1)})},i=function(r){return new Promise(function(t,n){return r?e===!0&&n(!1):t(!0)})},a=function(r){return new Promise(function(n,o){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;return r.toLowerCase()==t.__detectLang()?n(!0):e===!0&&o(!1)}catch(r){return void console.error(r)}})},s=function(r){return new Promise(function(n,o){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;var i=t.__detectLang();return r.toLowerCase()==i.slice(0,2)?n(!0):e===!0&&o(!1)}catch(r){return void console.error(r)}})},u=function(r){return new Promise(function(o,i){try{if("undefined"===window)throw this.messages("LanguageSelects").onlyBrowser;if(!Array.isArray(r))throw n.isNotArray;return t.__contains(t.__arrayToLower(r),t.__detectLang())?o(!0):e===!0&&i(!1)}catch(r){return void console.error(r)}})},c=function(r){try{if("undefined"===window)throw this.messages("LangSelects").onlyBrowser;if(!Array.isArray(r))throw n.isNotArray;var o=t.__detectLang();return t.__contains(t.__arrayToLower(r),o.slice(0,2))?resolve(!0):e===!0&&reject(!1)}catch(r){return void console.error(r)}},f=function(r){try{if("undefined"===window)throw this.messages("LanguageExcepts").onlyBrowser;if(!Array.isArray(r))throw n.isNotArray;return t.__contains(t.__arrayToLower(r),t.__detectLang())?e===!0&&reject(!1):resolve(!0)}catch(r){return void console.error(r)}},h=function(r){try{if("undefined"===window)throw this.messages("LangExcepts").onlyBrowser;if(!Array.isArray(r))throw n.isNotArray;var o=t.__detectLang();return t.__contains(t.__arrayToLower(r),o.slice(0,2))?e===!0&&reject(!1):resolve(!0)}catch(r){return void console.error(r)}},d={True:o,False:i,Language:a,Lang:s,LanguageSelects:u,LangSelects:c,LanguageExcepts:f,LangExcepts:h};return d},r.prototype.timer=function(){var r=this.messages(),e=this.helpers(),t=function(t,n,o){return new Promise(function(i){var a=e.__typeToMilliseconds(t),s=typeof o;try{if(!a)throw r.timeFormat;if(isNaN(n))throw r.numFormat;if(0===n||"0"===n)throw r.numFormat;if(!e.__contains(["object","function","undefined"],s))throw this.messages("type").taskFormat;if("object"===s){if(!("before"in o))throw this.messages("key:before").notExist;if("function"!=typeof o.before)throw this.messages("before").shouldBeFunction;return o.before(),setTimeout(function(){return i(!0)},n*a)}return setTimeout(function(){return i(!0)},n*a)}catch(r){return void console.error(r)}})},n={After:t};return n},r}); |
@@ -192,6 +192,15 @@ ;(function(root, factory) { | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -207,3 +216,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -926,3 +936,3 @@ | ||
if (lang == _helper.__detectLang()) | ||
if (lang.toLowerCase() == _helper.__detectLang()) | ||
return task !== undefined ? task() : true; | ||
@@ -947,3 +957,4 @@ } catch (e) { | ||
if (lang == detect.slice(0, 2)) return task !== undefined ? task() : true; | ||
if (lang.toLowerCase() == detect.slice(0, 2)) | ||
return task !== undefined ? task() : true; | ||
} catch (e) { | ||
@@ -967,3 +978,8 @@ console.error(e); | ||
if (_helper.__contains(languages, _helper.__detectLang())) | ||
if ( | ||
_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
) | ||
return task !== undefined ? task() : true; | ||
@@ -990,3 +1006,3 @@ } catch (e) { | ||
if (_helper.__contains(lang, detect.slice(0, 2))) | ||
if (_helper.__contains(_helper.__arrayToLower(lang), detect.slice(0, 2))) | ||
return task !== undefined ? task() : true; | ||
@@ -1011,3 +1027,8 @@ } catch (e) { | ||
if (!_helper.__contains(languages, _helper.__detectLang())) | ||
if ( | ||
!_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
) | ||
return task !== undefined ? task() : true; | ||
@@ -1034,3 +1055,3 @@ } catch (e) { | ||
if (!_helper.__contains(lang, detect.slice(0, 2))) | ||
if (!_helper.__contains(_helper.__arrayToLower(lang), detect.slice(0, 2))) | ||
return task !== undefined ? task() : true; | ||
@@ -1037,0 +1058,0 @@ } catch (e) { |
@@ -1,1 +0,1 @@ | ||
!function(t,r){"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():t.SelfTimer=r()}(this,function(){"use strict";function t(t){this.D=t}return t.prototype.helpers=function(){var t=this.D,r=(this.D.getDay(),function(t){return"function"==typeof t||void 0==t}),e=function(t,r){for(var e=t.length;e--;)if(t[e]===r)return!0;return!1},n=function(t){return t.map(function(t){return t.replace(/Sun/g,0)}).map(function(t){return t.replace(/Mon/g,1)}).map(function(t){return t.replace(/Tue/g,2)}).map(function(t){return t.replace(/Wed/g,3)}).map(function(t){return t.replace(/Thu/g,4)}).map(function(t){return t.replace(/Fri/g,5)}).map(function(t){return t.replace(/Sat/g,6)}).map(function(t){return parseInt(t)})},o=function(t){var r=t.split(/:|\s/),e=new Date;return"pm"==r.pop().toLowerCase()&&(r[0]=+r[0]+12),e.setHours(+r.shift()),e.setMinutes(+r.shift()),e},i=function(t,r){1==arguments.length&&(r=t,t=0);for(var e=[],n=0;n<r;n++)e.push(t-n);return e},a=function(t,r,e){return e<r.setDate(r.getDate()+1)&&e>t},s=function(){var r=t.getMonth()+1,e=t.getDate();return r.length<2&&(r="0"+r),e.length<2&&(e="0"+e),[r,e].join("-")},c=function(t){var r;switch(t){case"s":case"sec":case"second":case"seconds":r=1e3;break;case"m":case"min":case"minute":case"minutes":r=6e4;break;default:r=!1}return r},u=function(){return"undefined"===navigator.userLanguage?navigator.userLanguage:navigator.language},h={__checkIsValid:r,__contains:e,__dayOfTheWeekStringToNumber:n,__timeObject:o,__range:i,__dateCompare:a,__dateString:s,__typeToMilliseconds:c,__detectLang:u};return h},t.prototype.messages=function(t){return{day:"Error: A day should be less than 31",month:"Error: month should be untll 12",date:"Error: date format shoud be MM-DD",year:"Error: date format shoud be 20YY",monthBetween:"Error: start of month should be less than end of month",startHour:"Error: start hour should be less than 23",endHour:"Error: end hour should be until 23",hourFormat:"Error: hours should be numberic",isNotValidHour:"Error: hour should be until 23",startDay:"Error: start day should be less than 30",endDay:"Error: end day should be untill 31",time:"Error: invalid time format. time should be [hh:mm AM or PM]",isNotArray:"Error: first argument shold be Array",dateGrater:"start date should not be grater than end-of -date",dateSameDay:"start and end date are should not be same date ",timeFormat:"Error: time of type formats",numFormat:"Error: num should be numberic",taskFormat:"Error: "+t+" should be object or function",notExist:"Error: "+t+" not exist",shouldBeFunction:"Error: "+t+" is shold be function",onlyBrowser:"Error: "+t+" is just supported web-browser"}},t.prototype.formats=function(){return{date:/^(1[0-2]|[1-9])-([1-9]|[12]\d|3[0-1])$/,year:/^[2][0][1-9]{2}$/,annual:/^[2]{1}[0]{1}[1-3]{1}[0-9]{1}-[01]{1}[0-9]{1}-[0-3]{1}[0-9]{1}$/,time:/^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$/}},t.prototype.info=function(){return{version:"1.4.1",method:{on:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Weekdays","Weekend","Selects","Annual","DatesBetween","DatesContain"],at:["Between","Unless","Hour","HoursBetween","HourSelects"],in:["Day","Days","DaysBetween","Month","MonthSelects","Year"],is:["True","False","Language","Lang","LanguageSelects","LangSelects","LanguageExcepts","LangExcepts"],timer:["After"]}}},t.prototype.on=function(){var t=this.D,r=this.D.getDay(),e=this.messages(),n=this.helpers(),o=this.formats(),i=function(t){if(n.__checkIsValid(t)&&0===r)return void 0===t||t()},a=function(t){if(n.__checkIsValid(t)&&1===r)return void 0===t||t()},s=function(t){if(n.__checkIsValid(t)&&2===r)return void 0==t||t()},c=function(t){if(n.__checkIsValid(t)&&3===r)return void 0===t||t()},u=function(t){if(n.__checkIsValid(t)&&4===r)return void 0===t||t()},h=function(t){if(n.__checkIsValid(t)&&5===r)return void 0===t||t()},f=function(t){if(n.__checkIsValid(t)&&6===r)return void 0===t||t()},d=function(t,o){if(n.__checkIsValid(o))try{if(!Array.isArray(t))throw e.isNotArray;var i=n.__dayOfTheWeekStringToNumber(t);if(n.__contains(i,r))return void 0===o||o()}catch(t){return void console.error(t)}},_=function(t){if(n.__checkIsValid(t)){var e=[1,2,3,4,5];if(n.__contains(e,r))return void 0===t||t()}},l=function(t){if(n.__checkIsValid(t)){var e=[0,6];if(n.__contains(e,r))return void 0===t||t()}},y=function(t,r){if(n.__checkIsValid(r))try{if(!t.match(o.date))throw e.date;if(t==n.__dateString())return void 0===r||r()}catch(t){return void console.error(t)}},m=function(r,o,i){if(n.__checkIsValid(i)){var a=new Date(r),s=new Date(o);try{if(a>s)throw e.dateGrater;if(a==s)throw e.dateSameDay;if(n.__dateCompare(a,s,t))return void 0===i||i()}catch(t){return void console.error(t)}}},g=function(r,o){if(n.__checkIsValid(o))try{if(!Array.isArray(r))throw e.isNotArray;if(n.__contains(r,t.toISOString().slice(0,10)))return void 0===o||o()}catch(t){return void console.error(t)}},v={Sunday:i,Monday:a,Tuesday:s,Wednesday:c,Thursday:u,Friday:h,Saturday:f,Selects:d,Weekdays:_,Weekend:l,Annual:y,DatesBetween:m,DatesContain:g};return v},t.prototype.at=function(){var t=this.D,r=(this.D.getDay(),this.D.getHours()),e=this.messages(),n=this.helpers(),o=this.formats(),i=function(r,i,a){if(n.__checkIsValid(a))try{if(!r.match(o.time))throw e.time+"at start";if(!i.match(o.time))throw e.time+" at end";var s=t<n.__timeObject(i)&&t>n.__timeObject(r);if(s)return void 0===a||a()}catch(t){return void console.error(t)}},a=function(r,i,a){if(n.__checkIsValid(a))try{if(!r.match(o.time))throw e.time+"at start";if(!i.match(o.time))throw e.time+" at end";var s=t<n.__timeObject(i)&&t>n.__timeObject(r);if(!s)return void 0===a||a()}catch(t){return void console.error(t)}},s=function(t,o){if(n.__checkIsValid(o)){var i=parseInt(t);try{if(i>23)throw e.startHour;if(i===r)return void 0===o||o()}catch(t){return void console.error(t)}}},c=function(t,o,i){if(n.__checkIsValid(i)){var a=parseInt(t),s=parseInt(o);try{if(a>23)throw e.startHour;if(s>23)throw e.endHour;var c=n.__range(s,s-a);if(c.push(t),n.__contains(c,r))return void 0===i||i()}catch(t){return void console.error(t)}}},u=function(t,o){if(n.__checkIsValid(o))try{if(!Array.isArray(t))throw e.isNotArray;if(1!=!t.some(isNaN))throw e.hourFormat;var i=t.map(function(t){return parseInt(t)});if(i.map(function(t){if(t>23)throw e.isNotValidHour}),n.__contains(i,r))return void 0===o||o()}catch(t){return void console.error(t)}},h={Between:i,Unless:a,Hour:s,HoursBetween:c,HourSelects:u};return h},t.prototype.in=function(t){var r=t,e=this.messages(),n=this.helpers(),o=this.formats(),i=(this.D,this.D.getDate()),a=this.D.getMonth()+1,s=this.D.getFullYear(),c=function(t,e){if(0!=this._Chain&&n.__checkIsValid(e))try{if(parseInt(t)>31)throw __message.day;return t==i?void 0!==e?e():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},u=function(t,o){if(0!=this._Chain&&n.__checkIsValid(o))try{if(!Array.isArray(t))throw e.isNotArray;var a=t.map(function(t){return parseInt(t)});return n.__contains(a,i)?void 0!==o?o():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},h=function(t,o,a){if(0!=this._Chain&&n.__checkIsValid(a))try{var s=parseInt(t),c=parseInt(o);if(s>30)throw e.startDay;if(c>31)throw e.endDay;var u=n.__range(c,c-s);return u.push(t),n.__contains(u,i)?void 0!==a?a():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},f=function(t,o){if(0!=this._Chain&&n.__checkIsValid(o))try{if(parseInt(t)>12)throw e.month;var i=t<10?"0"+t:t;return i==a?void 0!==o?o():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},d=function(t,o){if(0!=this._Chain&&n.__checkIsValid(o)){if(!Array.isArray(t))throw e.isNotArray;return n.__contains(t,a)?void 0!==o?o():1!=r||this:(this._Chain=!1,1==r&&this)}},_=function(t,i){if(0!=this._Chain&&n.__checkIsValid(i))try{if(!t.toString().match(o.year))throw e.year;return t==s?void 0!==i?i():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},l={Day:c,Days:u,DaysBetween:h,Month:f,MonthSelects:d,Year:_};return l},t.prototype.is=function(){var t=this.helpers(),r=this.messages(),e=function(t,r){if(t)return void 0===r||r()},n=function(t,r){if(!t)return void 0===r||r()},o=function(r,e){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;if(r==t.__detectLang())return void 0===e||e()}catch(t){return void console.error(t)}},i=function(r,e){try{if("undefined"===window)throw this.messages("Lang").onlyBrowser;var n=t.__detectLang();if(r==n.slice(0,2))return void 0===e||e()}catch(t){return void console.error(t)}},a=function(e,n){try{if("undefined"===window)throw this.messages("LanguageSelects").onlyBrowser;if(!Array.isArray(e))throw r.isNotArray;if(t.__contains(e,t.__detectLang()))return void 0===n||n()}catch(t){return void console.error(t)}},s=function(e,n){try{if("undefined"===window)throw this.messages("LangSelects").onlyBrowser;if(!Array.isArray(e))throw r.isNotArray;var o=t.__detectLang();if(t.__contains(e,o.slice(0,2)))return void 0===n||n()}catch(t){return void console.error(t)}},c=function(e,n){try{if("undefined"===window)throw this.messages("LanguageExcepts").onlyBrowser;if(!Array.isArray(e))throw r.isNotArray;if(!t.__contains(e,t.__detectLang()))return void 0===n||n()}catch(t){return void console.error(t)}},u=function(e,n){try{if("undefined"===window)throw this.messages("LangExcepts").onlyBrowser;if(!Array.isArray(e))throw r.isNotArray;var o=t.__detectLang();if(!t.__contains(e,o.slice(0,2)))return void 0===n||n()}catch(t){return void console.error(t)}},h={True:e,False:n,Language:o,Lang:i,LanguageSelects:a,LangSelects:s,LanguageExcepts:c,LangExcepts:u};return h},t.prototype.timer=function(){var t=this.messages(),r=this.helpers(),e=function(e,n,o){var i=r.__typeToMilliseconds(e),a=typeof o;try{if(!i)throw t.timeFormat;if(isNaN(n))throw t.numFormat;if(0===n||"0"===n)throw t.numFormat;if(!r.__contains(["object","function"],a))throw this.messages("type").taskFormat;if("object"===a){if(!("before"in o))throw this.messages("key:before").notExist;if(!("before"in o))throw this.messages("key:after").notExist;if("function"!=typeof o.before)throw this.messages("before").shouldBeFunction;if("function"!=typeof o.after)throw this.messages("after").shouldBeFunction;return o.before(),setTimeout(function(){return o.after()},n*i)}if("function"===a)return setTimeout(function(){return o()},n*i)}catch(t){return void console.error(t)}},n=function(e,n,o){var i=r.__typeToMilliseconds(e),a=typeof o;try{if(!i)throw t.timeFormat;if(isNaN(n))throw t.numFormat;if(0===n||"0"===n)throw t.numFormat;if(!r.__contains(["object","function"],a))throw this.messages("type").taskFormat;if("object"===a){if(!("before"in o))throw this.messages("key:before").notExist;if(!("before"in o))throw this.messages("key:after").notExist;if("function"!=typeof o.before)throw this.messages("before").shouldBeFunction;if("function"!=typeof o.after)throw this.messages("after").shouldBeFunction;return o.before(),setInterval(function(){return o.after()},n*i)}if("function"===a)return setInterval(function(){return o()},n*i)}catch(t){return void console.error(t)}},o={After:e,Every:n};return o},t}); | ||
!function(t,r){"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():t.SelfTimer=r()}(this,function(){"use strict";function t(t){this.D=t}return t.prototype.helpers=function(){var t=this.D,r=(this.D.getDay(),function(t){return"function"==typeof t||void 0==t}),e=function(t,r){for(var e=t.length;e--;)if(t[e]===r)return!0;return!1},n=function(t){return t.map(function(t){return t.replace(/Sun/g,0)}).map(function(t){return t.replace(/Mon/g,1)}).map(function(t){return t.replace(/Tue/g,2)}).map(function(t){return t.replace(/Wed/g,3)}).map(function(t){return t.replace(/Thu/g,4)}).map(function(t){return t.replace(/Fri/g,5)}).map(function(t){return t.replace(/Sat/g,6)}).map(function(t){return parseInt(t)})},o=function(t){var r=t.split(/:|\s/),e=new Date;return"pm"==r.pop().toLowerCase()&&(r[0]=+r[0]+12),e.setHours(+r.shift()),e.setMinutes(+r.shift()),e},i=function(t,r){1==arguments.length&&(r=t,t=0);for(var e=[],n=0;n<r;n++)e.push(t-n);return e},a=function(t,r,e){return e<r.setDate(r.getDate()+1)&&e>t},s=function(){var r=t.getMonth()+1,e=t.getDate();return r.length<2&&(r="0"+r),e.length<2&&(e="0"+e),[r,e].join("-")},c=function(t){var r;switch(t){case"s":case"sec":case"second":case"seconds":r=1e3;break;case"m":case"min":case"minute":case"minutes":r=6e4;break;default:r=!1}return r},u=function(){return"undefined"===navigator.userLanguage?navigator.userLanguage.toLowerCase():navigator.language.toLowerCase()},h=function(t){return t.map(function(t){return t.toLowerCase()})},f={__checkIsValid:r,__contains:e,__dayOfTheWeekStringToNumber:n,__timeObject:o,__range:i,__dateCompare:a,__dateString:s,__typeToMilliseconds:c,__detectLang:u,__arrayToLower:h};return f},t.prototype.messages=function(t){return{day:"Error: A day should be less than 31",month:"Error: month should be untll 12",date:"Error: date format shoud be MM-DD",year:"Error: date format shoud be 20YY",monthBetween:"Error: start of month should be less than end of month",startHour:"Error: start hour should be less than 23",endHour:"Error: end hour should be until 23",hourFormat:"Error: hours should be numberic",isNotValidHour:"Error: hour should be until 23",startDay:"Error: start day should be less than 30",endDay:"Error: end day should be untill 31",time:"Error: invalid time format. time should be [hh:mm AM or PM]",isNotArray:"Error: first argument shold be Array",dateGrater:"start date should not be grater than end-of -date",dateSameDay:"start and end date are should not be same date ",timeFormat:"Error: time of type formats",numFormat:"Error: num should be numberic",taskFormat:"Error: "+t+" should be object or function",notExist:"Error: "+t+" not exist",shouldBeFunction:"Error: "+t+" is shold be function",onlyBrowser:"Error: "+t+" is just supported web-browser"}},t.prototype.formats=function(){return{date:/^(1[0-2]|[1-9])-([1-9]|[12]\d|3[0-1])$/,year:/^[2][0][1-9]{2}$/,annual:/^[2]{1}[0]{1}[1-3]{1}[0-9]{1}-[01]{1}[0-9]{1}-[0-3]{1}[0-9]{1}$/,time:/^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$/}},t.prototype.info=function(){return{version:"1.4.1",method:{on:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Weekdays","Weekend","Selects","Annual","DatesBetween","DatesContain"],at:["Between","Unless","Hour","HoursBetween","HourSelects"],in:["Day","Days","DaysBetween","Month","MonthSelects","Year"],is:["True","False","Language","Lang","LanguageSelects","LangSelects","LanguageExcepts","LangExcepts"],timer:["After"]}}},t.prototype.on=function(){var t=this.D,r=this.D.getDay(),e=this.messages(),n=this.helpers(),o=this.formats(),i=function(t){if(n.__checkIsValid(t)&&0===r)return void 0===t||t()},a=function(t){if(n.__checkIsValid(t)&&1===r)return void 0===t||t()},s=function(t){if(n.__checkIsValid(t)&&2===r)return void 0==t||t()},c=function(t){if(n.__checkIsValid(t)&&3===r)return void 0===t||t()},u=function(t){if(n.__checkIsValid(t)&&4===r)return void 0===t||t()},h=function(t){if(n.__checkIsValid(t)&&5===r)return void 0===t||t()},f=function(t){if(n.__checkIsValid(t)&&6===r)return void 0===t||t()},d=function(t,o){if(n.__checkIsValid(o))try{if(!Array.isArray(t))throw e.isNotArray;var i=n.__dayOfTheWeekStringToNumber(t);if(n.__contains(i,r))return void 0===o||o()}catch(t){return void console.error(t)}},_=function(t){if(n.__checkIsValid(t)){var e=[1,2,3,4,5];if(n.__contains(e,r))return void 0===t||t()}},l=function(t){if(n.__checkIsValid(t)){var e=[0,6];if(n.__contains(e,r))return void 0===t||t()}},y=function(t,r){if(n.__checkIsValid(r))try{if(!t.match(o.date))throw e.date;if(t==n.__dateString())return void 0===r||r()}catch(t){return void console.error(t)}},m=function(r,o,i){if(n.__checkIsValid(i)){var a=new Date(r),s=new Date(o);try{if(a>s)throw e.dateGrater;if(a==s)throw e.dateSameDay;if(n.__dateCompare(a,s,t))return void 0===i||i()}catch(t){return void console.error(t)}}},g=function(r,o){if(n.__checkIsValid(o))try{if(!Array.isArray(r))throw e.isNotArray;if(n.__contains(r,t.toISOString().slice(0,10)))return void 0===o||o()}catch(t){return void console.error(t)}},v={Sunday:i,Monday:a,Tuesday:s,Wednesday:c,Thursday:u,Friday:h,Saturday:f,Selects:d,Weekdays:_,Weekend:l,Annual:y,DatesBetween:m,DatesContain:g};return v},t.prototype.at=function(){var t=this.D,r=(this.D.getDay(),this.D.getHours()),e=this.messages(),n=this.helpers(),o=this.formats(),i=function(r,i,a){if(n.__checkIsValid(a))try{if(!r.match(o.time))throw e.time+"at start";if(!i.match(o.time))throw e.time+" at end";var s=t<n.__timeObject(i)&&t>n.__timeObject(r);if(s)return void 0===a||a()}catch(t){return void console.error(t)}},a=function(r,i,a){if(n.__checkIsValid(a))try{if(!r.match(o.time))throw e.time+"at start";if(!i.match(o.time))throw e.time+" at end";var s=t<n.__timeObject(i)&&t>n.__timeObject(r);if(!s)return void 0===a||a()}catch(t){return void console.error(t)}},s=function(t,o){if(n.__checkIsValid(o)){var i=parseInt(t);try{if(i>23)throw e.startHour;if(i===r)return void 0===o||o()}catch(t){return void console.error(t)}}},c=function(t,o,i){if(n.__checkIsValid(i)){var a=parseInt(t),s=parseInt(o);try{if(a>23)throw e.startHour;if(s>23)throw e.endHour;var c=n.__range(s,s-a);if(c.push(t),n.__contains(c,r))return void 0===i||i()}catch(t){return void console.error(t)}}},u=function(t,o){if(n.__checkIsValid(o))try{if(!Array.isArray(t))throw e.isNotArray;if(1!=!t.some(isNaN))throw e.hourFormat;var i=t.map(function(t){return parseInt(t)});if(i.map(function(t){if(t>23)throw e.isNotValidHour}),n.__contains(i,r))return void 0===o||o()}catch(t){return void console.error(t)}},h={Between:i,Unless:a,Hour:s,HoursBetween:c,HourSelects:u};return h},t.prototype.in=function(t){var r=t,e=this.messages(),n=this.helpers(),o=this.formats(),i=(this.D,this.D.getDate()),a=this.D.getMonth()+1,s=this.D.getFullYear(),c=function(t,e){if(0!=this._Chain&&n.__checkIsValid(e))try{if(parseInt(t)>31)throw __message.day;return t==i?void 0!==e?e():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},u=function(t,o){if(0!=this._Chain&&n.__checkIsValid(o))try{if(!Array.isArray(t))throw e.isNotArray;var a=t.map(function(t){return parseInt(t)});return n.__contains(a,i)?void 0!==o?o():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},h=function(t,o,a){if(0!=this._Chain&&n.__checkIsValid(a))try{var s=parseInt(t),c=parseInt(o);if(s>30)throw e.startDay;if(c>31)throw e.endDay;var u=n.__range(c,c-s);return u.push(t),n.__contains(u,i)?void 0!==a?a():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},f=function(t,o){if(0!=this._Chain&&n.__checkIsValid(o))try{if(parseInt(t)>12)throw e.month;var i=t<10?"0"+t:t;return i==a?void 0!==o?o():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},d=function(t,o){if(0!=this._Chain&&n.__checkIsValid(o)){if(!Array.isArray(t))throw e.isNotArray;return n.__contains(t,a)?void 0!==o?o():1!=r||this:(this._Chain=!1,1==r&&this)}},_=function(t,i){if(0!=this._Chain&&n.__checkIsValid(i))try{if(!t.toString().match(o.year))throw e.year;return t==s?void 0!==i?i():1!=r||this:(this._Chain=!1,1==r&&this)}catch(t){return void console.error(t)}},l={Day:c,Days:u,DaysBetween:h,Month:f,MonthSelects:d,Year:_};return l},t.prototype.is=function(){var t=this.helpers(),r=this.messages(),e=function(t,r){if(t)return void 0===r||r()},n=function(t,r){if(!t)return void 0===r||r()},o=function(r,e){try{if("undefined"===window)throw this.messages("Language").onlyBrowser;if(r.toLowerCase()==t.__detectLang())return void 0===e||e()}catch(t){return void console.error(t)}},i=function(r,e){try{if("undefined"===window)throw this.messages("Lang").onlyBrowser;var n=t.__detectLang();if(r.toLowerCase()==n.slice(0,2))return void 0===e||e()}catch(t){return void console.error(t)}},a=function(e,n){try{if("undefined"===window)throw this.messages("LanguageSelects").onlyBrowser;if(!Array.isArray(e))throw r.isNotArray;if(t.__contains(t.__arrayToLower(e),t.__detectLang()))return void 0===n||n()}catch(t){return void console.error(t)}},s=function(e,n){try{if("undefined"===window)throw this.messages("LangSelects").onlyBrowser;if(!Array.isArray(e))throw r.isNotArray;var o=t.__detectLang();if(t.__contains(t.__arrayToLower(e),o.slice(0,2)))return void 0===n||n()}catch(t){return void console.error(t)}},c=function(e,n){try{if("undefined"===window)throw this.messages("LanguageExcepts").onlyBrowser;if(!Array.isArray(e))throw r.isNotArray;if(!t.__contains(t.__arrayToLower(e),t.__detectLang()))return void 0===n||n()}catch(t){return void console.error(t)}},u=function(e,n){try{if("undefined"===window)throw this.messages("LangExcepts").onlyBrowser;if(!Array.isArray(e))throw r.isNotArray;var o=t.__detectLang();if(!t.__contains(t.__arrayToLower(e),o.slice(0,2)))return void 0===n||n()}catch(t){return void console.error(t)}},h={True:e,False:n,Language:o,Lang:i,LanguageSelects:a,LangSelects:s,LanguageExcepts:c,LangExcepts:u};return h},t.prototype.timer=function(){var t=this.messages(),r=this.helpers(),e=function(e,n,o){var i=r.__typeToMilliseconds(e),a=typeof o;try{if(!i)throw t.timeFormat;if(isNaN(n))throw t.numFormat;if(0===n||"0"===n)throw t.numFormat;if(!r.__contains(["object","function"],a))throw this.messages("type").taskFormat;if("object"===a){if(!("before"in o))throw this.messages("key:before").notExist;if(!("before"in o))throw this.messages("key:after").notExist;if("function"!=typeof o.before)throw this.messages("before").shouldBeFunction;if("function"!=typeof o.after)throw this.messages("after").shouldBeFunction;return o.before(),setTimeout(function(){return o.after()},n*i)}if("function"===a)return setTimeout(function(){return o()},n*i)}catch(t){return void console.error(t)}},n=function(e,n,o){var i=r.__typeToMilliseconds(e),a=typeof o;try{if(!i)throw t.timeFormat;if(isNaN(n))throw t.numFormat;if(0===n||"0"===n)throw t.numFormat;if(!r.__contains(["object","function"],a))throw this.messages("type").taskFormat;if("object"===a){if(!("before"in o))throw this.messages("key:before").notExist;if(!("before"in o))throw this.messages("key:after").notExist;if("function"!=typeof o.before)throw this.messages("before").shouldBeFunction;if("function"!=typeof o.after)throw this.messages("after").shouldBeFunction;return o.before(),setInterval(function(){return o.after()},n*i)}if("function"===a)return setInterval(function(){return o()},n*i)}catch(t){return void console.error(t)}},o={After:e,Every:n};return o},t}); |
{ | ||
"name": "self-timer", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "light-weight callback runner.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/selftimer.min.js", |
@@ -73,3 +73,3 @@ # self-timer.js | ||
```bash | ||
npm install self-timer | ||
npm install self-timer --save | ||
``` | ||
@@ -76,0 +76,0 @@ |
@@ -192,6 +192,15 @@ ;(function(root, factory) { | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -207,3 +216,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -926,3 +936,3 @@ | ||
if (lang == _helper.__detectLang()) | ||
if (lang.toLowerCase() == _helper.__detectLang()) | ||
return task !== undefined ? task() : true; | ||
@@ -947,3 +957,4 @@ } catch (e) { | ||
if (lang == detect.slice(0, 2)) return task !== undefined ? task() : true; | ||
if (lang.toLowerCase() == detect.slice(0, 2)) | ||
return task !== undefined ? task() : true; | ||
} catch (e) { | ||
@@ -967,3 +978,8 @@ console.error(e); | ||
if (_helper.__contains(languages, _helper.__detectLang())) | ||
if ( | ||
_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
) | ||
return task !== undefined ? task() : true; | ||
@@ -990,3 +1006,3 @@ } catch (e) { | ||
if (_helper.__contains(lang, detect.slice(0, 2))) | ||
if (_helper.__contains(_helper.__arrayToLower(lang), detect.slice(0, 2))) | ||
return task !== undefined ? task() : true; | ||
@@ -1011,3 +1027,8 @@ } catch (e) { | ||
if (!_helper.__contains(languages, _helper.__detectLang())) | ||
if ( | ||
!_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
) | ||
return task !== undefined ? task() : true; | ||
@@ -1034,3 +1055,3 @@ } catch (e) { | ||
if (!_helper.__contains(lang, detect.slice(0, 2))) | ||
if (!_helper.__contains(_helper.__arrayToLower(lang), detect.slice(0, 2))) | ||
return task !== undefined ? task() : true; | ||
@@ -1037,0 +1058,0 @@ } catch (e) { |
@@ -183,6 +183,15 @@ "use strict"; | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -198,3 +207,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -917,3 +927,3 @@ | ||
if (lang == _helper.__detectLang()) | ||
if (lang.toLowerCase() == _helper.__detectLang()) | ||
return task !== undefined ? task() : true; | ||
@@ -938,3 +948,4 @@ } catch (e) { | ||
if (lang == detect.slice(0, 2)) return task !== undefined ? task() : true; | ||
if (lang.toLowerCase() == detect.slice(0, 2)) | ||
return task !== undefined ? task() : true; | ||
} catch (e) { | ||
@@ -958,3 +969,8 @@ console.error(e); | ||
if (_helper.__contains(languages, _helper.__detectLang())) | ||
if ( | ||
_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
) | ||
return task !== undefined ? task() : true; | ||
@@ -981,3 +997,3 @@ } catch (e) { | ||
if (_helper.__contains(lang, detect.slice(0, 2))) | ||
if (_helper.__contains(_helper.__arrayToLower(lang), detect.slice(0, 2))) | ||
return task !== undefined ? task() : true; | ||
@@ -1002,3 +1018,8 @@ } catch (e) { | ||
if (!_helper.__contains(languages, _helper.__detectLang())) | ||
if ( | ||
!_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
) | ||
return task !== undefined ? task() : true; | ||
@@ -1025,3 +1046,3 @@ } catch (e) { | ||
if (!_helper.__contains(lang, detect.slice(0, 2))) | ||
if (!_helper.__contains(_helper.__arrayToLower(lang), detect.slice(0, 2))) | ||
return task !== undefined ? task() : true; | ||
@@ -1028,0 +1049,0 @@ } catch (e) { |
@@ -192,6 +192,15 @@ ;(function(root, factory) { | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -207,3 +216,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -916,3 +926,3 @@ | ||
return lang == _helper.__detectLang() | ||
return lang.toLowerCase() == _helper.__detectLang() | ||
? resolve(true) | ||
@@ -940,3 +950,3 @@ : _Condition === true ? reject(false) : false; | ||
return lang == detect.slice(0, 2) | ||
return lang.toLowerCase() == detect.slice(0, 2) | ||
? resolve(true) | ||
@@ -964,3 +974,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(languages, _helper.__detectLang()) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -989,3 +1002,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(lang, detect.slice(0, 2)) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1011,3 +1027,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(languages, _helper.__detectLang()) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -1035,3 +1054,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(lang, detect.slice(0, 2)) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1038,0 +1060,0 @@ : _Condition === true ? reject(false) : false; |
@@ -193,6 +193,15 @@ !function(e){function n(){}function t(e,n){return function(){e.apply(n,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(e,this)}function i(e,n){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(n):(e._handled=!0,void o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null===t)return void(1===e._state?r:u)(n.promise,e._value);var o;try{o=t(e._value)}catch(i){return void u(n.promise,i)}r(n.promise,o)}))}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var i=n.then;if(n instanceof o)return e._state=3,e._value=n,void f(e);if("function"==typeof i)return void s(t(i,n),e)}e._state=1,e._value=n,f(e)}catch(r){u(e,r)}}function u(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n<t;n++)i(e,e._deferreds[n]);e._deferreds=null}function c(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}function s(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,u(n,e))})}catch(o){if(t)return;t=!0,u(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var o=new this.constructor(n);return i(this,new c(e,t,o)),o},o.all=function(e){var n=Array.prototype.slice.call(e);return new o(function(e,t){function o(r,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var f=u.then;if("function"==typeof f)return void f.call(u,function(e){o(r,e)},t)}n[r]=u,0===--i&&e(n)}catch(c){t(c)}}if(0===n.length)return e([]);for(var i=n.length,r=0;r<n.length;r++)o(r,n[r])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(n,t){for(var o=0,i=e.length;o<i;o++)e[o].then(n,t)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},o._setImmediateFn=function(e){o._immediateFn=e},o._setUnhandledRejectionFn=function(e){o._unhandledRejectionFn=e},"undefined"!=typeof module&&module.exports?module.exports=o:e.Promise||(e.Promise=o)}(this); | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -208,3 +217,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -917,3 +927,3 @@ | ||
return lang == _helper.__detectLang() | ||
return lang.toLowerCase() == _helper.__detectLang() | ||
? resolve(true) | ||
@@ -941,3 +951,3 @@ : _Condition === true ? reject(false) : false; | ||
return lang == detect.slice(0, 2) | ||
return lang.toLowerCase() == detect.slice(0, 2) | ||
? resolve(true) | ||
@@ -965,3 +975,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(languages, _helper.__detectLang()) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -990,3 +1003,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(lang, detect.slice(0, 2)) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1012,3 +1028,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(languages, _helper.__detectLang()) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -1036,3 +1055,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(lang, detect.slice(0, 2)) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1039,0 +1061,0 @@ : _Condition === true ? reject(false) : false; |
@@ -183,6 +183,15 @@ "use strict"; | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -198,3 +207,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -907,3 +917,3 @@ | ||
return lang == _helper.__detectLang() | ||
return lang.toLowerCase() == _helper.__detectLang() | ||
? resolve(true) | ||
@@ -931,3 +941,3 @@ : _Condition === true ? reject(false) : false; | ||
return lang == detect.slice(0, 2) | ||
return lang.toLowerCase() == detect.slice(0, 2) | ||
? resolve(true) | ||
@@ -955,3 +965,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(languages, _helper.__detectLang()) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -980,3 +993,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(lang, detect.slice(0, 2)) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1002,3 +1018,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(languages, _helper.__detectLang()) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -1026,3 +1045,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(lang, detect.slice(0, 2)) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -1029,0 +1051,0 @@ : _Condition === true ? reject(false) : false; |
@@ -41,3 +41,3 @@ /** | ||
if (lang == _helper.__detectLang()) | ||
if (lang.toLowerCase() == _helper.__detectLang()) | ||
return task !== undefined ? task() : true; | ||
@@ -62,3 +62,4 @@ } catch (e) { | ||
if (lang == detect.slice(0, 2)) return task !== undefined ? task() : true; | ||
if (lang.toLowerCase() == detect.slice(0, 2)) | ||
return task !== undefined ? task() : true; | ||
} catch (e) { | ||
@@ -82,3 +83,8 @@ console.error(e); | ||
if (_helper.__contains(languages, _helper.__detectLang())) | ||
if ( | ||
_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
) | ||
return task !== undefined ? task() : true; | ||
@@ -105,3 +111,3 @@ } catch (e) { | ||
if (_helper.__contains(lang, detect.slice(0, 2))) | ||
if (_helper.__contains(_helper.__arrayToLower(lang), detect.slice(0, 2))) | ||
return task !== undefined ? task() : true; | ||
@@ -126,3 +132,8 @@ } catch (e) { | ||
if (!_helper.__contains(languages, _helper.__detectLang())) | ||
if ( | ||
!_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
) | ||
return task !== undefined ? task() : true; | ||
@@ -149,3 +160,3 @@ } catch (e) { | ||
if (!_helper.__contains(lang, detect.slice(0, 2))) | ||
if (!_helper.__contains(_helper.__arrayToLower(lang), detect.slice(0, 2))) | ||
return task !== undefined ? task() : true; | ||
@@ -152,0 +163,0 @@ } catch (e) { |
@@ -54,3 +54,3 @@ /** | ||
return lang == _helper.__detectLang() | ||
return lang.toLowerCase() == _helper.__detectLang() | ||
? resolve(true) | ||
@@ -78,3 +78,3 @@ : _Condition === true ? reject(false) : false; | ||
return lang == detect.slice(0, 2) | ||
return lang.toLowerCase() == detect.slice(0, 2) | ||
? resolve(true) | ||
@@ -102,3 +102,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(languages, _helper.__detectLang()) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -127,3 +130,6 @@ : _Condition === true ? reject(false) : false; | ||
return _helper.__contains(lang, detect.slice(0, 2)) | ||
return _helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -149,3 +155,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(languages, _helper.__detectLang()) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(languages), | ||
_helper.__detectLang() | ||
) | ||
? resolve(true) | ||
@@ -173,3 +182,6 @@ : _Condition === true ? reject(false) : false; | ||
return !_helper.__contains(lang, detect.slice(0, 2)) | ||
return !_helper.__contains( | ||
_helper.__arrayToLower(lang), | ||
detect.slice(0, 2) | ||
) | ||
? resolve(true) | ||
@@ -176,0 +188,0 @@ : _Condition === true ? reject(false) : false; |
@@ -173,6 +173,15 @@ /** | ||
return navigator.userLanguage === "undefined" | ||
? navigator.userLanguage | ||
: navigator.language; | ||
? navigator.userLanguage.toLowerCase() | ||
: navigator.language.toLowerCase(); | ||
}; // ! __detectLang() | ||
/** | ||
* @return {[ Array ]} | ||
*/ | ||
var __arrayToLower = function(arr) { | ||
return arr.map(function(val) { | ||
return val.toLowerCase(); | ||
}); | ||
}; | ||
// Register methods | ||
@@ -188,3 +197,4 @@ var REGISTER = { | ||
__typeToMilliseconds: __typeToMilliseconds, | ||
__detectLang: __detectLang | ||
__detectLang: __detectLang, | ||
__arrayToLower: __arrayToLower | ||
}; // ! REGISTER | ||
@@ -191,0 +201,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1008072
14742