MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / buildDialog

Function buildDialog

notes.js:1280–3385  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1278 }
1279
1280 function buildDialog() {
1281 // 检查是否已存在弹窗,如果存在则先移除
1282 const existingOverlay = document.querySelector('.nsn-mask');
1283 if (existingOverlay) {
1284 document.body.removeChild(existingOverlay);
1285 }
1286
1287 ensureInitialData();
1288 const categories = readJSON(LS_KEYS.categories, []);
1289 const notesMap = readJSON(LS_KEYS.notes, {});
1290
1291 const overlay = createElement('div', { className: 'nsn-mask' });
1292 const dialog = createElement('div', { className: 'nsn-dialog' });
1293 overlay.appendChild(dialog);
1294
1295 const header = createElement('div', { className: 'nsn-header' }, [
1296 createElement('div', { className: 'nsn-title' }, ['笔记']),
1297 createElement('button', { className: 'nsn-close' }, ['×'])
1298 ]);
1299 dialog.appendChild(header);
1300
1301 // 添加拖动功能
1302 let isDragging = false;
1303 let dragStartX = 0;
1304 let dragStartY = 0;
1305 let initialLeft = 0;
1306 let initialTop = 0;
1307
1308 // 创建拖动区域(左上角30px区域)
1309 const dragArea = createElement('div', {
1310 className: 'nsn-drag-area',
1311 style: {
1312 position: 'absolute',
1313 top: '0',
1314 left: '0',
1315 width: '30px',
1316 height: '30px',
1317 cursor: 'move',
1318 zIndex: '10'
1319 }
1320 });
1321 dialog.appendChild(dragArea);
1322
1323 // 拖动事件处理
1324 dragArea.addEventListener('mousedown', (e) => {
1325 isDragging = true;
1326 dragStartX = e.clientX;
1327 dragStartY = e.clientY;
1328
1329 // 获取当前弹窗位置
1330 const rect = dialog.getBoundingClientRect();
1331 initialLeft = rect.left;
1332 initialTop = rect.top;
1333
1334 // 防止文本选择
1335 e.preventDefault();
1336
1337 // 添加拖动样式

Callers 1

showTrashDialogFunction · 0.85

Calls 15

ensureInitialDataFunction · 0.85
readJSONFunction · 0.85
createElementFunction · 0.85
buildToolbarFunction · 0.85
stopAutoSaveFunction · 0.85
renderNotesFunction · 0.85
clearEditorFunction · 0.85
saveCurrentFunction · 0.85
showSaveNotificationFunction · 0.85
renderCategoriesFunction · 0.85
restoreLastSelectedNoteFunction · 0.85
updateSaveStateFunction · 0.85

Tested by

no test coverage detected