<div style="display: flex; flex-wrap: wrap; white-space: pre-wrap; align-items: center; "><img height="20" width="20" style="border-radius:50%; margin-right: 4px;" decoding="async" src="https://avatars.githubusercontent.com/u/50826859?s=20&v=4" /><strong>hlfan</strong> left a comment <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6255#issuecomment-3121874355">(openstreetmap/openstreetmap-website#6255)</a></div>
<p dir="auto">I could see the whole thing, including handleExportSuccess and handleExportError, made into a higher-order function that's called like:</p>
<div class="highlight highlight-source-js" dir="auto"><pre class="notranslate"><span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">querySelector</span><span class="pl-kos">(</span><span class="pl-s">".export_form"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"turbo:submit-end"</span><span class="pl-kos">,</span> <span class="pl-en">getTurboDownload</span><span class="pl-kos">(</span><span class="pl-s">"map.osm"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Or a more modular version with a callback:</p>
<div class="highlight highlight-source-js" dir="auto"><pre class="notranslate"><span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">querySelector</span><span class="pl-kos">(</span><span class="pl-s">".export_form"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"turbo:submit-end"</span><span class="pl-kos">,</span> <span class="pl-en">getTurboBlobHandler</span><span class="pl-kos">(</span><span class="pl-s1">blob</span> <span class="pl-c1">=></span> <span class="pl-en">downloadBlob</span><span class="pl-kos">(</span><span class="pl-s1">blob</span><span class="pl-kos">,</span> <span class="pl-s">"map.osm"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">But in any case, I'd like to have <code class="notranslate">downloadBlob</code> separately to reuse it for the directions geojson download.</p>
<p dir="auto">As for where to store them, that's probably a question of whether there are any things to download outside of the index/map_layout pages; otherwise, I'd put it there and in the OSM namespace.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6255#issuecomment-3121874355">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMT2JVFJY6PROA6VVT3KOANJAVCNFSM6AAAAACCNPOCDKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCMRRHA3TIMZVGU">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLITI766FHYJSLOXIW33KOANJA5CNFSM6AAAAACCNPOCDKWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTV2CQC3G.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/6255/c3121874355</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/6255#issuecomment-3121874355",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/6255#issuecomment-3121874355",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>