TGA Weekly - International Regulatory News generator
Auto-generates the HTML for the IRNews section of the internal Weekly
by timmah
HTML
<!--
Paste the International Regulatory News content from Word into Dreamweaver, then paste the resulting HTML into here with NO CHANGES
NOTES:
- This script assumes the text in Word was correctly formatted and styled prior to being pasted into Dreamweaver
- This script targets news items by looking at <p> tags featuring links as the first thing in them.
This may result in unintended links being targeted
- This script cleans HTML, it doesn't apply correct title tags to links etc.
Use the TGA code cleaner for that or do it manually.
-->
<p><a href="http://news.gc.ca/web/article-en.do?nid=1127659&tp=1">Statement from Health Canada on the Testing of Marijuana</a></p>
<p><strong>Health Canada, 21 September 2106</strong></p>
<p>Health Canada's position on the risks of obtaining cannabis from dispensaries has been consistent: these facilities are unlicensed by the federal government, illegally supplied, and sell product that may be contaminated or otherwise unsafe.</p>
<p><a href="http://www.ema.europa.eu/ema/index.jsp?curl=pages/news_and_events/news/2016/09/news_detail_002609.jsp&mid=WC0b01ac058004d5c1">EU-US collaboration to boost medicine development for rare diseases</a></p>
<p><strong>EMA, 26 September 2016 </strong></p>
<p>The European Medicines Agency (EMA) and the <a href="http://www.ema.europa.eu/ema/index.jsp?curl=pages/partners_and_networks/general/general_content_000651.jsp&mid=WC0b01ac0580a51ff3">United States Food and Drug Administration</a> (FDA) have set up a
new '<a href="http://www.ema.europa.eu/ema/index.jsp?curl=pages/partners_and_networks/general/general_content_000655.jsp&mid=WC0b01ac0580953d98">cluster</a>' on rare diseases to share experiences and best practices on each other's regulatory approach
to the development of medicines for these diseases.</p>
<p><a href="http://www.who.int/mediacentre/news/releases/2016/commitment-antimicrobial-resistance/en/">At UN, global leaders commit to act on antimicrobial...
JavaScript
/* HOW TO USE
This script quickly corrects the HTML markup of International Regulatory News for pasting into theTGA Weekly:
http://intranet.tga.gov.au/news-events/news/tga-weekly/Pages/default.aspx
Paste in your Dreamweaver HTML in the window above, then hit 'Run'
*/
// Add an output wrapper to populate with the results
$('body').prepend('<div id="output"></div>');
var $output = $('#output'),
$newList;
// Wrap the original contents to target later
$('p').wrapAll('<div id="original"></div>');
var $orig = $('#original');
// First, crawlour source HTML for for the elements we want to manipulate.
// There aren't many classes, wrappers or IDs, so we need to get creative.
$orig.children('p').each(function() {
/*
The variable '$result':
- Grabs the contents of each 'p' tag, then
- Slices the HTML inside into an Array containing the HTML's first 2 characters, then
- Converts that Array into a String, so it can be more easily searched
*/
var $item = $(this),
$link = $item.html().slice(0, 2).toString();
// Check if the first thing appearing in the 'p' tag's HTML is a link, '0' being the position of the first item
if ($link.indexOf('<a') === 0) {
// If the tag starts with a link, add classes to the link and following <p> tag
$item.addClass('title');
$('.title').next('p').addClass('date');
}
});
// For each title link, add a targetable element immediately before it
$('.title').each(function() {
$(this).before('<span class="remove">');
});
// For each targetable element (span.remove), select all elements until it reaches another or runs out of things to select
$('span.remove').each(function() {
// This selects all elements from one span.remove till the next one, not including the selector elements themselves
$(this).nextUntil('span.remove')
// Now we can wrap each group of elements in a single HTML wrapper for easy targeting
.wrapAll('<div...