I tested a bit and was able to achieve at least partial caching of the slowest loading folder in my library. Let us call that folder "slowfolder" from now on.
The file to edit is
runeui.js
First some background. When you navigate to the slowfolder (or any other folder) in the library
runeui.js by default does these things every time:
1 call the function getDB(options) which does a
2 $.post call to MPD to retrieve data about the folder contents. The returned data is next
3 put into the function populateDB(options)
4 which generates the html content for that library page.
We can speed things with these changes to runeui.js
1 near the top declare an empty variable to later on put the cached content in
2 edit populateDB(options) tot save the content to a cache variable when our slowfolder is loaded the first time and thereafter reuse that content each time the folder is opened.
3 edit getDB(options) to similarly only read data for the slowfolder from MPD the first time and thereafter resuse the cached content.
Before you jump in keep in mind that this is only partial caching because the first load of the slowfolder will not be any faster than before. And every time the browser tab is reloaded or closed and reopened the next load of slowfolder will be slow again.
A better method could generate the content for the slowfolder in the background when RuneAudio boots and then save it to a variable in php that is stable between browser reloads and is available on all devices. I'll be delighted if someone comes up with something like that.
But for now this is what I've got
Below the line
// Global GUI Array
add these lines
var slowcache;
var slowfolder = "USB/one folder/the slow folder"
Edit the slowfolder string to match the folder you want to enable cache for. I think the structure is <mountpoint root name>/<subfolder name>/<slow folder name>
Inside the large getDB(options) function find the line
else if (cmd === 'browse') {
and add this directly below it
if ((path == slowfolder && slowcache)
populateDB({
data: "",
path: path,
uplevel: uplevel
});
else
Make sure there is no empty line between that final else and the already existing content that comes next in the file. In other words it should look like this
if ((path == slowfolder && slowcache)
populateDB({
data: "",
path: path,
uplevel: uplevel
});
else
$.post('/db/?cmd=browse', { 'path': path, 'browsemode': GUI.browsemode }, function(data) {
populateDB({
data: data,
path: path,
uplevel: uplevel
});
}, 'json');
Finally inside the large function populateDB(options) find the line that starts with
$('#db-search-results').removeClass('hide')
below it you see this
}
for (i = 0; (row = data[i]); i += 1) {
content += parseResponse({
inputArr: row,
respType: 'db',
i: i,
inpath: path
});
}
Which should be changed into
}
if (path == slowfolder && slowcache)
content = slowcache
else
{
for (i = 0; (row = data[i]); i += 1) {
content += parseResponse({
inputArr: row,
respType: 'db',
i: i,
inpath: path
});
}
if (path == slowfolder && !slowcache)
slowcache = content
}
That was all the edits. Now save runeui.js then copy its contents into
http://gpbmike.github.io/refresh-sf/ , click "Javascript", put the minified code on the clipboard , open runeui.min.js and replace everything in it with the clipboard text. Save. That is it.
Edit: fixed a typo in the code.