1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-22 14:33:51 +00:00

local files before presets in pulldown; hide selector before list is built

This commit is contained in:
Steven Hugg 2019-05-03 18:44:59 -04:00
parent 4750e3e876
commit 02ec5c7d04
2 changed files with 11 additions and 7 deletions

View File

@ -142,7 +142,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
</ul>
</span>
<select id="preset_select" name="" title="Project Select" style="width:16em">
<select id="preset_select" name="" title="Project Select" style="width:16em;visibility:hidden">
</select>
<img id="compile_spinner" src="images/spinner.gif" height="20em" style="visibility:hidden;margin-left:8px;margin-right:8px">

View File

@ -598,10 +598,11 @@ function populateExamples(sel) {
var name = preset.chapter ? (preset.chapter + ". " + preset.name) : preset.name;
sel.append($("<option />").val(preset.id).text(name).attr('selected',(preset.id==main_file_id)?'selected':null));
}
// don't create new entry if example not found
});
}
function populateFiles(sel, category, prefix) {
function populateFiles(sel:JQuery, category:string, prefix:string, callback:() => void) {
store.keys(function(err, keys : string[]) {
var foundSelected = false;
var numFound = 0;
@ -616,21 +617,24 @@ function populateFiles(sel, category, prefix) {
if (key == main_file_id) foundSelected = true;
}
}
// create new entry if not found, but it matches our prefix
if (!foundSelected && main_file_id && main_file_id.startsWith(prefix)) {
var name = main_file_id.substring(prefix.length);
var key = prefix + name;
sel.append($("<option />").val(key).text(name).attr('selected','true'));
}
if (callback) { callback(); }
});
}
function updateSelector() {
var sel = $("#preset_select").empty();
if (platform_id != 'base_z80') { // TODO
populateFiles(sel, "Local Files", "local/");
populateFiles(sel, "Shared", "shared/");
}
populateExamples(sel);
populateFiles(sel, "Local Files", "local/", () => {
populateFiles(sel, "Shared", "shared/", () => {
populateExamples(sel);
sel.css('visibility','visible');
});
});
// set click handlers
sel.off('change').change(function(e) {
reloadPresetNamed($(this).val().toString());