Spaces:
Runtime error
Runtime error
File size: 2,098 Bytes
8fd7a1d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
const SET_TIME_TRAVEL = 'scratch-gui/time-travel/SET_TIME_TRAVEL';
const initialState = {
year: 'NOW'
};
const NOW = 'NOW';
const YEAR_2020 = '2020';
const YEAR_1990 = '1990';
const YEAR_1920 = '1920';
const YEAR_220022BC = '220022BC';
const reducer = function (state, action) {
if (typeof state === 'undefined') state = initialState;
switch (action.type) {
case SET_TIME_TRAVEL:
return Object.assign({}, state, {
year: action.year
});
default:
return state;
}
};
const isTimeTravel220022BC = function (state) {
return state.scratchGui.timeTravel.year === YEAR_220022BC;
};
const setTimeTravel220022BC = function () {
return {
type: SET_TIME_TRAVEL,
year: YEAR_220022BC
};
};
const isTimeTravel1920 = function (state) {
return state.scratchGui.timeTravel.year === YEAR_1920;
};
const setTimeTravel1920 = function () {
return {
type: SET_TIME_TRAVEL,
year: YEAR_1920
};
};
const isTimeTravel1990 = function (state) {
return state.scratchGui.timeTravel.year === YEAR_1990;
};
const setTimeTravel1990 = function () {
return {
type: SET_TIME_TRAVEL,
year: YEAR_1990
};
};
const isTimeTravel2020 = function (state) {
return state.scratchGui.timeTravel.year === YEAR_2020;
};
const setTimeTravel2020 = function () {
return {
type: SET_TIME_TRAVEL,
year: YEAR_2020
};
};
const isTimeTravelNow = function (state) {
return state.scratchGui.timeTravel.year === NOW;
};
const setTimeTravelNow = function () {
return {
type: SET_TIME_TRAVEL,
year: NOW
};
};
const setTimeTravel = function (mode) {
return {
type: SET_TIME_TRAVEL,
year: mode
};
};
export {
reducer as default,
initialState as timeTravelInitialState,
isTimeTravel220022BC,
isTimeTravel1920,
isTimeTravel1990,
isTimeTravel2020,
isTimeTravelNow,
setTimeTravel220022BC,
setTimeTravel1920,
setTimeTravel1990,
setTimeTravel2020,
setTimeTravelNow,
setTimeTravel
};
|