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

changed file selector to <optgroup>

This commit is contained in:
Steven Hugg 2023-11-14 10:57:19 -06:00
parent a252ea65bd
commit 12957d7740

View File

@ -1220,13 +1220,13 @@ async function _downloadAllFilesZipFile(e) {
} }
function populateExamples(sel) { function populateExamples(sel) {
var files = {}; let files = {};
sel.append($("<option />").text("--------- Examples ---------").attr('disabled','true')); let optgroup = $("<optgroup />").attr('label','Examples').appendTo(sel);
for (var i=0; i<PRESETS.length; i++) { for (var i=0; i<PRESETS.length; i++) {
var preset = PRESETS[i]; var preset = PRESETS[i];
var name = preset.chapter ? (preset.chapter + ". " + preset.name) : preset.name; var name = preset.chapter ? (preset.chapter + ". " + preset.name) : preset.name;
var isCurrentPreset = preset.id==current_project.mainPath; var isCurrentPreset = preset.id==current_project.mainPath;
sel.append($("<option />").val(preset.id).text(name).attr('selected',isCurrentPreset?'selected':null)); optgroup.append($("<option />").val(preset.id).text(name).attr('selected',isCurrentPreset?'selected':null));
if (isCurrentPreset) current_preset = preset; if (isCurrentPreset) current_preset = preset;
files[preset.id] = name; files[preset.id] = name;
} }
@ -1238,12 +1238,11 @@ function populateRepos(sel) {
var n = 0; var n = 0;
var repos = getRepos(); var repos = getRepos();
if (repos) { if (repos) {
let optgroup = $("<optgroup />").attr('label','Repositories').appendTo(sel);
for (let repopath in repos) { for (let repopath in repos) {
var repo = repos[repopath]; var repo = repos[repopath];
if (repo.platform_id && getBasePlatform(repo.platform_id) == getBasePlatform(platform_id)) { if (repo.platform_id && getBasePlatform(repo.platform_id) == getBasePlatform(platform_id)) {
if (n++ == 0) optgroup.append($("<option />").val(repo.url).text(repo.url.substring(repo.url.indexOf('/'))));
sel.append($("<option />").text("------ Repositories ------").attr('disabled','true'));
sel.append($("<option />").val(repo.url).text(repo.url.substring(repo.url.indexOf('/'))));
} }
} }
} }
@ -1251,16 +1250,15 @@ function populateRepos(sel) {
} }
async function populateFiles(sel:JQuery, category:string, prefix:string, foundFiles:{}) { async function populateFiles(sel:JQuery, category:string, prefix:string, foundFiles:{}) {
var keys = await store.keys(); let keys = await store.keys();
var numFound = 0;
if (!keys) keys = []; if (!keys) keys = [];
let optgroup;
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
var key = keys[i]; let key = keys[i];
if (key.startsWith(prefix) && !foundFiles[key]) { if (key.startsWith(prefix) && !foundFiles[key]) {
if (numFound++ == 0) if (!optgroup) optgroup = $("<optgroup />").attr('label',category).appendTo(sel);
sel.append($("<option />").text("------- " + category + " -------").attr('disabled','true')); let name = key.substring(prefix.length);
var name = key.substring(prefix.length); optgroup.append($("<option />").val(key).text(name).attr('selected',(key==current_project.mainPath)?'selected':null));
sel.append($("<option />").val(key).text(name).attr('selected',(key==current_project.mainPath)?'selected':null));
} }
} }
} }