Insert file name in a JSQuery

Things I have tried

What I’m trying to do

I wish to automatically put the name of the note in a JSQuery.
The query is for creating a progress bar indicating the percentage of a book I’ve read. IN the frontmatter I’ve put the total number of page and the page already read.

The query is:
Bar:: $= dv.view('view', {file: 'tba'})
and I want to chang tba with the name of the note, so I can just put the query in my Book Template and I need just to indicate the numeber of pages read.
Tried with this.fila.name and <% tp.file.title %> (I’ve Templater plugin installed) but it’s not working.
I don’t know nothing about js and so I’m sure is my fault.

Thanks in advance for any help

Hi.

  1. What’s JSQuery?
  2. If you don’t know JS, why you build your system based in a complex way that you can’t control? For example, a plug-in update or a change in a specific syntax destroys all your system and you don’t know how to fix it,
  3. Why you don’t start with solid steps learning the more basic DQL queries? You’re using the dv.view() with an “external” query in JS file… that is the real query, not the query you show us (the last one just “filter” what you want to see from the main one…).

Don’t get me wrong… But we can’t “jump” to a complex things (just because we want “results”) without a patient step by step learn. I’ve been here for a while and I still don’t know how to consistently use JS queries.

1 Like

You’re right but I don’t think I need to learn JavaScript just for solving this problem.
I haven’t created nothing complex: it is just the query I’ve posted above. I know that the “dv.view” part call a script (taken from this post ) and I wish to know if it would be possible to insert the name of the note (so the title of the book) automatically inside this script.
I’vve called this JSQuery since the post mention that you have to “Enable inline JavaScript Queries” in the Dataview plugin.
I know it would be better to learn something instead of getting just the answer but if this must be the case I can’t use any Obsidian’s plugin (I’m not a programmer I’m just a user) :smiley:

I’m also not a programmer, coder or similar. I’m just a user.
But I have as a rule not to drive a car if I don’t have the license to do so.
To do that, I have to be willing to learn and start with lower expectations.

Dataview has a documentation page with some basic information… and, in your case, maybe the more adequate is start with DQL, not with Dataview JS (DVJS).

I don’t know how you create your book page and the inherit metadata (inline? frontmatter?). But if you want to “build” a progress bar in the current page, with current data (i.e., a progress bar in book file taken as metadata the info placed in that same file), you don’t need to do that with JS (much less following the method defined in that post).

But this is my opinion…

I’ve tried to find a way for using Dataview but I haven’t find a way to automatically calculate the percentage having the data in the frontmatter.
I’ve found how to have a “manual progress bar” (where I input the data and calculate the percentage) but if it would be possible I prefer to let the program to do such kind of things.

I’m not interested in learning JavaScript just for this purpose and so I know that I can insert manually the book’s title and having the bar I want.

If you or somebody else can help me it’s great, otherwise no problem at all: I’ll remain with a manual input :grinning:

You want a progress bar in the current note? (i.e. you have a book file/page with the number of total pages and the number read pages… and you want in that same pages a “nice” progress bar)
If yes, place here one or two examples/files to see what’s the best way to do that without JS.

Thanks.
Following my frontmatter for one of the books. Of course I can change the frontmatter if this is needed.
I’m getting most of the data via Book Search plugin


tag: :books:Book
title: “How to Take Smart Notes”
author: “[[Sönke Ahrens]]”
category: Academic writing
publisher: Createspace Independent Publishing Platform
publish: 2017
total: 170
cover: https://books.google.com/books/content?id=DGMTzgEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api
rating:
date-read:
stato: reading
pagina: 62
autore: Sönke Ahrens
serie:
volume:
Progress: 62
Target: 170

To start, what’s your result with this inline query:

`="<progress value=" + this.pagina + " max=" + this.total + "></progress>" + " " + round(this.pagina/this.total*100) + "%"`

Thanks a lot! It seems to work.
Now I’ve to leave for a meeting but later today or tomorrow I’ll check it better and let you know.

Feel free to point me to the resource I need to read about this inline query (I hope is not hard to study)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.