Closed Mylloon closed 2 years ago
Decent solution.
Just a couple thoughts:
This could even be used for <audio>
and <video>
in the future. But this could be done in the future.
Maybe this could use cache so it doesn't call ajax again every time you switch pages and back, if the page is already loaded. But I'm not sure when it will be too much for JS memory. If the file is already loaded it can be added to the "loaded" variable and checked like this.
if (self.loaded[href]) {
window.location.hash = href
self.render_file(self.loaded[href])
return
}
Then it will also be cached if the image was already rendered alone. And to further lower traffic, it could keep a list of all images (urls) that didnt exist in pinedocs, so it won't keep doing unnessary ajax calls if the user navigates back to the same page.
But you don't have to do this now, just let me know and I will still merge it, and create issues for the notes.
But I just tested the code and it doesn't work if you are not in a directory, eg. "index.md". Seems like the regex expects a "/".
This fails: /(.*\/)/g.exec("index.md")[0]
Ok I'll take a look tomorrow
This could even be used for
<audio>
and<video>
in the future. But this could be done in the future.
Done
If the file is already loaded it can be added to the "loaded" variable
Done
And to further lower traffic, it could keep a list of all images (urls) that didnt exist in pinedocs, so it won't keep doing unnessary ajax calls if the user navigates back to the same page.
I added a black_list
variable so a stuff that don't exist only make one request
This fails:
/(.*\/)/g.exec("index.md")[0]
Fixed
I tried to solve the accessibility problem by putting the file name as an alternative text but the bot disagree 😅
Thanks!
Closes #170.
Certainly not the cleanest way to do it, but it works