/* * [PSAType.java] * * Summary: generates public service ads for the Footer. This is not a macro. It is a helper for PSA. * * Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.8 2009-02-06 include go package in ZIP bundle. * Foot decides if do nonmil or PSA ad, and PSA decides which ad. */ package com.mindprod.htmlmacros.support; import com.mindprod.common18.BigDate; import com.mindprod.common18.EIO; import com.mindprod.fastcat.FastCat; import com.mindprod.htmlmacros.macro.Global; import com.mindprod.htmlmacros.macro.Include; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import static com.mindprod.htmlmacros.macro.Global.configuration; import static java.lang.System.*; /** * generates public service ads for the Footer. This is not a macro. It is a helper for PSA. *

* Key methods are adForPSA and footerQuoteOfTheDay. * PSA class decides if we do non-mil, quote or PSA ad. * * @author Roedy Green, Canadian Mind Products * @version 1.8 2009-02-06 include go package in ZIP bundle. * @see com.mindprod.htmlmacros.support.PSA * @see QuoteAggregate * @since 2009 */ public enum PSAType { /* How random ad/quote selection works: There are weighted enums for various charities. Non-Mil and Footer Quote are treated as just another charity. A slot in the separate footer file is reserved for one of these three randomly selected possibilities. We use a random number to make a weighted selection. Then within that charity, we randomly select an ad. When we are doing a footer quote, we select an aggregate, based on what part of the website this page is in. Then we randomly select a weighted Flock within the aggregate. Then we select a random quote from that file. The weighting is done by duplicating offsets to quotes all stored in a common file, not with a separate array of weights as is done for the higher level weighting. For quotes in the middle of page, the quote macro selects the Aggregate. From there it works the same. non-mil weight:5 quote weight:40 PSA weight:41 The google ad is separate and goes above the slot for quote/PSA/Non-mil */ NONMIL( PSA.NONMIL_WEIGHT, 1 ) { /** * get html for a non-military * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { return "The information on this page is for non-military use only.\n" + "
" + "Military use includes use by defence contractors."; } }, FOOTER_QUOTE( PSA.FOOTER_QUOTE_WEIGHT, 0 ) { /** * get html for a CMP ad, actually just a random quotation * * @param fileBeingDistributed page where ad will be embedded * @param footerFileBeingDistributed web page where iframe ad will go * @param aggregate which qouote aggregate to use to generate a random quote. * @param override overide normal random choice * * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFileBeingDistributed, final QuoteAggregate aggregate, final int override ) { // for notes on how overall quote generating process works, see Quotation.expandNoRef. final String quotationText = aggregate.getRandomQuotationForFile( Global.configuration .getFooterRotateIntervalInMillis( fileBeingDistributed ), fileBeingDistributed ); // expanded any macro embedded in the quotation. if ( quotationText.contains( ""; case 2: return Tools.completeLink( "http://www.amnesty.ca/our-work/issues/torture", BuildImage.buildImgTag( "psa/amnesty/torturewheel.png", "Stop Torture in the Philippines", null, "rec", footerFile ), "rec", "_blank", footerFile ) + "\n

This roulette wheel is used to pick a list of torture techniques meted out to prisoners in the Philippines.

"; case 3: return Tools.completeLink( "https://twitter.com/AmnestyNow/status/475013217853267968/photo/1", BuildImage.buildImgTag( "psa/amnesty/girls.jpg", "Stop Boko Haram’s kidnapping girls", null, "rec", footerFile ), "rec", "_blank", footerFile ) + "\n

Stop Boko Haram’s kidnapping girls.

"; default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, CLIMATECRISIS( 1, 2 ) { String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "http://www.takepart.com/ait10/", BuildImage.buildImgTag( "psa/climatecrisis/inconvenienttruth.png", "An Inconvenient Truth", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "http://www.takepart.com/ait10/", BuildImage.buildImgTag( "psa/climatecrisis/difficult.png", "An Inconvenient Truth", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, CLIMATE_HOT_MAP( 1, 1 ) { /** * get html for ClimateHotMap public service ad * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { return Tools.completeLink( "http://www.climatehotmap.org/", BuildImage.buildImgTag( "psa/climatehotmap/map.png", "Global Warming: Early Warning Signs", null, "rec", footerFile ), "rec", "_blank", footerFile ); } }, DAVIDSUZUKI( 5, 16 ) { /** * get html for a DavidSuzuki.org public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "http://www.davidsuzuki.org/", BuildImage.buildImgTag( "psa/davidsuzuki/davidsuzukibanner.png", "Visit David Suzuki", null, "rec", footerFile ), "rec", "_blank", footerFile ); // this is not just weighting. These are 8 separate ads, all linking to the same place. case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: // any of 8 possible images return Tools.completeLink( "http://www.davidsuzuki.org/what-you-can-do/nature-challenge/", BuildImage.buildImgTag( "psa/davidsuzuki/c" + choice + ".jpg", "Take the David Suzuki nature challenge.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 9: return Tools.completeLink( "http://www.davidsuzuki.org/issues/oceans/", BuildImage.buildImgTag( "psa/davidsuzuki/c" + choice + ".jpg", "Sustainable seafood", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 10: return Tools.completeLink( "http://getbackoutside.ca", BuildImage.buildImgTag( "psa/davidsuzuki/outside.jpg", "Get Back Outside", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 11: case 12: case 13: case 14: case 15: /* extra weight */ return Tools.completeLink( "http://bluedot.ca", BuildImage.buildImgTag( "psa/davidsuzuki/bluedot.jpg", "Blue Dot Tour", null, "rec", footerFile ), "rec", "_blank", footerFile ) + "

Blue Dot Canadian concert tour for the environment

"; default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, DAWKINS( 1 /* weight */, 2/* variants */ ) { /** * get html for a Richard Dawkins ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "https://richarddawkins.net/", BuildImage.buildImgTag( "psa/dawkins/rdf.jpg", "Richard Dawkins Foundation", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "https://richarddawkins.net/store/", BuildImage.buildImgTag( "psa/dawkins/earrings.jpg", "earrings", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, EARTHDAY( new BigDate( Global.THIS_CALENDAR_YEAR, 4, 22 ).isCelebrating( 21, 3 ) ? 6 : 1 /* weight */, 2 /* variants */ ) /* set weight to 6, 3 weeks prior to next earth day 2014-04-22, otherwise 1, back to normal 3 days later. */ { /** * get html for an earth hour service ad. * Flash countdown to next Earth Day/Hour. * * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return "
\n" + "

Together We’ve Reached

\n" + "" + "2,023,246,086\n" + "

Acts of Green

\n" + "

Help us reach 3 billion

\n" + "
\n"; case 1: return Tools.completeLink( "http://www.earthday.org/", BuildImage.buildImgTag( "psa/earthday/carbon.png", "Earth day", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, EARTHHOUR( new BigDate( Global.THIS_CALENDAR_YEAR, 3, 28 ).isCelebrating( 21, 3 ) ? 6 : 1, 6 /* count of choices */ ) /* set weight to 6, 3 weeks prior to next earth hour 2015-03-28, otherwise 1 */ { /** * get html for an earth hour service ad. * Flash countdown to next Earth Day/Hour. * @param footerFile web page where banner will go * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final String earthHourURL = "https://www.earthhour.org?ref=http://mindprod.com"; final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return youTubeflashAd( footerFile, "Earth Hour", "sFIL0l-e1j4", /* generic */ 560, 315 ); case 1: case 2: case 3: case 4: return youTubeflashAd( footerFile, "Earth Hour", "XxIMib4e8f8", /* 2015 */ 560, 315 ); case 5: return Tools.completeLink( earthHourURL, /* genereric */ BuildImage.buildImgTag( "psa/earthhour/banner.jpg", "Earth hour", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, FONKOZE( 1, 2 ) { /** * get html for Fonkoze public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "http://www.fonkoze.org/", BuildImage.buildImgTag( "psa/fonkoze/logo.png", "Fonkoze", null, "rec", footerFile ), "rec", "_blank", footerFile ) + "
" + "I spent an afternoon with Kathleen Felix the head of " + "Fonkoze.\n" + "They have produced amazing results\n" + "with very little money for the poor of Haiti, with education, " + "aid and microcredit. Fonkoze are\n" + "practical and grass roots. If you want to help Haiti, " + "this is probably the most efficient way to do it.\n"; case 1: return Tools.completeLink( "http://www.fonkoze.org/", BuildImage.buildImgTag( "psa/fonkoze/sendmoney.jpg", "Fonkoze", null, "rec", footerFile ), "rec", "_blank", footerFile ) + "
" + "In addition to efficiently helping the poor of Haiti with education, " + "and microcredit,\n" + "Fonkoze\n" + "offers the cheapest way to wire money to individuals in Haiti.\n"; default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, FORESTETHICS( 2, 3 ) { /** * get html for a Forest Ethics public service ad * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "http://donotmail.org/", BuildImage.buildImgTag( "psa/forestethics/junkmail.png", "Fight junk mail.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "https://donate.stand.earth/checkout/donation?eid=52890", BuildImage.buildImgTag( "psa/forestethics/sfi.png", "SFI Sustainable Forestry Initiative really means Selling False Information", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "https://donate.stand.earth/checkout/donation?eid=52890", BuildImage.buildImgTag( "psa/forestethics/tar.png", "Oppose uncontrolled tar sands development.", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ForestEthics ad number" ); } } }, GREENPARTY( 1, 5 ) { /** * get html for a Green Party public service ad * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice overide random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "https://gpc-gear.myshopify.com/collections/gpc-gear/products/gpc-eco-mug", BuildImage.buildImgTag( "psa/greenparty/mug.png", "I love clean energy button", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "https://gpc-gear.myshopify.com/collections/frontpage/products/young-greens-sustainable-t-shirt", BuildImage.buildImgTag( "psa/greenparty/tee.jpg", "Get your Green Party electioneering gear", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "https://www.greenparty.ca/en/blogs/7/2013-06-28/climate-jeopardy", BuildImage.buildImgTag( "psa/greenparty/keepkyoto.png", "Keep Kyoto", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 3: return Tools.completeLink( "https://gpc-gear.myshopify.com/collections/gpc-gear/products/green-message-buttons-2-25-message-vert-boutons-2-26", BuildImage.buildImgTag( "psa/greenparty/localfood.png", "I love local food button", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 4: return Tools.completeLink( "https://gpc-gear.myshopify.com/collections/gpc-gear/products/green-message-buttons-2-25-message-vert-boutons-2-26", BuildImage.buildImgTag( "psa/greenparty/cleanenergy.png", "I love clean energy button", null, "rec", footerFile ), "rec", "_blank", footerFile ); /* case 5: return Tools.completeLink( "https://www.greenparty.ca/en", BuildImage.buildImgTag( "psa/greenparty/gplogo.png", "Vote Green in the Canadian federal election.", null, "rec", footerFile ), "rec", "_blank", footerFile ); */ default: throw new IllegalArgumentException( "program bug: invalid Green Party ad number" ); } } }, GREENPEACE( 4, 35 ) { /** * get html for a Greenpeace public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { // final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: // polar bear 430x286 return Tools.completeLink( "http://www.greenpeace.org/usa/multimedia/", BuildImage.buildImgTag( "psa/greenpeace/polarbear.jpg", "A polar bear in drifting and unconsolidated sea ice in Kane Basin, " + "off Cape Clay, northern Greenland.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: // climate shame return Tools.completeLink( "http://www.greenpeace.org/canada/en/recent/climate_chaos_copenhagen/", BuildImage.buildImgTag( "psa/greenpeace/climateshame.jpg", "Historic opportunity to avert climate chaos squandered in Doha.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: // Anthony Hopkins for the whales return youTubeflashAd( footerFile, "Greenpeace : Sir Anthony Hopkins for the whales", "VwSZn_27NVw", 620, 501 ); case 3: // Dove Advert return youTubeflashAd( footerFile, "Greenpeace : Dove Advert", "odI7pQFyjso", 620, 501 ); case 4: // Greenpeace pollution revolution animated gif. 468x60 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/animatedpollutionrevolution.gif", "Visit Greenpeace and help save the climate.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 5: // Greenpeace oceans your choice animated gif. 468x60 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/animatedocean.gif", "Visit Greenpeace to help save your seas.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 6: // Greenpeace last tree is gone animated gif. 468x60 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/animatedlasttree.gif", "Visit Greenpeace to help prevent environmental destruction.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 7: // Greenpeace why just surf when your can make waves? animated gif. 468x60 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/animatedsurf.gif", "Join the Greenpeace cyberactivist community and start making waves.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 8: // Greenpeace plain 148x78 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/greenpeaceplain.png", "Visit Greenpeace to find out what you can do to protect the environment.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 9: // Greenpeace International rainbow 234 x 60 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/buttonrainbow.png", "Greenpeace.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 10: // Greenpeace windmill energy [r]evolution rainbow 125 x 125 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/windmill.png", "Greenpeace energy [r]evolution.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 11: // tar sands 300x300 return Tools.completeLink( "http://www.greenpeace" + ".org/canada/en/recent/greenpeace-welcomes-president-obama/social-media/", BuildImage.buildImgTag( "psa/greenpeace/tarsands.jpg", "Climate leaders don't buy tar sands.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 12: // tar sands2 522x200 return Tools.completeLink( "http://www.greenpeace.org/canada/en/recent/stopstarsands3_action/", BuildImage.buildImgTag( "psa/greenpeace/tarsands2.jpg", "Tar sands climate crime.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 13: // there is no Petropolis 408x110 return Tools.completeLink( "http://www.greenpeace.org/canada/en/recent/petropolis_film_festival/", BuildImage.buildImgTag( "psa/greenpeace/petropolis.jpg", "Petropolis", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 14: // there is no Canadian Climate leadership 408x110 return Tools.completeLink( "http://www.greenpeace.org/canada/en/recent/greenpeace-demands-action-on-t/", BuildImage.buildImgTag( "psa/greenpeace/canadaclimateleadership.jpg", "Canadian climate leadership", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 15: // Xerox 408x110 return Tools.completeLink( "http://www.greenpeace.org/canada/en/recent/xerox-stop-destroying/", BuildImage.buildImgTag( "psa/greenpeace/xerox.jpg", "Xerox destroying boreal forest", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 16: // energy revolution 120x160 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/animatedenergysquare.gif", "Join the energy revolution - Greenpeace", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 17: // energy revolution 150x60 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/animatedenergybanner.gif", "Join the energy revolution - Greenpeace", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 18: // energy revolution 150x60 return Tools.completeLink( "http://www.greenpeace.org/international/en/", BuildImage.buildImgTag( "psa/greenpeace/louderthanwords.jpg", "Join the Greenpeace cyberactivist community and start making waves.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 19: // there is no cod 250x250 return Tools.completeLink( "http://www.greenpeace.org/canada/en/recent/probably-no-cod/", BuildImage.buildImgTag( "psa/greenpeace/cod.jpg", "There is no cod.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 20: // Islands going under ny Hopkins for the whales return youTubeflashAd( footerFile, "Greenpeace : Islands Going Under", "fTlLDGWfAPs", 620, 501 ); case 21: // Electronic: in the hands of a few return youTubeflashAd( footerFile, "Greenpeace : Electronic: in the hands of a few", "9-O2iIHXyn0", 620, 501 ); case 22: // Hundreds strip naked on glacier in global warming protest return youTubeflashAd( footerFile, "Greenpeace : Hundreds strip naked on glacier in global warming protest", "0RVp8Q6H9e0", 620, 501 ); case 23: // Grow Up, Cool Down return youTubeflashAd( footerFile, "Greenpeace : Grow Up, Cool Down", "E-3YPBfO2Ys", 620, 501 ); case 24: // The Convenient Solution return youTubeflashAd( footerFile, "Greenpeace : The Convenient Solution", "xfzVQwW_8Jk", 620, 501 ); case 25: // Man & Whale return youTubeflashAd( footerFile, "Greenpeace : Man & Whale", "ozx1fzzuXdE", 620, 501 ); case 26: // The Wind return youTubeflashAd( footerFile, "Greenpeace : The Wind", "5M9XjL2Vk0I", 620, 501 ); case 27: // Dirty laundry - Background on clothing manufacturing pollution return youTubeflashAd( footerFile, "Greenpeace : Dirty laundry - Background on clothing manufacturing pollution", "Zkou6xAb6Rw", 620, 501 ); case 28: // Kumi Naidoo leads from the front in dramatic Arctic oil rig action return youTubeflashAd( footerFile, "Greenpeace : Kumi Naidoo leads from the front in dramatic Arctic oil rig action", "psoEt4rzHbs", 620, 501 ); case 29: // Celebrating the soya moratorium return youTubeflashAd( footerFile, "Greenpeace : Celebrating the soya moratorium", "Jd_d95WDfXQ", 620, 501 ); case 30: // tuna helipcopter return youTubeflashAd( footerFile, "Greenpeace : Helicopter Pilot Blows Whistle On Tuna Industry", "6JlKwoUtMk4", 551, 354 ); case 31: // Fashion industry dirty little secret return youTubeflashAd( footerFile, "Greenpeace : Fashion industry dirty little secret", "-UpFEuyNVJ4", 620, 501 ); case 32: // The ship that sailed herself return youTubeflashAd( footerFile, "Greenpeace : The ship that sailed herself", "YMPHvMwtOqc", 620, 501 ); case 33: // golden rice revolution 300x199 return Tools.completeLink( "http://www.greenpeace.org/canada/en/" + "Blog/golden-rice-the-true-story/blog/42223/", BuildImage.buildImgTag( "psa/greenpeace/goldenrice.jpg", "Untested GMO rice - Greenpeace", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 34: // tuna 188x166 return Tools.completeLink( "http://www.greenpeace.org/canada/en/" + "campaigns/ocean/Tuna/Get-involved/Back-to-school/", BuildImage.buildImgTag( "psa/greenpeace/tuna.jpg", "Learn about the tuna you eat - Greenpeace", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, HUMANIST( 1, 2 ) { /** * get html for a American Humanist public service ad * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "https://foundationbeyondbelief.org/hdrdrive", BuildImage.buildImgTag( "psa/humanist/humanistcharities.jpg", "Funds collected used to support unambiguously Humanist relief efforts.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "https://americanhumanist.org/", BuildImage.buildImgTag( "psa/humanist/humanist.png", "American Humanist Association.", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid American Humanist ad number" ); } } }, KIND( 1, 1 ) { /** * get html for a K.I.N.D public service ad * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { return Tools.completeLink( "http://www.msnbc.com/kind-fund", BuildImage.buildImgTag( "psa/kind/desks.jpg", "Visit MSNBC and support Lawrence O’Donnell’s campaign to provide " + "school desks to Malawi.", null, "rec", footerFile ), "rec", "_blank", footerFile ); } }, MSF( 1, 1 ) { /** * get html for a Doctors without Borders MEDECINS SANS FRONTIERES public service ad * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice override normal random choice * @return html to display banner and link * */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { return Tools.completeLink( "http://www.msf.ca/", BuildImage.buildImgTag( "psa/msf/msf.png", "Visit msf.ca and support a doctors in the third world.", null, "rec", footerFile ), "rec", "_blank", footerFile ); } }, NATURE_CONSERVANCY( 2, 9 ) { /** * get html for a Nature Conservance of Canada public service ad * @param * fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/british-columbia/", BuildImage.buildImgTag( "psa/natureconservancy/bc.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/alberta/", BuildImage.buildImgTag( "psa/natureconservancy/alberta.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/saskatchewan/", BuildImage.buildImgTag( "psa/natureconservancy/saskatchewan.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 3: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/manitoba/", BuildImage.buildImgTag( "psa/natureconservancy/manitoba.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 4: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/ontario/", BuildImage.buildImgTag( "psa/natureconservancy/ontario.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 5: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/quebec/", BuildImage.buildImgTag( "psa/natureconservancy/quebec.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 6: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/new-brunswick/", BuildImage.buildImgTag( "psa/natureconservancy/newbrunswick.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 7: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/prince-edward-island/", BuildImage.buildImgTag( "psa/natureconservancy/pei.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 8: return Tools.completeLink( "http://www.natureconservancy.ca/en/where-we-work/newfoundland-and-labrador/", BuildImage.buildImgTag( "psa/natureconservancy/nl.jpg", "Visit the Nature Conservancy of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid Nature Conservancy ad number" ); } } }, NDP( 2, 4 ) { /** * get html for a ndp.ca public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "http://www.ndp.ca", BuildImage.buildImgTag( "psa/ndp/leaves.png", "Visit the New Democratic Party of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "http://www.ndp.ca", BuildImage.buildImgTag( "psa/ndp/fairness.jpg", "Visit the New Democratic Party of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "https://secure.ndp.ca/index_e.php", BuildImage.buildImgTag( "psa/ndp/donatemonthly.jpg", "Become a monthly donor to the New Democratic Party of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ) + "
" + "Become a monthly donor to the New Democratic Party of Canada"; case 3: return Tools.completeLink( "https://secure.ndp.ca/index_e.php?payment_option=onetime", BuildImage.buildImgTag( "psa/ndp/donatenow.jpg", "Donate now to the New Democratic Party of Canada", null, "rec", footerFile ), "rec", "_blank", footerFile ) + "
" + "Donate now to the New Democratic Party of Canada"; default: throw new IllegalArgumentException( "program bug: invalid NDP ad number" ); } } }, OXFAM( 2, 3 ) { /** * get html for a Oxfam public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "https://www.oxfam.ca/our-work/campaigns/arms-trade-treaty", BuildImage.buildImgTag( "psa/oxfam/arms.jpg", "Help set up an arms trade treaty", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "https://www.oxfam.ca/get-involved/campaigns/even-it-up", BuildImage.buildImgTag( "psa/oxfam/equality.jpg", "Help African women deal with sexual equality.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "https://www.oxfam.org/en/east-africa-food-crisis-our-response", BuildImage.buildImgTag( "psa/oxfam/eastafrica.jpg", "Help the massive East African famine.", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid Oxfam ad number" ); } } }, PETA( 3, 19 ) { /** * get html for a PETA public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { // banners from http://www.peta.org/actioncenter/webbanners.asp // http://www.peta.org/actioncenter/bannercodes-com.asp final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/", BuildImage.buildImgTag( "psa/peta/bannerhelpinganimals.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/", BuildImage.buildImgTag( "psa/peta/bannerpuppies.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "https://features.peta.org/cruelty-free-company-search/index.aspx", BuildImage.buildImgTag( "psa/peta/cc-purchase_banner.gif", "Visit caringconsumer", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 3: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/", BuildImage.buildImgTag( "psa/peta/chaineddog.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 4: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/", BuildImage.buildImgTag( "psa/peta/cold.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 5: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/overpopulation/", BuildImage.buildImgTag( "psa/peta/fixcats.gif", "Visit fixcats", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 6: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/", BuildImage.buildImgTag( "psa/peta/goodboy_webbanner.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 7: return Tools.completeLink( "https://features.peta.org/how-to-go-vegan/", BuildImage.buildImgTag( "psa/peta/goveg1.gif", "Visit goVeg", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 8: return Tools.completeLink( "https://features.peta.org/how-to-go-vegan/", BuildImage.buildImgTag( "psa/peta/goveg2.gif", "Visit goVeg", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 9: return Tools.completeLink( "https://features.peta.org/how-to-go-vegan/", BuildImage.buildImgTag( "psa/peta/goveg3.gif", "Visit goVeg", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 10: return Tools.completeLink( "https://www.peta2.com/", BuildImage.buildImgTag( "psa/peta/hellbanner.gif", "Visit peta2", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 11: return Tools.completeLink( "https://www.peta.org/features/", BuildImage.buildImgTag( "psa/peta/cruelduck.jpg", "Kosher is no less cruel than other factory farming.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 12: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/", BuildImage.buildImgTag( "psa/peta/neuteriscuter.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 13: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/", BuildImage.buildImgTag( "psa/peta/newdisaster.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 14: return Tools.completeLink( "https://www.peta.org/teachkind/", BuildImage.buildImgTag( "psa/peta/teachkindbanner_ani.gif", "Visit teachkind", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 15: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/human-animal-abuse/", BuildImage.buildImgTag( "psa/peta/violenttoanimals.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 16: return Tools.completeLink( "https://www.peta.org/issues/companion-animal-issues/cruel-practices/", BuildImage.buildImgTag( "psa/peta/lifesentence.gif", "Visit helpinganimals", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 17: return Tools.completeLink( "http://www.kentuckyfriedcruelty.com/", BuildImage.buildImgTag( "psa/peta/kfc-banner1.gif", "Visit kentuckyfriedcruelty", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 18: return Tools.completeLink( "http://www.meat.org", BuildImage.buildImgTag( "psa/peta/mymwarning_banner.gif", "Meat your meet video", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, PLANCANADA( 1, 1 ) { /** * get html for a Plane Canada public service ad * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { return Tools.completeLink( "http://plancanada.ca/", BuildImage.buildImgTag( "psa/plan/plangirl.png", "Visit PlanCanada.ca and support a child in the third world.", null, "rec", footerFile ), "rec", "_blank", footerFile ); } }, CLIMATEREALITYPROJECT( 1, 3 ) { /** * get html for Climate Reality Project public service ad formerly RepowerAmerica * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: // html5 video return ""; case 1: return Tools.completeLink( "https://www.climaterealityproject.org/video/doubters/", BuildImage.buildImgTag( "psa/climaterealityproject/doubt.png", "Climate Change Doubt", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "https://www.climaterealityproject.org/video/climate-101-bill-nye", BuildImage.buildImgTag( "psa/climaterealityproject/climate101.png", "Climate Change 101", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, SEASHEPHERD( 3, 3 /* count */ ) { /** * get html for a Sea Shepherd public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "http://www.seashepherd.org/milagro3/", BuildImage.buildImgTag( "psa/seashepherd/defendingdolphins.jpg", "Defending Dolphins", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "http://www.seashepherd.org.uk/cove-guardians/", BuildImage.buildImgTag( "psa/seashepherd/defendingdolphins.jpg", "Protecting Dolsphins", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "http://www.seashepherd.org/jairo/", BuildImage.buildImgTag( "psa/seashepherd/turtle.png", "Protecting the Sea Turtles", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, SPREADTHENET( 1, 3 ) { /** * get html for a SpreadTheNet public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); // All three possibilities are identical except for one digit in the file name. return Tools.completeLink( "http://plancanada.ca/spread-the-net", BuildImage.buildImgTag( "psa/spreadthenet/c" + choice + ".png", "Spread the Net", null, "rec", footerFile ), "rec", "_blank", footerFile ); } }, SOS( 1, 2 ) { /** html for a SOS childrens' Villages public service ad * @param fileBeingDistributed file where we embed this footer * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "https://www.soschildrensvillages.ca/", BuildImage.buildImgTag( "psa/sos/nelson.gif", "Support a Childrens’ Villages", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "https://www.soschildrensvillages.ca/", BuildImage.buildImgTag( "psa/sos/mike.gif", "Support a Childrens’ Villages", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, UNICEF( 1, 3 ) { /** * get html for a Unicef.ca public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: return Tools.completeLink( "http://www.unicef.ca/en/", BuildImage.buildImgTag( "psa/unicef/globalparent.jpg", "Be a Unicef global parent", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: return Tools.completeLink( "http://www.unicef.ca/en/?store_id=1201&s_locale=en_C", BuildImage.buildImgTag( "psa/unicef/gift.png", "Survival gifts for kids in the third world.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: /* Kids in Need of Desks */ return Tools.completeLink( "https://inspiredgifts.unicefusa.org/", BuildImage.buildImgTag( "psa/unicef/kind.jpg", "Provide desks to students in Malawi", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, WCWC( 1, 3 ) { /** * get html for a wildernesscommitteevictoria.org public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: case 1: // pick one of two images return Tools.completeLink( "https://www.wildernesscommittee.org/", BuildImage.buildImgTag( "psa/wcwc/c" + choice + ".jpg", "Visit Western Canada Wilderness Committee.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 2: return Tools.completeLink( "https://www.wildernesscommittee.org/join", BuildImage.buildImgTag( "psa/wcwc/animatedjoin.gif", "Join the Western Canada Wilderness Committee.", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }, WFP( 1, 2 ) { /** * get html for a world food program public service ad * @param fileBeingDistributed page where ad will be embedded * @param footerFile web page where iframe ad will go * @param aggregate not used * @param override overide normal random choice * @return html to display banner and link */ String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override ) { final int choice = chooseAnAdVariant( fileBeingDistributed, override ); switch ( choice ) { case 0: // Sean Penn video return Tools.completeLink( "http://www.wfp.org/videos/human-rescue-plan", BuildImage.buildImgTag( "psa/wfp/c" + choice + ".jpg", "Visit World Food Program.", null, "rec", footerFile ), "rec", "_blank", footerFile ); case 1: // map return Tools.completeLink( "image/psa/wfp/map.pdf", BuildImage.buildImgTag( "psa/wfp/c" + choice + ".jpg", "World Hunger Map", null, "rec", footerFile ), "rec", "_blank", footerFile ); default: throw new IllegalArgumentException( "program bug: invalid ad number" ); } } }; // declarations /** * weights for each charity collected into a single array */ private static int[] allWeights; /** * how many different variants there are on this ad. */ private final int variants; /** * weight for this charity in determining frequency of ad placement. */ private final int weight; // /declarations /** * constructor * * @param weight relative weight to control the frequency this ad appears */ PSAType( final int weight, final int variants ) { this.weight = weight; this.variants = variants; } // methods /** * generate a flash ad where the SWF file is out on the net. * * @param footerFile footer file where ad will be embedded * @param swf urlString to the swf file. without http://mindprod.com/image/ prefix. * @param width pixels wide. * @param height pixels tall * * @return HTML to invoke the flash. */ private static String flashAd( final File footerFile, String swf, int width, int height ) { final String relativeURL = Tools.relativeURL( "image/" + swf, footerFile ); final FastCat sb = new FastCat( 27 ); // we don't bothher with IE-specific ClassID. sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); // window - The SWF content plays in its own rectangle ("window") on a web page. The browser determines how // the SWF content is layered against other HTML elements. With this value, // you cannot explicitly specify if SWF content appears above or below other HTML elements on the page. // direct - Use direct to path rendering. This attribute bypasses compositing in the screen buffer and renders // the SWF content directly to the screen.This wmode value is recommended to provide the best // performance for // content playback.It enables hardware accelerated presentation of SWF content that uses Stage Video // or Stage 3D. // opaque - The SWF content is layered together with other HTML elements on the page. The SWF file is opaque // and hides everything // layered behind it on the page.This option reduces playback performance compared to wmode = window // or wmode = direct. // transparent - The SWF content is layered together with other HTML elements on the page. // The SWF file background color( Stage color ) is transparent.HTML elements beneath the SWF file are // visible // through any transparent areas of the SWF, with alpha blending. This option reduces playback // performance compared // to wmode = window or wmode = direct. // gpu - Use additional hardware acceleration on some Internet -connected // TVs and mobile devices. In contrast to other wmode values, pixel fidelity for display list // graphics is // not guaranteed. Otherwise, this value is similar to wmode = direct. sb.append( withFlash( footerFile ) ); return sb.toString(); }// /method /** * get array af weights for all PSATypes, caches result. * * @return array of weights */ static int[] getAllWeights() { if ( allWeights != null ) { return allWeights; } allWeights = new int[ PSAType.values().length ]; int i = 0; for ( PSAType p : PSAType.values() ) { allWeights[ i++ ] = p.weight; } return allWeights; }// /method /** * get HTML to display a flash button then when clicked will take you to download flash * * @param footerFile web page where iframe ad will go * * @return html to display banner and link */ private static String withFlash( final File footerFile ) { final FastCat sb = new FastCat( 3 ); sb.append( "" ); sb.append( BuildImage.buildImgTag( "video/flash.png", "You need Adobe flash to see this public service ad.", null, null, footerFile ) ); sb.append( "" ); return sb.toString(); }// /method /** * generate a flash ad where the SWF file is out on the net. * * @param footerFile footer file where ad will be embedded * @param desc destription of the video * @param videoID YouTube id of the swf video. * @param width pixels wide. * @param height pixels tall * * @return HTML to invoke the flash. */ private static String youTubeflashAd( final File footerFile, String desc, String videoID, int width, int height ) { final FastCat loc = new FastCat( 7 ); loc.append( "https://www.youtube.com/v/" ); loc.append( videoID ); loc.append( "?video_id=" ); loc.append( videoID ); loc.append( "&version=3&enablejsapi=1&playerapiid=" ); loc.append( videoID ); loc.append( "&hl=en&fs=1&showinfo=0&cc_load_policy=1" ); // location appears twice is expansion. final String location = loc.toString(); final FastCat sb = new FastCat( 28 ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); // we don't bother with embed. sb.append( "\n" ); sb.append( withFlash( footerFile ) ); return sb.toString(); }// /method /** * get html public service ad * * @param fileBeingDistributed page where ad will be embedded via an iframe * @param footerFile web page where iframe ad will go * @param aggregate not used except for Footer quote * @param override overide normal random choice (for proofreading) * * @return html to display banner and link */ abstract String ad( final File fileBeingDistributed, final File footerFile, final QuoteAggregate aggregate, final int override );// /method /** * select which of the ad variations to use * * @param fileBeingProcessed page where ad will be embedded * @param override overide normal random choice (for proofreading) * * @return choice 0..adVariations-1 */ int chooseAnAdVariant( final File fileBeingProcessed, final int override ) { if ( override >= 0 ) { assert override < variants : "chooseAnAdVariant override out of range " + override; return override; } // use same interval to select which banner for PSA as the PSA final long interval = configuration.getFooterRotateIntervalInMillis( fileBeingProcessed ); // same interval // as for advertiser // get a different hash than one used for other ad/quote selection. final int hash = 0x12345678 ^ Randomiser.getHashForFilename( interval, fileBeingProcessed ); // no weights here return Randomiser.getRandomSelectorIndexForHash( hash, variants ); }// /method /** * debugging, get statistics, get psaproof.html document with all ads on it. * * @param args not used. */ public static void main( final String[] args ) throws IOException { // code not normally needed if ( true ) { Global.installConfiguration( new ConfigurationForMindprod() ); int psaWeight = 0; for ( PSAType psaType : PSAType.values() ) { psaWeight += psaType.weight; } psaWeight -= PSA.NONMIL_WEIGHT + PSA.FOOTER_QUOTE_WEIGHT; out.println( "non-mil weight:" + PSA.NONMIL_WEIGHT + " quote weight:" + PSA.FOOTER_QUOTE_WEIGHT + " PSA " + "weight:" + psaWeight ); // generate document to sample the ads for proofreading and link checking. // O P E N final File file = new File( "E:/mindprod/psaproof.html" ); final PrintWriter prw = EIO.getPrintWriter( file, 32 * 1024, EIO.UTF8 ); prw.println( "\n" + "\n" + "\n" + "\n" + "Proofread PSAs\n" + "" + "\n" + "\n" ); for ( PSAType p : PSAType.values() ) { int count = p.variants; prw.println( "

" + p.name() + "

" ); for ( int i = 0; i < count; i++ ) { prw.println( p.ad( file, file, null, i ) ); prw.println( "
" ); } } prw.println( "" ); // C L O S E prw.close(); } }// /method // /methods }