Autogenerate 'On this page' menus
by timmah
HTML
<p>The Medicine Shortages Information Initiative provides information about prescription <a href="/node/4024#general">medicine shortages</a> in Australia. This information is provided to assist health professionals and consumers when there is a temporary or permanent disruption (discontinuation) to the supply of a medicine in Australia.</p>
<p>The medicine shortages information on this website is mostly based on information provided voluntarily to the TGA by <a href="/node/3379#sponsor">sponsors</a>. The information provided refers to the supply of prescription medicines to the overall Australian market. This means that stock of a particular medicine may still be available at your pharmacy to fill your prescription.</p>
<p>If you are having difficulty obtaining a medicine that has been prescribed to you, talk to your doctor or pharmacist.</p>
<p class="ie7-below keywords callout">This service does not support Internet Explorer 7 and below.</p>
<p class="spaced"> <span class="button" id="button-msi"><a href="http://apps.tga.gov.au/prod/MSI/search/" title="link to the TGA apps website">Search Medicine Shortages Information (MSI)</a></span></p>
<h2 id="alternative-supply">Alternative supply</h2>
<p>In response to certain medicine shortages, a sponsor can apply to the TGA for permission to supply an unapproved medicine under section 19A of the <em>Therapeutic Goods Act 1989 </em>(the Act).</p>
<h2 id="alerts">Alerts</h2>
<p>In some instances, the TGA will publish additional information about specific medicines shortages, in the form of alerts, in the interest of public health. These alerts are updated when new information becomes available, including when the shortage has been resolved. You can <a href="/node/4468">subscribe to automatically receive notifications</a> when new alerts and updates are published.</p>
<p>Where a sponsor has not provided a medicine shortage notification, the TGA still has the power to publish information such information.</p>
<h3...
JavaScript
// Autogenerate 'On this page' pagemenus
// Just set $hLevel to the heading level you want to build your menu with and hit 'Run'
var $pageMenu = '<p class="pagemenu"><strong>On this page:</strong> </p>',
$items = [],
$hLevel = 'h2';
$($hLevel).each(function() {
var $this = $(this),
$text = $this.text(),
$id = $this.attr('id'),
$template = '<a href=#' + $id + '>' + $text + '</a> | ';
$items.push($template);
});
// TODO - replace the pipe character in the last array element.
//console.log(($items[$items.length - 1]));
//$items[$items.length - 1].replace(/|, '');
//console.log(($items[$items.length - 1]));
$($hLevel + ':first').before($pageMenu);
$('.pagemenu').append($items);