fixed display bug when switching between professional and standard without saving in between

This commit is contained in:
Neythen Treloar 2022-02-24 17:05:37 +00:00
parent ff4aa4376f
commit e572fb5142
4 changed files with 15 additions and 25 deletions

View File

@ -89,7 +89,7 @@ def index():
if not professional:
currently_displaying = json.load(open('csv/display_settings.json', 'r'))[1]
not_displaying = [f for f in all_features if f not in currently_displaying]
not_displaying = [f for f in all_features if f not in currently_displaying[0]]
elif professional:
currently_displaying = json.load(open('csv/display_settings.json', 'r'))[1]
@ -143,7 +143,7 @@ def index():
def save_displaying(input_settings):
#print('save')
print('save_displaying_input:', input_settings)
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages']
@ -155,14 +155,17 @@ def save_displaying(input_settings):
display_settings = []
if professional:
input_settings = [[]]*2
input_settings[0] = [i for i in input_settings[0] if i in all_settings]
input_settings[1] = [i for i in input_settings[1] if i in all_settings]
s = "Professional" if professional else "Standard"
display_settings = [s] + [input_settings]
print(display_settings)
with open('csv/display_settings.json', 'w+') as f:
json.dump(list(display_settings), f)

View File

@ -877,14 +877,7 @@ function getListItems(list_el) {
return items;
}
// toggle professional
dispFormatButton.addEventListener("click", () => {
opt = getSelected(displayFormats);
fetch("/display_format", {
method: "PUT",
body: JSON.stringify(opt),
});
});
// gets which features are to be displayed
@ -896,7 +889,7 @@ function getDisplaying(){
let features = getListItems(list_el);
return features;
return [features];
} else if (opt.includes("Professional")) {
var top_list_el = document.getElementById("display-format");

View File

@ -2699,8 +2699,8 @@ class StockTicker():
userSettings = json.load(open('csv/display_settings.json'))
if 'Professional'==userSettings[0] and len(userSettings[1][0])>0 and len(userSettings[1][1])>0: #if professional display
self.scrollProfessionalAnimated(userSettings[1])
elif len(userSettings[1])>0 and 'Standard'==userSettings[0]:
self.scrollFunctionsAnimated(userSettings[1], animation = 'down')
elif len(userSettings[1][0])>0 and 'Standard'==userSettings[0]:
self.scrollFunctionsAnimated(userSettings[1][0], animation = 'down')
elif msg == 'b':
userSettings = json.load(open('csv/display_settings.json'))

View File

@ -150,7 +150,7 @@
<select id="inputDisplayFormat" class="form-select">
<option>Standard Scrolling</option>
<option>Professional two rows</option>
<option>Static display</option>
</select>
</div>
<div class="col-auto">
@ -212,17 +212,11 @@
class="display-features-list text-dark"
>
{%if not professional%}
{% for f in currently_displaying %}
<li>{{f}}</li>
{% endfor%}
{%endif%}
{%if professional%}
{% for f in currently_displaying[0] %}
<li>{{f}}</li>
{% endfor%}
{%endif%}
{% for f in currently_displaying[0] %}
<li>{{f}}</li>
{% endfor%}
</ul>