diff --git a/src/App.js b/src/App.js index 56fd345..45b2dd2 100755 --- a/src/App.js +++ b/src/App.js @@ -17,7 +17,8 @@ import Spinner from 'react-bootstrap/Spinner'; import Form from 'react-bootstrap/Form'; import { FaCheckCircle } from 'react-icons/fa'; -import { IoCheckmarkCircleOutline,IoCloseCircleSharp,IoAlertCircleOutline } from 'react-icons/io5'; +import { BiAlarmAdd } from 'react-icons/bi'; +import { MdAlarmOff } from 'react-icons/md'; const fuzzysort = require('fuzzysort') @@ -37,8 +38,36 @@ const progress2 = new Audio(process.env.PUBLIC_URL+"/progress2.mp3") const retainerNames = ["Ayayayaya","Kittystorage","Morecatz","Finalretainer","Nowitsabun","Butwhy","Kkittyy","Howdoesanyonenameall","Ayayayayay"]; function Item(p){ - const {item,setLockout,contributor,lockout,itemCount,totalItemCount,playerInventory} = p + const {item,contributor,itemCount,totalItemCount,playerInventory} = p const [itemLoc,setItemLoc]=useState("") + const [itemTimers,setItemTimers]=useState([]) + const [lockout,setLockout]=useState(false) + + function updateTimer(ts,te,timerIndex) { + var newTimerStart=[]; + if (item.timer_start!==null){ + newTimerStart=[...item.timer_start.split(",")]; + } + var newTimerEnd=[]; + if (item.timer_end!==null){ + newTimerEnd=[...item.timer_end.split(",")]; + } + if (ts==""&&te==""){ + newTimerStart=newTimerStart.filter((item,i)=>i!=timerIndex); + newTimerEnd=newTimerEnd.filter((item,i)=>i!=timerIndex); + } else { + newTimerStart[timerIndex]=ts; + newTimerEnd[timerIndex]=te; + } + setLockout(true) + axios.post(BACKEND_URL+"/updateTimer",{timer_start:newTimerStart.join(","),timer_end:newTimerEnd.join(","),id:item.id,last_modified:new Date()}) + .then((data)=>{ + setLockout(false) + }) + .catch((err)=>{ + setLockout(false) + }) + } function updateItem(item,target,contributor) { var correctedVal=Math.min(item.required,target.value); @@ -49,7 +78,7 @@ function Item(p){ setLockout(false) }) .catch((err)=>{ - + setLockout(false) }) } @@ -131,7 +160,7 @@ function Item(p){ tempItem.amt+=it.amt } tempItem.page=Math.floor(j/35+1) - locObj[String(retainerNames[i-1])]={...tempItem} + locObj[String(retainerNames[i-1])]={...tempItem} } } } @@ -145,6 +174,12 @@ function Item(p){ //locs+="Player Inventory ["+Math.floor((j/35+1))+"] x"+it.amt } setItemLoc(locs) + if (item.required!==item.obtained&&item.timer_start!==null&&item.timer_start.length>0&&item.timer_start[0]!=""){ + var endTimers = item.timer_end.split(","); + setItemTimers(item.timer_start.split(",").map((t,i)=>{return {timer_start:t,timer_end:endTimers[i]}})) + } else { + setItemTimers([]) + } },[item,playerInventory]) return @@ -164,12 +199,35 @@ function Item(p){ updateItem(item,{value:item.required},contributor) }}/>} - + {item.required!==item.obtained&&<> + View Item Info + + {if (item.timer_start!==null&&item.timer_start.length>0){updateTimer("0:00","3:00",item.timer_start.split(",").length)} else {updateTimer("0:00","3:00",0)}}}/> + + + {itemTimers.map((timer,i)=>)} + } } +function Timer(p){ + const {timer_start,timer_end,timerIndex,updateTimer,lockout}=p + const [timerStart,setTimerStart] = useState("") + const [timerEnd,setTimerEnd] = useState("") + useEffect(()=>{ + setTimerStart(timer_start) + setTimerEnd(timer_end) + },[timer_start,timer_end]) + return + {setTimerStart(f.currentTarget.value)}} onKeyDown={(k)=>{if (k.key==='Enter') {if (k.currentTarget.value!=timer_start){updateTimer(k.currentTarget.value,timer_end,timerIndex)}}}} onBlur={(f)=>{if (f.currentTarget.value!=timer_start){updateTimer(f.currentTarget.value,timer_end,timerIndex)}}}> + - + {setTimerEnd(f.currentTarget.value)}} onKeyDown={(k)=>{if (k.key==='Enter') {if (k.currentTarget.value!=timer_end){updateTimer(timer_start,k.currentTarget.value,timerIndex)}}}} onBlur={(f)=>{if (f.currentTarget.value!=timer_end){updateTimer(timer_start,f.currentTarget.value,timerIndex)}}}> + {updateTimer("","",timerIndex)}}/> + +} + function ItemGroup(p) { const { data } = p const { contributor,itemCount,totalItemCount,playerInventory,lockout,setLockout } = p @@ -472,6 +530,32 @@ function ListApp(p){ } +function TimeDisplay(duration){ + var hrs=Math.floor(duration/3600) + var min=Math.floor(duration/60)%60 + return (hrs>0?hrs+" hrs,":"")+min+" min" +} + +function TimerDisplay(p){ + const {timer,eorzeanTime} = p + var eorzeanSeconds=Number(eorzeanTime.split(":")[0])*3600+Number(eorzeanTime.split(":")[1])*60 + return <> + + {timer.name} {eorzeanSeconds>timer.actual_seconds&&eorzeanSecondstimer.actual_seconds)?timer.actual_seconds+86400-eorzeanSeconds:timer.actual_seconds-eorzeanSeconds)} + + + {timer.timer_start} - {timer.timer_end} + + + + + + timer.actual_seconds&&eorzeanSecondstimer.actual_seconds&&eorzeanSecondstimer.actual_seconds&&eorzeanSecondstimer.actual_seconds?eorzeanSeconds + + + +} + function App() { const [data,setData] = useState([]) @@ -493,6 +577,10 @@ function App() { const [lastModified,setLastModified] = useState(new Date()) const [lastUpdate,setLastUpdate] = useState(0) const [playerInventory,setPlayerInventory] = useState([]) + const [eorzeanTime,setEorzeanTime] = useState("") + const [timerList,setTimerList] = useState([]) + const [timerCutList1,setTimerCutList1] = useState([]) + const [timerCutList2,setTimerCutList2] = useState([]) const [contributor,setContributor] = useState("") const [notifications,setNotifications] = useState([]) @@ -503,11 +591,25 @@ function App() { const [matchedItems,setMatchedItems] = useState([]) - const [lockout,setLockout] = useState(false) + //const [lockout,setLockout] = useState(false) function LZ(digits,numb) { return "0".repeat(digits-String(numb).length)+numb } + + useEffect(()=>{ + var eorzeanSeconds=Number(eorzeanTime.split(":")[0])*3600+Number(eorzeanTime.split(":")[1])*60 + var timerObjs=timerList.map((item)=>{ + var seconds=Number(item.timer_start.split(":")[0])*3600+Number(item.timer_start.split(":")[1])*60 + var originalSeconds=seconds + var endSeconds=Number(item.timer_end.split(":")[0])*3600+Number(item.timer_end.split(":")[1])*60 + if (endSeconds=0&&eorzeanSecondsa.end_seconds-b.end_seconds) + setTimerCutList1(timerObjs.filter((timer)=>timer.end_seconds>=eorzeanSeconds)) + setTimerCutList2(timerObjs.filter((timer)=>timer.end_seconds{ const interval = setInterval(()=>{ @@ -519,6 +621,20 @@ function App() { return axios.get("https://projectdivar.com:4505/getData") .then((data)=>{ //setData(data.data) + var timers=[] + var timerItems=data.data.filter((item)=>item.obtained!=item.required&&item.timer_start!=null&&item.timer_start.length>0) + for (item of timerItems){ + var splitter=item.timer_start.split(",") + var splitter2=item.timer_end.split(",") + var i=0 + for (var t of splitter){ + var newItem={...item} + newItem.timer_start=t + newItem.timer_end=splitter2[i++] + timers=[...timers,newItem] + } + } + setTimerList(timers) setData(data.data.slice(dataSplitters[0],dataSplitters[1])) setData2(data.data.slice(dataSplitters[1],dataSplitters[2])) setData3(data.data.slice(dataSplitters[2],dataSplitters[3])) @@ -577,6 +693,22 @@ function App() { return ()=>clearInterval(interval) },[nav,lastUpdate]) + useEffect(()=>{ + const interval = setInterval(()=>{ + if (nav==="main"){ + var date=new Date() + var earthH=date.getHours(),earthM=date.getMinutes(),earthS=date.getSeconds() + var earthTime=earthH*3600+earthM*60+earthS + var eorzeanTime=earthTime*20.571428571428571428571428571429 + var eorzeanH=Math.floor(eorzeanTime/3600)%24 + var eorzeanM=Math.floor(eorzeanTime/60)%60 + var eorzeanS=Math.floor(eorzeanTime)%60 + setEorzeanTime((("0")+eorzeanH).slice(-2)+":"+(("0")+eorzeanM).slice(-2)) + } + },3000) + return ()=>clearInterval(interval) + },[nav,lastUpdate]) + useEffect(()=>{ var notificationLastUpdate = new Date(new Date()-(NOTIFICATIONTIMEOUT*1000)) var largestNotificationID = -1 @@ -627,6 +759,20 @@ function App() { axios.get("https://projectdivar.com:4505/getData") .then((data)=>{ //setData(data.data) + var timers=[] + var timerItems=data.data.filter((item)=>item.obtained!=item.required&&item.timer_start!=null&&item.timer_start.length>0) + for (item of timerItems){ + var splitter=item.timer_start.split(",") + var splitter2=item.timer_end.split(",") + var i=0 + for (var t of splitter){ + var newItem={...item} + newItem.timer_start=t + newItem.timer_end=splitter2[i++] + timers=[...timers,newItem] + } + } + setTimerList(timers) setData(data.data.slice(dataSplitters[0],dataSplitters[1])) setData2(data.data.slice(dataSplitters[1],dataSplitters[2])) setData3(data.data.slice(dataSplitters[2],dataSplitters[3])) @@ -773,7 +919,7 @@ function App() { return ( - + BUN logo BUN Collab App @@ -784,52 +930,64 @@ function App() { } - - {contributor.length===0?<> - {if (k.key==='Enter') {setContributor(document.getElementById("username").value)}}} id="username"/> - - : - nav==="main"? - data.length>0? - <> - - {Math.floor(Number(completeRatio)+Number(inProgressRatio)+Number(craftsRatio))}% complete({itemCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " / " + totalItemCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}) - - - - - - - - - - -
- - { - updateSearch(f.currentTarget.value) - }} /> - {matchedItems.map((item)=>)} - -
-
- - - - - - - : - :nav==="list"?: - <> - } -
- - {notifications.map((not)=>{ - return - })} - -
+ + + + + {contributor.length===0?<> + {if (k.key==='Enter') {setContributor(document.getElementById("username").value)}}} id="username"/> + + : + nav==="main"? + data.length>0? + <> + + {Math.floor(Number(completeRatio)+Number(inProgressRatio)+Number(craftsRatio))}% complete({itemCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " / " + totalItemCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}) + + + + + + + + + + +
+ + { + updateSearch(f.currentTarget.value) + }} /> + {matchedItems.map((item)=>)} + +
+
+ + + + + + + : + :nav==="list"?: + <> + } +
+ + {notifications.map((not)=>{ + return + })} + +
+ + {contributor.length>0&& + + TimersET: {eorzeanTime} + {timerCutList1.map((timer,i)=>)} + {timerCutList2.map((timer,i)=>)} + + } +
);