controller.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. let changeStrand = (name)=>{
  2. for(let strand of document.querySelectorAll(".strand")){
  3. strand.style.display = "none";
  4. }
  5. for(let button of document.querySelectorAll(".menu > button")){
  6. button.classList = "";
  7. button.onclick = ()=>{changeStrand(`${button.id.slice(0, button.id.indexOf("Btn"))}Strand`)};
  8. }
  9. let activeButton = document.querySelector(`#${name.slice(0, name.indexOf("Strand"))}Btn`);
  10. activeButton.classList = "active";
  11. activeButton.onclick = undefined;
  12. document.querySelector(`#${name}`).style.display = "flex";
  13. window[`${name}Obj`].display();
  14. }
  15. let dateIndices = (from, to = new Date())=>{
  16. let indices = [];
  17. for(let i = 0; i < transactions.length; i++){
  18. if(transactions[i].date > from){
  19. indices[0] = i;
  20. break;
  21. }
  22. }
  23. for(let i = transactions.length - 1; i >=0; i--){
  24. if(transactions[i].date < to){
  25. indices[1] = i;
  26. break;
  27. }
  28. }
  29. return indices;
  30. }
  31. for(let transaction of transactions){
  32. transaction.date = new Date(transaction.date);
  33. }
  34. homeStrandObj.display();