| 1 |
|
| 2 |
(function() { |
| 3 |
function applyView(view) { |
| 4 |
var container = document.getElementById('items-container'); |
| 5 |
if (container) { |
| 6 |
container.className = 'items-container items-' + view + '-view'; |
| 7 |
} |
| 8 |
document.querySelectorAll('.view-btn').forEach(function(btn) { |
| 9 |
btn.classList.toggle('is-selected', btn.dataset.view === view); |
| 10 |
}); |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
document.addEventListener('DOMContentLoaded', function() { |
| 15 |
var saved = safeStorageGet('projectViewPref') || 'grid'; |
| 16 |
applyView(saved); |
| 17 |
}); |
| 18 |
|
| 19 |
|
| 20 |
document.querySelectorAll('.view-btn').forEach(function(btn) { |
| 21 |
btn.addEventListener('click', function() { |
| 22 |
var view = btn.dataset.view; |
| 23 |
applyView(view); |
| 24 |
safeStorageSet('projectViewPref', view); |
| 25 |
}); |
| 26 |
}); |
| 27 |
})(); |
| 28 |
|