Dataview and Metadata plugin questions

Hello everyone,

I am new to this plugin and I am looking for some help.

I use the Dataview plugin to track progress across different books, courses, todos etc. I am currently working on. The way this is structured is that I have .js component which contains a JSON where I store my progress (time spent, pages read etc.) and update these into my Metadata.

Below is a sample code, where I define a function which calculates my progress and my log function, which is assigned to a button logs it to metadata:

//define update
const {update} =["metaedit"].api

//function which calculates my progress on a book for example
function calculateProgress(){
	for (let i = 0; i < json.productivity.length; i++) {
		currentProgress += json.productivity[i].session.progress

	if (json.content > 0) {
		totalProgress = Math.round((currentProgress / json.content) * 100)
	else {
		totalProgress = 0;
//running the above function

//function which updates all the parameters I am calculating
function log(){
	// update("runRate", weeklyRunRateUnit + " " + json.unit + " " + weeklyRunRateTime + " minutes", dv.current().file.path)
	update("progress", totalProgress, dv.current().file.path)
	// update("estimation", Math.round(estDaysToFinish), dv.current().file.path)

// appending the log function to a button I can press
let container = document.createElement("a")
container.innerHTML = "SAVE CHANGES""white"
container.addEventListener("click", log)

The I am encountering is, that my page keeps refreshing most probably due to the {update} definition. Is there a way to stop this from happening?

Another problem is, that I define more functions that calculate some parameters such as time spent, progress this week, pages remaining etc. However my log() function only updates one parameter. I would love to run my log() and update all 3 (this is why there are commented out in the code above).

I would appreciate any help, if you need me to provide more material I will. Thank you in advance.

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