Keep the filters, switches and saved stars in step, and trim the headline
"Clear search and filters" left the longest-length list on a step: the script rebuilds the length options and did not mark "Any" as the default, which is what a form's reset returns to. The same kind of fault elsewhere: - A length in the address in the other unit (?max=200km for a reader who uses miles) was dropped. It now takes the nearest step, and the address is rewritten on load to say what the controls show. - After Back or a reload a browser may put a form's old values back after the script has run, or show an old copy of the page from its cache. The theme and units switches, the filters, the sort and the saved stars are set again when the page is shown. - A theme or units change now reaches other open tabs. - The popup on the home page's map follows the units and closes when the filters leave its trail out. - The Saved page drops ?t= from the address when the list in it is the visitor's own. The home page's headline no longer says "to compare and download", and its subtitle no longer counts the GPX files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
46dc81523c
commit
601235d2cb
3 files changed
+120
-25
No files matched your search
@@ -211,6 +211,20 @@ class MissingValuesTest(unittest.TestCase):
|
||||
self.assertIn("if (s.month && words(d.months).indexOf(s.month) === -1) return false;", js)
|
||||
self.assertIn("note.hidden = !on[note.dataset.missing]", js)
|
||||
|
||||
def test_clearing_returns_the_lengths_to_any(self):
|
||||
# A form's reset picks the option marked as default, or else the first one.
|
||||
# "Any" is the last option of the longest-length list, so both the page and
|
||||
# the script (which rebuilds the lists in the reader's units) must mark it;
|
||||
# in the shortest-length list it is first.
|
||||
form = home.finder_form(self.recs(3, 8))
|
||||
longest = re.search(r'<select[^>]* id="max"[^>]*>(.*?)</select>', form, re.S).group(1)
|
||||
self.assertEqual(re.findall(r'<option value="([^"]*)" selected', longest), [""])
|
||||
shortest = re.search(r'<select[^>]* id="min"[^>]*>(.*?)</select>', form, re.S).group(1)
|
||||
self.assertTrue(shortest.startswith('<option value="">Any</option>'))
|
||||
with open(os.path.join(WEB, "assets", "app.js"), encoding="utf-8") as f:
|
||||
js = f.read()
|
||||
self.assertIn("if (value === '') o.defaultSelected = true;", js)
|
||||
|
||||
|
||||
# Words that must not appear on a browsing page (home, places, lists, Routes, and a
|
||||
# trail page above "About this data"). Record text can say what it likes; these are
|
||||
|
||||
Reference in new issue
Block a user