I have a JQuery function which is supposed to automatically download a date stamped XML file from a URL from Monday of the previous week each week.
I've coded the following JQuery and HTML:
$(function() {
$('a[data-auto-download]').each(function(){
var $this = $(this);
setTimeout(function() {
window.location = $this.attr('href');
}, 2000);
});
});
The corresponding HTML which calls the function is the following:
<p>The download should start shortly. If it doesn't, click
<a data-auto-download href="https://download.microsoft.com/download/0/1/8/018E208D-54F8-44CD-AA26-CD7BC9524A8C/PublicIPs_20190513.xml">here</a>.</p>
Example of the full URL is:
https://download.microsoft.com/download/0/1/8/018E208D-54F8-44CD-AA26-CD7BC9524A8C/PublicIPs_20190513.xml
The following URL portion is always static each week:
https://download.microsoft.com/download/0/1/8/018E208D-54F8-44CD-AA26-CD7BC9524A8C/PublicIPs_
I would like to parametrize just the target filename portion of the URL to download each week (immediately following the underscore '_'), for example...
20190513.xml
… such that it always returns Monday of the previous week automatically.
How do I complete my JQuery function so that the XML date stamp always reflects the Monday of the previous week as of the current date?
For example, if we're the 21st of May 2019 (or 22nd, 23rd, or 24th) for that matter), I would like the filename to reflect **/PublicIPs_20190513.xml.
In another example, if we're now the 27th of May 2019, the file datestamp should now reflect the following:
PublicIPs_20190520.xml
Any guidance would be very much appreciated!
Thanks very much in advance, Shawn