25 lines
885 B
JavaScript
25 lines
885 B
JavaScript
(function (root, factory) {
|
|
if (typeof module === 'object' && module.exports) module.exports = factory;
|
|
else root.createMobileWorkEntry = factory;
|
|
})(typeof self !== 'undefined' ? self : this, function createMobileWorkEntry(options) {
|
|
function mode() {
|
|
if (options.isTodayActive()) return 'continue';
|
|
if (options.getTodayCount() > 0 && options.isTodayResumable()) return 'resume';
|
|
if (options.getTodayCount() > 0) return 'start';
|
|
if (options.getEligibleCount() > 0) return 'plan';
|
|
return 'work';
|
|
}
|
|
|
|
function open() {
|
|
const current = mode();
|
|
if (current === 'continue') options.continueToday();
|
|
else if (current === 'resume') options.resumeToday();
|
|
else if (current === 'start') options.startToday();
|
|
else if (current === 'plan') options.planToday();
|
|
else options.openFallback();
|
|
return current;
|
|
}
|
|
|
|
return {mode, open};
|
|
});
|