1 line
5.5 KiB
JSON
1 line
5.5 KiB
JSON
{"notes": [{"noteId": "EW0u2LoAZTYv", "title": "표 표시 (renderTable)", "type": "code", "mime": "application/javascript;env=frontend", "content": "module.exports = counts => {\n const $statsTable = api.$container.find('.stats-table');\n \n addRow('합계', \n counts.reduce((acc, cur) => acc + cur.countNotDeleted, 0), \n counts.reduce((acc, cur) => acc + cur.countDeleted, 0)\n );\n \n for (const count of counts) {\n addRow(count.type, count.countNotDeleted, count.countDeleted);\n }\n\n function addRow(type, countNotDeleted, countDeleted) {\n $statsTable.append(\n $(\"<tr>\")\n .append($(\"<td>\").text(type))\n .append($(\"<td>\").text(countNotDeleted))\n .append($(\"<td>\").text(countDeleted))\n );\n }\n}"}, {"noteId": "WJaFVVj6QO1J", "title": "자바스크립트 (js)", "type": "code", "mime": "application/javascript;env=frontend", "content": "const noteCounts = await api.runOnBackend(() => {\n return api.sql.getRows(`\n SELECT\n type,\n isDeleted,\n SUM(CASE WHEN isDeleted=0 THEN 1 ELSE 0 END) AS countNotDeleted,\n SUM(CASE WHEN isDeleted=1 THEN 1 ELSE 0 END) AS countDeleted\n FROM notes\n GROUP BY type\n ORDER BY countNotDeleted DESC`);\n});\n\nrenderPieChart(noteCounts.map(nc => {\n return {\n name: nc.type,\n count: nc.countNotDeleted\n };\n}));\n\nrenderTable(noteCounts);"}, {"noteId": "ga590IKu7zmy", "title": "속성 변경 처리 (attributechanged)", "type": "code", "mime": "application/javascript;env=backend", "content": "if (![\"task\", \"location\", \"tag\", \"todoDate\", \"doneDate\"].includes(api.originEntity.name)) {\n return;\n}\n\nconst tagRootNote = api.getNoteWithLabel('taskTagRoot');\nconst doneRootNote = api.getNoteWithLabel('taskDoneRoot');\nconst todoRootNote = api.getNoteWithLabel('taskTodoRoot');\n\nif (!tagRootNote || !doneRootNote || !todoRootNote) {\n console.log(\"태그 또는 완료 목록 또는 할 일 목록의 기준 노트를 찾을 수 없습니다.\");\n return;\n}\n\nconst note = api.originEntity.getNote();\n\nif (note.isDeleted) {\n return;\n}\n \nconst attributes = note.getAttributes();\n\nconst todoDate = note.getLabelValue('todoDate');\nconst doneDate = note.getLabelValue('doneDate');\n\nfunction isWithinExpectedRange(date) {\n if (!date) {\n return true;\n }\n \n const year = parseInt(date.substr(0, 4));\n \n return year >= 2010 && year < 2050;\n}\n\nif (!isWithinExpectedRange(todoDate) || !isWithinExpectedRange(doneDate)) {\n console.log(`날짜가 허용 범위를 벗어났습니다. 예정일: ${todoDate} / 완료일: ${doneDate}`);\n \n return;\n}\n\nconst isTaskDone = !!doneDate;\n\napi.toggleNoteInParent(isTaskDone, note.noteId, doneRootNote.noteId);\napi.toggleNoteInParent(!isTaskDone, note.noteId, todoRootNote.noteId);\n\nconst location = note.getLabelValue('location');\nconst locationRootNote = api.getNoteWithLabel('taskLocationRoot');\n\nreconcileAssignments(note, locationRootNote, location ? [location] : [], 'taskLocationNote', isTaskDone);\n\nconst tags = attributes.filter(attr => attr.type === 'label' && attr.name === 'tag').map(attr => attr.value);\n\nreconcileAssignments(note, tagRootNote, tags, 'taskTagNote', isTaskDone);\n\nnote.toggleLabel(isTaskDone, \"cssClass\", \"done\");\n\nconst doneTargetNoteId = isTaskDone ? api.getDayNote(doneDate).noteId : null;\napi.setNoteToParent(note.noteId, 'DONE', doneTargetNoteId);\n\nnote.toggleLabel(!isTaskDone, \"cssClass\", \"todo\");\n\nconst todoTargetNoteId = (!isTaskDone && todoDate) ? api.getDayNote(todoDate).noteId : null;\napi.setNoteToParent(note.noteId, 'TODO', todoTargetNoteId);"}, {"noteId": "swKGGdlek7o6", "title": "아이작 아시모프의 마지막 질문.pdf", "type": "file", "mime": "application/pdf"}], "attributes": [{"attributeId": "teXYgLEYyqww", "noteId": "7NfbiSmiVFyR", "name": "label:weight", "value": "promoted,number,single,precision=1"}, {"attributeId": "Gt3n5YmjWd92", "noteId": "1A2pDj0rZWRk", "name": "label:geolocation", "value": "promoted,alias=Geolocation,single,text"}, {"attributeId": "mNukzJtxNy9F", "noteId": "PF0ofV83QNq9", "name": "label:readingEnd", "value": "promoted,single,date"}, {"attributeId": "84Eslb7zduKM", "noteId": "PF0ofV83QNq9", "name": "label:readingStart", "value": "promoted,single,date"}, {"attributeId": "oOhOmvlQA1l7", "noteId": "PF0ofV83QNq9", "name": "label:author", "value": "promoted,single,text"}, {"attributeId": "ovlzSwPHBESP", "noteId": "PF0ofV83QNq9", "name": "label:link", "value": "promoted,single,url"}, {"attributeId": "1YTM1UQRQtnt", "noteId": "rjbXo0acF0uE", "name": "label:location", "value": "promoted,text,single"}, {"attributeId": "KbYhsredrwOt", "noteId": "rjbXo0acF0uE", "name": "label:tag", "value": "promoted,text,multi"}, {"attributeId": "UE1YHe51q07k", "noteId": "rjbXo0acF0uE", "name": "label:todoDate", "value": "promoted,date,single"}, {"attributeId": "PmBHwLv8Dtf3", "noteId": "rjbXo0acF0uE", "name": "label:doneDate", "value": "promoted,date,single"}], "branches": [{"branchId": "E1e6RXYb7KDR_HlLfbi37EMDe", "noteId": "HlLfbi37EMDe", "prefix": "TODO"}, {"branchId": "Zqbx4QzZLAw2_0za9R4spbuOD", "noteId": "0za9R4spbuOD", "prefix": "DONE"}, {"branchId": "GIfEhKrDNdnn_2JsGaSEmZSku", "noteId": "2JsGaSEmZSku", "prefix": "DONE"}, {"branchId": "GIfEhKrDNdnn_hpxIn2I2IdAJ", "noteId": "hpxIn2I2IdAJ", "prefix": "TODO"}, {"branchId": "m6DbuIecq3cC_BdeGRs0x9xSN", "noteId": "BdeGRs0x9xSN", "prefix": "28. 11. 2017"}]} |