Skip to content

Build your personal knowledge base with Trilium Notes

Updated all scripts to current versions working with current script API

azivner44bcdedaba86
diff --git a/src/scripts/Reddit Importer.tar b/src/scripts/Reddit Importer.tar
index b8145e9825..7435750ff5 100644
Binary files a/src/scripts/Reddit Importer.tar and b/src/scripts/Reddit Importer.tar differ
diff --git a/src/scripts/Today.tar b/src/scripts/Today.tar
new file mode 100644
index 0000000000..761eb17aaf
Binary files /dev/null and b/src/scripts/Today.tar differ
diff --git a/src/scripts/Weight Tracker.tar b/src/scripts/Weight Tracker.tar
new file mode 100644
index 0000000000..0a88916577
Binary files /dev/null and b/src/scripts/Weight Tracker.tar differ
diff --git a/src/scripts/today.js b/src/scripts/today.js
deleted file mode 100644
index 1204f1ea7f..0000000000
--- a/src/scripts/today.js
+++ /dev/null
@@ -1,13 +0,0 @@
-api.addButtonToToolbar('go-today', $('<button class="btn btn-xs" onclick="goToday();"><span class="ui-icon ui-icon-calendar"></span> Today</button>'));
-
-window.goToday = async function() {
- const todayDateStr = formatDateISO(new Date());
-
- const todayNoteId = await server.exec([todayDateStr], async todayDateStr => {
- return await this.getDateNoteId(todayDateStr);
- });
-
- api.activateNote(todayNoteId);
-};
-
-$(document).bind('keydown', "alt+t", window.goToday);
\ No newline at end of file
diff --git a/src/scripts/weight.html b/src/scripts/weight.html
deleted file mode 100644
index c976058d7a..0000000000
--- a/src/scripts/weight.html
+++ /dev/null
@@ -1,146 +0,0 @@
-<form id="weight-form" style="display: flex; width: 700px; justify-content: space-around; align-items: flex-end;">
- <div>
- <label for="weight-date">Date</label>
- <input type="text" id="weight-date" class="form-control" style="width: 150px; text-align: center;" />
- </div>
- <div>
- <label for="weight">Weight</label>
- <input type="number" id="weight" value="80.0" step="0.1" class="form-control" style="text-align: center; width: 100px;" />
- </div>
- <div>
- <label for="comment">Comment</label>
- <input type="text" id="comment" class="form-control" style="width: 200px;" />
- </div>
-
- <button type="submit" class="btn btn-primary">Add</button>
-</form>
-
-<br/><br/>
-
-<canvas id="canvas"></canvas>
-
-<script>
- (async function() {
- const $form = $("#weight-form");
- const $date = $("#weight-date");
- const $weight = $("#weight");
- const $comment = $("#comment");
- let chart;
-
- $date.datepicker();
- $date.datepicker('option', 'dateFormat', 'yy-mm-dd');
- $date.datepicker('setDate', new Date());
-
- async function saveWeight() {
- await server.exec([$date.val(), parseFloat($weight.val()), $comment.val()], async (date, weight, comment) => {
- const dataNote = await this.getNoteWithAttribute('date_data', date);
-
- if (dataNote) {
- dataNote.jsonContent.weight = weight;
-
- if (comment) {
- dataNote.jsonContent.weight_comment = comment;
- }
-
- await this.updateEntity(dataNote);
- }
- else {
- const parentNoteId = await this.getDateNoteId(date);
- const jsonContent = { weight: weight };
-
- if (comment) {
- jsonContent.weight_comment = comment;
- }
-
- await this.createNote(parentNoteId, 'data', jsonContent, {
- json: true,
- attributes: {
- date_data: date,
- hide_in_autocomplete: null
- }
- });
- }
- });
-
- showMessage("Weight has been saved");
-
- chart.data = await getData();
- chart.update();
- }
-
- async function drawChart() {
- const data = await getData();
-
- const ctx = $("#canvas")[0].getContext("2d");
-
- chart = new Chart(ctx, {
- type: 'line',
- data: data,
- options: {
- tooltips: {
- enabled: true,
- mode: 'single',
- callbacks: {
- label: function (tooltipItem, data) {
- const multistringText = [tooltipItem.yLabel];
- const comment = data.comments[tooltipItem['index']];
-
- if (comment) {
- multistringText.push(comment);
- }
-
- return multistringText;
- }
- }
- },
- }
- });
- }
-
- async function getData() {
- const data = await server.exec([], async () => {
- const notes = await this.getNotesWithAttribute('date_data');
- const data = [];
-
- for (const note of notes) {
- const dateAttr = await note.getAttribute('date_data');
-
- data.push({
- date: dateAttr.value,
- weight: note.jsonContent.weight,
- comment: note.jsonContent.weight_comment
- });
- }
-
- data.sort((a, b) => a.date < b.date ? -1 : +1);
-
- return data;
- });
-
- const datasets = [{
- label: "Weight",
- backgroundColor: 'red',
- borderColor: 'red',
- data: data.map(row => row.weight),
- fill: false
- }];
-
- const labels = data.map(row => row.date);
- const comments = data.map(row => row.comment);
-
- return {
- labels: labels,
- datasets: datasets,
- comments: comments
- };
- }
-
- $form.submit(event => {
- saveWeight();
-
- event.preventDefault();
- });
-
- drawChart();
- })();
-</script>
\ No newline at end of file