Last active
March 7, 2022 17:21
-
-
Save MiracleXYZ/b04baf7eb1d8c91b71c3c2d6dd18c72d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let stepSize = 40; | |
let bigStepSize = 200; | |
if (app.isMobile) { | |
stepSize = 15; | |
bigStepSize = 100; | |
} | |
let completeSquare = '🟩'; | |
let notCompleteSquare = '⬛'; | |
let results = []; | |
let pages = dv.pages('"JobHunting/LeetCode/Problems"'); | |
for (let page of pages) { | |
let link = page.file.link; | |
link.display = completeSquare; | |
let rank = parseInt(page.file.name.slice(0, 4)); | |
if (rank) { | |
results.push({ | |
rank: rank, | |
name: page.file.name, | |
link: page.file.link | |
}); | |
} | |
} | |
results.sort((a, b) => a.rank - b.rank); | |
let current = 0; | |
let mapList = []; | |
for (let result of results) { | |
for (let i = 0; i < result.rank - current - 1; i++) { | |
mapList.push(notCompleteSquare); | |
} | |
mapList.push(result.link); | |
current = result.rank; | |
} | |
let displayString = ''; | |
for (let i = 0; i < mapList.length; i = i + stepSize) { | |
let startBigStep = Math.ceil((i) / bigStepSize); | |
let endBigStep = Math.ceil((i + stepSize) / bigStepSize); | |
if (endBigStep > startBigStep) { | |
displayString += ((endBigStep - 1) * bigStepSize).toString().padStart(4, ' '); | |
} else { | |
displayString += ' '.repeat(4); | |
} | |
displayString += ' ' + mapList.slice(i, i + stepSize).join('') + '<br>'; | |
} | |
dv.el('pre', displayString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Obsidian Completion Graph
I wrote this script to display my completion of LeetCode problems. Requires Obsidian and Dataview plugin, with
dataviewjs
enabled.Instruction
dataviewjs
, then copy all the code and paste into it.pages
to the path you want (or the filter you want).0123 lorem.md
.Showcase