MCPcopy Create free account
hub / github.com/error311/FileRise / loadMoveFolderTargets

Function loadMoveFolderTargets

public/js/folderManager.js:310–339  ·  view source on GitHub ↗
(sourceFolder, sourceId)

Source from the content-addressed store, hash-verified

308}
309
310async function loadMoveFolderTargets(sourceFolder, sourceId) {
311 const targetSel = document.getElementById('moveFolderTarget');
312 if (!targetSel) return;
313 targetSel.innerHTML = '';
314 const activeId = getActiveSourceId();
315 const sameSource = (sourceId || activeId) === activeId;
316 const url = withBase('/api/folder/getFolderList.php')
317 + '?counts=0'
318 + (sourceId ? `&sourceId=${encodeURIComponent(sourceId)}` : '');
319 try {
320 let list = await fetch(url, { credentials: 'include' }).then(r => r.json());
321 if (Array.isArray(list) && list.length && typeof list[0] === 'object' && list[0].folder) {
322 list = list.map(it => it.folder);
323 }
324 const rootOpt = document.createElement('option');
325 rootOpt.value = 'root';
326 rootOpt.textContent = getRootLabel(sourceId || activeId);
327 targetSel.appendChild(rootOpt);
328 (list || [])
329 .filter(f => f && f !== 'trash' && (!sameSource || f !== (sourceFolder || '')))
330 .forEach(f => {
331 const o = document.createElement('option');
332 o.value = f;
333 o.textContent = f;
334 targetSel.appendChild(o);
335 });
336 } catch (e) {
337 // ignore
338 }
339}
340
341async function initMoveFolderSourceSelect(sourceFolder) {
342 const row = document.getElementById('moveFolderSourceRow');

Callers 1

Calls 3

withBaseFunction · 0.85
getActiveSourceIdFunction · 0.70
getRootLabelFunction · 0.70

Tested by

no test coverage detected