mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
method name refactoring
This commit is contained in:
parent
211001fb2f
commit
cfce744338
@ -79,7 +79,7 @@ INSERT INTO notes VALUES('7H3OrcgB8Io6','Meeting minutes','<p>bla bla bla ...</p
|
||||
INSERT INTO notes VALUES('tX80udgxnW5n','18 - Monday','<p>Miscellaneous notes done on monday ...</p><p> </p><p>Interesting video: <a href="https://www.youtube.com/watch?v=_eSAF_qT_FY&feature=youtu.be">https://www.youtube.com/watch?v=_eSAF_qT_FY&feature=youtu.be</a></p><p> </p><p> </p>',0,0,'2018-08-29T17:29:24.548Z','2018-08-29T21:28:50.683Z','text','text/html','3ZuNMUCKI6');
|
||||
INSERT INTO notes VALUES('qEi5St9PBPCP','Button',replace('api.addButtonToToolbar({\n title: ''Weight Tracker'',\n icon: ''star'',\n action: () => api.activateNote(''8LOr7xUMuWD4'')\n});','\n',char(10)),0,0,'2018-08-28T20:50:36.150Z','2018-08-28T21:01:26.563Z','code','application/javascript;env=frontend','N9f0m+DlQA');
|
||||
INSERT INTO notes VALUES('kV2NwNNvepGF','JS code',replace('async function getChartData() {\n const days = await api.runOnServer(async () => {\n const notes = await api.getNotesWithLabel(''weight'');\n const days = [];\n\n for (const note of notes) {\n const date = await note.getLabelValue(''dateNote'');\n const weight = parseFloat(await note.getLabelValue(''weight''));\n\n if (date && weight) {\n days.push({ date, weight });\n }\n }\n\n days.sort((a, b) => a.date > b.date ? 1 : -1);\n\n return days;\n });\n\n const datasets = [\n {\n label: "Weight (kg)",\n backgroundColor: ''red'',\n borderColor: ''red'',\n data: days.map(day => day.weight),\n fill: false,\n spanGaps: true,\n datalabels: {\n display: false\n }\n }\n ];\n\n return {\n datasets: datasets,\n labels: days.map(day => day.date)\n };\n}\n\nconst ctx = $("#canvas")[0].getContext("2d");\n\nnew chartjs.Chart(ctx, {\n type: ''line'',\n data: await getChartData()\n});','\n',char(10)),0,0,'2018-08-28T20:50:36.092Z','2018-08-29T22:14:00.701Z','code','application/javascript;env=frontend','w+OzbwCEwQ');
|
||||
INSERT INTO notes VALUES('Dk5RGYzufXg3','JS code',replace('const persons = await api.runOnServer(async () => {\n const relationMapping = {\n isPartnerOf: "isPartnerOf",\n isChildOf: "hasChild",\n hasChild: "isChildOf"\n };\n \n const familyContainer = await api.originEntity.getRelationTarget(''familyContainer'');\n \n const persons = await familyContainer.findNotesWithLabel(''person'');\n const map = {};\n \n for (const person of persons) {\n const src = map[person.noteId] = map[person.noteId] || {};\n src.title = person.title;\n src.dateOfBirth = await person.getLabelValue(''dateOfBirth'') || '''';\n src.dateOfDeath = await person.getLabelValue(''dateOfDeath'') || '''';\n \n for (const relation of await person.getRelations()) {\n src[relation.name] = src[relation.name] || [];\n src[relation.name].push(relation.value);\n \n const trg = persons[relation.value] = persons[relation.value] || {};\n const inverseRelation = relationMapping[relation.name];\n \n trg[inverseRelation] = trg[inverseRelation] || [];\n trg[inverseRelation].push(person.noteId);\n }\n }\n \n return map;\n});\n\n// Create the input graph\nvar g = new dagreD3.graphlib.Graph()\n .setGraph({\n rankdir: "TB",\n ranksep: 100\n })\n .setDefaultEdgeLabel(function() { return {}; });\n\nfor (const noteId in persons) {\n const person = persons[noteId];\n \n const noteLink = await api.createNoteLink(noteId);\n \n g.setNode(noteId, { labelType: ''html'', label: noteLink[0].outerHTML \n + `<div style="color: black">${person.dateOfBirth.substr(0, 4)} - ${person.dateOfDeath.substr(0, 4)}</div>` });\n \n for (const childNoteId of (person.hasChild || [])) {\n g.setEdge(noteId, childNoteId);\n }\n}\n\ng.nodes().forEach(function(v) {\n var node = g.node(v);\n // Round the corners of the nodes\n node.rx = node.ry = 5;\n});\n\n// Create the renderer\nvar render = new dagreD3.render();\n\n// Set up an SVG group so that we can translate the final graph.\nvar svg = d3.select("svg"),\n svgGroup = svg.append("g");\n\n// Run the renderer. This is what draws the final graph.\nrender(d3.select("svg g"), g);\n\n// Center the graph\nvar xCenterOffset = (svg.attr("width") - g.graph().width) / 2;\nsvgGroup.attr("transform", "translate(" + xCenterOffset + ", 20)");\nsvg.attr("height", g.graph().height + 40);','\n',char(10)),0,0,'2018-08-28T20:50:21.939Z','2018-08-29T22:14:10.701Z','code','application/javascript;env=frontend','4CRzHnTsUv');
|
||||
INSERT INTO notes VALUES('Dk5RGYzufXg3','JS code',replace('const persons = await api.runOnServer(async () => {\n const relationMapping = {\n isPartnerOf: "isPartnerOf",\n isChildOf: "hasChild",\n hasChild: "isChildOf"\n };\n \n const familyContainer = await api.originEntity.getRelationTarget(''familyContainer'');\n \n const persons = await familyContainer.findChildNotesWithLabel(''person'');\n const map = {};\n \n for (const person of persons) {\n const src = map[person.noteId] = map[person.noteId] || {};\n src.title = person.title;\n src.dateOfBirth = await person.getLabelValue(''dateOfBirth'') || '''';\n src.dateOfDeath = await person.getLabelValue(''dateOfDeath'') || '''';\n \n for (const relation of await person.getRelations()) {\n src[relation.name] = src[relation.name] || [];\n src[relation.name].push(relation.value);\n \n const trg = persons[relation.value] = persons[relation.value] || {};\n const inverseRelation = relationMapping[relation.name];\n \n trg[inverseRelation] = trg[inverseRelation] || [];\n trg[inverseRelation].push(person.noteId);\n }\n }\n \n return map;\n});\n\n// Create the input graph\nvar g = new dagreD3.graphlib.Graph()\n .setGraph({\n rankdir: "TB",\n ranksep: 100\n })\n .setDefaultEdgeLabel(function() { return {}; });\n\nfor (const noteId in persons) {\n const person = persons[noteId];\n \n const noteLink = await api.createNoteLink(noteId);\n \n g.setNode(noteId, { labelType: ''html'', label: noteLink[0].outerHTML \n + `<div style="color: black">${person.dateOfBirth.substr(0, 4)} - ${person.dateOfDeath.substr(0, 4)}</div>` });\n \n for (const childNoteId of (person.hasChild || [])) {\n g.setEdge(noteId, childNoteId);\n }\n}\n\ng.nodes().forEach(function(v) {\n var node = g.node(v);\n // Round the corners of the nodes\n node.rx = node.ry = 5;\n});\n\n// Create the renderer\nvar render = new dagreD3.render();\n\n// Set up an SVG group so that we can translate the final graph.\nvar svg = d3.select("svg"),\n svgGroup = svg.append("g");\n\n// Run the renderer. This is what draws the final graph.\nrender(d3.select("svg g"), g);\n\n// Center the graph\nvar xCenterOffset = (svg.attr("width") - g.graph().width) / 2;\nsvgGroup.attr("transform", "translate(" + xCenterOffset + ", 20)");\nsvg.attr("height", g.graph().height + 40);','\n',char(10)),0,0,'2018-08-28T20:50:21.939Z','2018-08-29T22:14:10.701Z','code','application/javascript;env=frontend','4CRzHnTsUv');
|
||||
INSERT INTO notes VALUES('ucC6Zabv3Uml','CS',replace('/* This sets the color for "TK" nodes to a light blue green. */\ng.type-TK > rect {\n fill: #00ffd0;\n}\n\ntext {\n font-weight: 300;\n font-family: "Helvetica Neue", Helvetica, Arial, sans-serf;\n font-size: 14px;\n}\n\n.node rect {\n stroke: #999;\n fill: #fff;\n stroke-width: 1.5px;\n}\n\n.edgePath path {\n stroke: #333;\n stroke-width: 1.5px;\n}','\n',char(10)),0,0,'2018-08-28T20:50:22.120Z','2018-08-29T22:14:15.695Z','code','text/css','i19l+E0YSl');
|
||||
INSERT INTO notes VALUES('gYNJtGEPGW95','CSS',replace('span.fancytree-node.todo .fancytree-title {\n color: red !important;\n}\n\nspan.fancytree-node.done .fancytree-title {\n color: green !important;\n}','\n',char(10)),0,0,'2018-08-28T20:50:48.581Z','2018-08-29T22:14:28.006Z','code','text/css','gz0KCewmIx');
|
||||
INSERT INTO notes VALUES('s0Hhsl0nb1bg','Queen Elizabeth II.','<p> </p><p><strong>Elizabeth II</strong> (Elizabeth Alexandra Mary; born 21 April 1926)<a href="https://en.wikipedia.org/wiki/Elizabeth_II#cite_note-birthday-1">[a]</a> is <a href="https://en.wikipedia.org/wiki/Queen_of_the_United_Kingdom">Queen of the United Kingdom</a> and the other <a href="https://en.wikipedia.org/wiki/Commonwealth_realm">Commonwealth realms</a>.</p><p> </p><p>Elizabeth was born in <a href="https://en.wikipedia.org/wiki/London">London</a> as the first child of the Duke and Duchess of York, later <a href="https://en.wikipedia.org/wiki/King_George_VI">King George VI</a> and <a href="https://en.wikipedia.org/wiki/Queen_Elizabeth_The_Queen_Mother">Queen Elizabeth</a>, and she was educated privately at home. Her father acceded to the throne on the <a href="https://en.wikipedia.org/wiki/Edward_VIII_abdication_crisis">abdication</a> of his brother <a href="https://en.wikipedia.org/wiki/King_Edward_VIII">King Edward VIII</a> in 1936, from which time she was the <a href="https://en.wikipedia.org/wiki/Heir_presumptive">heir presumptive</a>. She began to undertake public duties <a href="https://en.wikipedia.org/wiki/Military_history_of_the_United_Kingdom_during_World_War_II">during the Second World War</a>, serving in the <a href="https://en.wikipedia.org/wiki/Auxiliary_Territorial_Service">Auxiliary Territorial Service</a>. In 1947, she married <a href="https://en.wikipedia.org/wiki/Philip,_Duke_of_Edinburgh">Philip, Duke of Edinburgh</a>, a former prince of <a href="https://en.wikipedia.org/wiki/Greece">Greece</a> and <a href="https://en.wikipedia.org/wiki/Denmark">Denmark</a>, with whom she has four children: <a href="https://en.wikipedia.org/wiki/Charles,_Prince_of_Wales">Charles, Prince of Wales</a>; <a href="https://en.wikipedia.org/wiki/Anne,_Princess_Royal">Anne, Princess Royal</a>; <a href="https://en.wikipedia.org/wiki/Andrew,_Duke_of_York">Andrew, Duke of York</a>; and <a href="https://en.wikipedia.org/wiki/Edward,_Earl_of_Wessex">Edward, Earl of Wessex</a>.</p><p> </p><p>When her father died in February 1952, she became <a href="https://en.wikipedia.org/wiki/Head_of_the_Commonwealth">Head of the Commonwealth</a> and <a href="https://en.wikipedia.org/wiki/Queen_regnant">queen regnant</a> of seven independent Commonwealth countries: the United Kingdom, <a href="https://en.wikipedia.org/wiki/Canada">Canada</a>, <a href="https://en.wikipedia.org/wiki/Australia">Australia</a>, <a href="https://en.wikipedia.org/wiki/New_Zealand">New Zealand</a>, <a href="https://en.wikipedia.org/wiki/Union_of_South_Africa">South Africa</a>, <a href="https://en.wikipedia.org/wiki/Dominion_of_Pakistan">Pakistan</a>, and <a href="https://en.wikipedia.org/wiki/Dominion_of_Ceylon">Ceylon</a>.</p>',0,0,'2018-08-28T20:50:22.196Z','2018-08-29T22:32:40.728Z','text','text/html','Fno0n5c24z');
|
||||
|
@ -438,7 +438,7 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="findNotesWithAttribute"><span class="type-signature">(async) </span>findNotesWithAttribute<span class="signature">(type, name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<Array.<<a href="Note.html">Note</a>>>}</span></h4>
|
||||
<h4 class="name" id="findChildNotesWithAttribute"><span class="type-signature">(async) </span>findChildNotesWithAttribute<span class="signature">(type, name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<Array.<<a href="Note.html">Note</a>>>}</span></h4>
|
||||
|
||||
|
||||
|
||||
@ -665,7 +665,7 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="findNotesWithLabel"><span class="type-signature">(async) </span>findNotesWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<Array.<<a href="Note.html">Note</a>>>}</span></h4>
|
||||
<h4 class="name" id="findChildNotesWithLabel"><span class="type-signature">(async) </span>findChildNotesWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<Array.<<a href="Note.html">Note</a>>>}</span></h4>
|
||||
|
||||
|
||||
|
||||
@ -861,7 +861,7 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="findNotesWithRelation"><span class="type-signature">(async) </span>findNotesWithRelation<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<Array.<<a href="Note.html">Note</a>>>}</span></h4>
|
||||
<h4 class="name" id="findChildNotesWithRelation"><span class="type-signature">(async) </span>findChildNotesWithRelation<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<Array.<<a href="Note.html">Note</a>>>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
@ -468,7 +468,7 @@ class Note extends Entity {
|
||||
* @param {string} [value] - attribute value
|
||||
* @returns {Promise<Note[]>}
|
||||
*/
|
||||
async findNotesWithAttribute(type, name, value) {
|
||||
async findChildNotesWithAttribute(type, name, value) {
|
||||
const params = [this.noteId, name];
|
||||
let valueCondition = "";
|
||||
|
||||
@ -506,7 +506,7 @@ class Note extends Entity {
|
||||
* @param {string} [value] - label value
|
||||
* @returns {Promise<Note[]>}
|
||||
*/
|
||||
async findNotesWithLabel(name, value) { return await this.findNotesWithAttribute(LABEL, name, value); }
|
||||
async findChildNotesWithLabel(name, value) { return await this.findChildNotesWithAttribute(LABEL, name, value); }
|
||||
|
||||
/**
|
||||
* Finds notes with given relation name and value. Only own relations are considered, not inherited ones
|
||||
@ -515,7 +515,7 @@ class Note extends Entity {
|
||||
* @param {string} [value] - relation value
|
||||
* @returns {Promise<Note[]>}
|
||||
*/
|
||||
async findNotesWithRelation(name, value) { return await this.findNotesWithAttribute(RELATION, name, value); }
|
||||
async findChildNotesWithRelation(name, value) { return await this.findChildNotesWithAttribute(RELATION, name, value); }
|
||||
|
||||
/**
|
||||
* Returns note revisions of this note.
|
||||
|
@ -433,14 +433,14 @@ class Note extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds notes with given attribute name and value. Only own attributes are considered, not inherited ones
|
||||
* Finds child notes with given attribute name and value. Only own attributes are considered, not inherited ones
|
||||
*
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @param {string} [value] - attribute value
|
||||
* @returns {Promise<Note[]>}
|
||||
*/
|
||||
async findNotesWithAttribute(type, name, value) {
|
||||
async findChildNotesWithAttribute(type, name, value) {
|
||||
const params = [this.noteId, name];
|
||||
let valueCondition = "";
|
||||
|
||||
@ -478,7 +478,7 @@ class Note extends Entity {
|
||||
* @param {string} [value] - label value
|
||||
* @returns {Promise<Note[]>}
|
||||
*/
|
||||
async findNotesWithLabel(name, value) { return await this.findNotesWithAttribute(LABEL, name, value); }
|
||||
async findChildNotesWithLabel(name, value) { return await this.findChildNotesWithAttribute(LABEL, name, value); }
|
||||
|
||||
/**
|
||||
* Finds notes with given relation name and value. Only own relations are considered, not inherited ones
|
||||
@ -487,7 +487,7 @@ class Note extends Entity {
|
||||
* @param {string} [value] - relation value
|
||||
* @returns {Promise<Note[]>}
|
||||
*/
|
||||
async findNotesWithRelation(name, value) { return await this.findNotesWithAttribute(RELATION, name, value); }
|
||||
async findChildNotesWithRelation(name, value) { return await this.findChildNotesWithAttribute(RELATION, name, value); }
|
||||
|
||||
/**
|
||||
* Returns note revisions of this note.
|
||||
|
@ -420,7 +420,7 @@ async function createNoteBox(noteId, title, x, y) {
|
||||
const $noteBox = $("<div>")
|
||||
.addClass("note-box")
|
||||
.prop("id", noteIdToId(noteId))
|
||||
.append($("<span>").addClass("title").html(await linkService.createNoteLink(noteId, title)).append(`[${Math.floor(x)}, ${Math.floor(y)}]`))
|
||||
.append($("<span>").addClass("title").html(await linkService.createNoteLink(noteId, title)))
|
||||
.append($("<div>").addClass("endpoint").attr("title", "Start dragging relations from here and drop them on another note."))
|
||||
.css("left", x + "px")
|
||||
.css("top", y + "px");
|
||||
|
Loading…
x
Reference in New Issue
Block a user