documentation for all JS files
This commit is contained in:
@@ -1,10 +1,29 @@
|
||||
/**
|
||||
* @fileoverview Manages the starred files functionality for the document management system.
|
||||
* This file handles the starred files view and user view preferences.
|
||||
* It provides functionality to view starred items in either grid or list view
|
||||
* and manages user view preferences for the starred items section.
|
||||
*/
|
||||
|
||||
let currentView = 'grid';
|
||||
|
||||
/**
|
||||
* Initializes the starred files view when the DOM content is loaded.
|
||||
* Sets up the initial view based on user preferences.
|
||||
* @function
|
||||
*/
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Initialize view
|
||||
initializeView();
|
||||
});
|
||||
|
||||
/**
|
||||
* Initializes the view based on user preferences.
|
||||
* Fetches the user's preferred view (grid or list) and applies it.
|
||||
* Falls back to grid view if there's an error.
|
||||
* @async
|
||||
* @function
|
||||
*/
|
||||
async function initializeView() {
|
||||
try {
|
||||
const response = await fetch('/api/user/preferred_view');
|
||||
@@ -18,6 +37,13 @@ async function initializeView() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles between grid and list views for starred files.
|
||||
* Updates the UI and saves the user's view preference.
|
||||
* @function
|
||||
* @param {string} view - The view to switch to ('grid' or 'list')
|
||||
* @throws {Error} If the view preference cannot be saved
|
||||
*/
|
||||
function toggleView(view) {
|
||||
currentView = view;
|
||||
const grid = document.getElementById('fileGrid');
|
||||
|
||||
Reference in New Issue
Block a user