mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-23 06:32:11 +00:00
local files before presets in pulldown; hide selector before list is built
This commit is contained in:
parent
4750e3e876
commit
02ec5c7d04
@ -142,7 +142,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
|||||||
</ul>
|
</ul>
|
||||||
</span>
|
</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>
|
</select>
|
||||||
|
|
||||||
<img id="compile_spinner" src="images/spinner.gif" height="20em" style="visibility:hidden;margin-left:8px;margin-right:8px">
|
<img id="compile_spinner" src="images/spinner.gif" height="20em" style="visibility:hidden;margin-left:8px;margin-right:8px">
|
||||||
|
14
src/ui.ts
14
src/ui.ts
@ -598,10 +598,11 @@ function populateExamples(sel) {
|
|||||||
var name = preset.chapter ? (preset.chapter + ". " + preset.name) : preset.name;
|
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));
|
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[]) {
|
store.keys(function(err, keys : string[]) {
|
||||||
var foundSelected = false;
|
var foundSelected = false;
|
||||||
var numFound = 0;
|
var numFound = 0;
|
||||||
@ -616,21 +617,24 @@ function populateFiles(sel, category, prefix) {
|
|||||||
if (key == main_file_id) foundSelected = true;
|
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)) {
|
if (!foundSelected && main_file_id && main_file_id.startsWith(prefix)) {
|
||||||
var name = main_file_id.substring(prefix.length);
|
var name = main_file_id.substring(prefix.length);
|
||||||
var key = prefix + name;
|
var key = prefix + name;
|
||||||
sel.append($("<option />").val(key).text(name).attr('selected','true'));
|
sel.append($("<option />").val(key).text(name).attr('selected','true'));
|
||||||
}
|
}
|
||||||
|
if (callback) { callback(); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSelector() {
|
function updateSelector() {
|
||||||
var sel = $("#preset_select").empty();
|
var sel = $("#preset_select").empty();
|
||||||
if (platform_id != 'base_z80') { // TODO
|
populateFiles(sel, "Local Files", "local/", () => {
|
||||||
populateFiles(sel, "Local Files", "local/");
|
populateFiles(sel, "Shared", "shared/", () => {
|
||||||
populateFiles(sel, "Shared", "shared/");
|
|
||||||
}
|
|
||||||
populateExamples(sel);
|
populateExamples(sel);
|
||||||
|
sel.css('visibility','visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
// set click handlers
|
// set click handlers
|
||||||
sel.off('change').change(function(e) {
|
sel.off('change').change(function(e) {
|
||||||
reloadPresetNamed($(this).val().toString());
|
reloadPresetNamed($(this).val().toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user