import {HIDE,RESET,SETINITDATA,SETDROPSHOW,SETADDITEMINIT,SETT0EDIT,SETREADDITEMS,
  HIDEDROP,CLICKCOUNT,ISREAD,SETOTHERHISTORY} from '../types/homePage.js';
import {showDrop,setAddItemInit,setLabelToEdit,confirmHide,clickNum} from '../actions/homePage.js';

const initState = {
  totalHide:false,
  initData:{},
  showDrop:{},
  focusTextIndex:'',
  clickData:[],
  addItems:{},
  commSymHide:false
};

export default function (state=initState,action) {
  let res = Object.assign({},state);
  switch (action.type){
    case HIDE:
      res.totalHide = true;
      return res;
    case RESET:
      res.totalHide = false;
      res.commSymHide = false;
      return res;
    case SETDROPSHOW:
      return showDrop(state,action);
    case HIDEDROP:
      return confirmHide(state,action);
    case SETINITDATA:
      res.initData = action.data;
      return res;
    case CLICKCOUNT:
      return clickNum(state,action);
    case SETADDITEMINIT:
      return setAddItemInit(state,action);
    case SETT0EDIT:
      return setLabelToEdit(state,action);
    case SETREADDITEMS:
      res.addItems = action.data||{};
      return res;
    case ISREAD:
      res.isRead = Math.random();
      return res;
    case SETOTHERHISTORY:
      res.initData.otherHis = action.data;
      res.initData.otherHisSave = action.save;
      res.initData.otherIsHis = true;
      return res;
    /*case SETTEXTFOCUS:
      res.focusTextIndex = action.index;
      res.span=action.$span;
      return res;*/
    default:
      return res;
  }
}