[KiRi] Avoid including data in the HTML that will be replaced

The JS changes various things at start-up, in particular:
- List of layers
- List of sheets
This commit is contained in:
Salvador E. Tropea 2023-12-01 09:53:17 -03:00
parent a291a8fde1
commit 4fb3870d12
2 changed files with 22 additions and 12 deletions

View File

@ -222,10 +222,10 @@ class KiRiOptions(VariantOptions):
f.write(ln+'\n')
if ln.endswith('<!-- FILL_COMMITS_HERE -->'):
self.create_commits(f, commits)
elif ln.endswith('<!-- FILL_PAGES_HERE -->'):
self.create_pages(f)
elif ln.endswith('<!-- FILL_LAYERS_HERE -->'):
self.create_layers(f)
# elif ln.endswith('<!-- FILL_PAGES_HERE -->'):
# self.create_pages(f)
# elif ln.endswith('<!-- FILL_LAYERS_HERE -->'):
# self.create_layers(f)
def create_commits(self, f, commits):
template = self.load_html_template('commits', 8)

View File

@ -725,7 +725,7 @@ function update_sheets_list(commit1, commit2) {
selected_sheet = pages[selected_page].id;
}
catch(err) {
selected_page = "";
selected_sheet = "";
console.log("There isn't a sheet selected");
}
@ -807,11 +807,13 @@ function update_sheets_list(commit1, commit2) {
}
else {
// If old selection does not exist, maybe the list is now shorter, then select the last item...
pages[optionLabels.length-1].checked = true;
if (optionLabels.length) {
pages[optionLabels.length-1].checked = true;
}
}
// If nothing is selected still, select the first item
if (!pages.filter(':checked').length) {
if (pages.length && !pages.filter(':checked').length) {
pages[0].checked = true;
}
}
@ -937,7 +939,9 @@ function update_layers_list(commit1, commit2, selected_layer_idx, selected_layer
}
else {
// If old selection does not exist, maybe the list is now shorter, then select the last item...
layers[optionLabels.length-1].checked = true;
if (optionLabels.length) {
layers[optionLabels.length-1].checked = true;
}
}
// restore previously selected index
@ -975,9 +979,15 @@ function update_layer() {
layer_id = layers[selected_layer].id.split("-")[1];
console.log(">>>> [label_id_ELSE] = ", layer_id);
} catch (error) {
console.log("[PCB] Images may not exist and Kicad layout may be missing.");
show_sch();
return;
if (layers.length == 0) {
selected_layer = -1
layer_id = ""
}
else {
console.log("[PCB] Images may not exist and Kicad layout may be missing.");
show_sch();
return;
}
}
}
}
@ -1012,7 +1022,7 @@ function update_layer() {
removeEmbed();
lastEmbed = createNewEmbed(image_path_timestamp_1, image_path_timestamp_2);
}
else
else if (layer_id != "")
{
document.getElementById("diff-xlink-1").href.baseVal = image_path_timestamp_1;
document.getElementById("diff-xlink-2").href.baseVal = image_path_timestamp_2;