class Controller { constructor(presenter) { this.presenter = presenter; }…
- User
class Controller { constructor(presenter) { this.presenter = presenter; }
codehandleEvent(element) { this.presenter.setLayout(element); }}
class Presenter { constructor(containerId) { this.container = document.getElementById(containerId); this.divs = this.container.querySelectorAll('.inner-div'); }
codesetLayout(layoutType) { this.divs.forEach(div => { div.style.removeProperty('left'); div.style.removeProperty('top'); div.style.removeProperty('right'); div.style.removeProperty('bottom'); div.style.display = 'none'; div.textContent = ''; }); switch (layoutType) { case 'A': [0, 1, 2].forEach(i => { this.divs[i].style.display = 'flex'; }); this.divs[0].style.left = '0'; this.divs[0].style.top = '0'; this.divs[0].textContent = 'Michal'; this.divs[1].style.left = '45%'; this.divs[1].style.top = '45%'; this.divs[1].textContent = 'Zwolinski'; this.divs[2].style.right = '0'; this.divs[2].style.bottom = '0'; this.divs[2].textContent = '3'; break; case 'B': this.divs.forEach((div, index) => { div.style.display = 'flex'; div.style.left = `${index * 33.3}%`; div.style.top = '45%'; }); this.divs[0].textContent = 'Michal'; this.divs[1].textContent = 'Zwolinski'; this.divs[2].textContent = '3'; break; case 'C': [0, 1, 2, 3].forEach(i => { this.divs[i].style.display = 'flex'; }); this.divs[0].style.left = '0'; this.divs[0].style.top = '0'; this.divs[0].textContent = 'Michal'; this.divs[1].style.left = '12%'; this.divs[1].style.top = '0'; this.divs[1].textContent = 'zwolinski'; this.divs[2].style.right = '0'; this.divs[2].style.bottom = '0'; this.divs[2].textContent = '4'; this.divs[3].style.right = '12%'; this.divs[3].style.bottom = '0'; this.divs[3].textContent = '3'; break; } } - Assistant
To ensure that only three squares are displayed in the "B" case layout, you can modify the
setLayoutmethod within thePresenterclass. Here's how you can adjust the code for case 'B' to specifically target and modify only the first three divs as needed, and make sure no additional divs beyond the initial three are displayed: - User
pokaz to co zmieniles
- Assistant
Absolutely! Here is a detailed view of the specific changes I made to the
setLayoutfunction for case 'B' in your class. These changes ensure only the first three div elements are visible and properly configured according to your layout 'B' requirement: - User
chcialbym zeby case B byl dobrze wysrodkowany
- Assistant
- User
ale teraz te prostokaty sa rozciagniete a nie maja takie byc
- Assistant