MediaWiki:Centralnotice-template-POTY 2015 R2
<script>
/* MediaWiki:CentralNotice/Resources/BannerShowHideCountDate.js * Determine if a banner should be hidden or displayed based on the * contents of the cookie named `hide-cookie-name` and that + `-wait`. * * Showing a banner entails that a certain number of impressions have * already occured in a time period. * * hide-cookie-show-count - Number of impressions to show per period * hide-cookie-wait-count - Number of impressions to wait per period * hide-cookie-wait-delay - Number of second in period * * Provides CentralNotice alterImpressionData hook * Banner may be forced if URL parameter force = 1 * Counters may be reset if URL parameter reset = 1 * * Flow chart: https://commons.wikimedia.org/wiki/File:CentralNotice_-_wait_cookie_code_flow.png */ (function(mw) { var /** Total number of impressions seen by this user */ cookieCount = parseInt($.cookie('POTY2015R2')) || 0,
waitData = ($.cookie('POTY2015R2-wait') || ).split(/[|]/), /** This cycle's count of how many impressions we've waited for */ waitCount = parseInt(waitData[0]) || 0, /** Timestamp (ms) until we can show another banner */ waitUntil = parseInt(waitData[1]) || 0, /** Number of impressions seen this cycle */ waitSeenCount = parseInt(waitData[2]) || 0,
showLimit = parseInt('5') || 0, waitLimit = parseInt('0') || 0, waitDelay = parseInt('2592000') || 0,
hideBanner = true, hideReason = null;
if (location.search.match(/\breset=1/)) { // Reset counters on demand cookieCount = 0; waitCount = 0; waitUntil = 0; waitSeenCount = 0; }
var pastDate = waitUntil < new Date().getTime(), waitForHideImps = waitCount < waitLimit, waitForShowImps = waitSeenCount < showLimit; if (location.search.match(/\bforce=1/)) { hideBanner = false; } else if (!pastDate) { hideReason = 'waitdate'; waitCount += 1; } else if (pastDate && waitForHideImps) { hideReason = 'waitimps'; waitCount += 1; } else if (pastDate && !waitForHideImps && waitForShowImps) { hideBanner = false; waitSeenCount += 1; cookieCount += 1; if (waitSeenCount >= showLimit) { waitCount = 0; waitSeenCount = 0; waitUntil = new Date().getTime() + (waitDelay * 1000); } } else { hideReason = 'waiterr'; waitCount = 0; waitSeenCount = 0; waitUntil = new Date().getTime() + (waitDelay * 1000); } waitData = waitCount + '|' + waitUntil + '|' + waitSeenCount; // Finish up and store results $.cookie('POTY2015R2', cookieCount, { expires: 365, path: '/' }); $.cookie('POTY2015R2-wait', waitData, { expires: 365, path: '/' }); mw.centralNotice.bannerData.hideResult = hideBanner; mw.centralNotice.bannerData.hideReason = hideReason; mw.centralNotice.bannerData.cookieCount = cookieCount; })(mediaWiki); mediaWiki.centralNotice.bannerData.alterImpressionData = function( impressionData ) { // Returning true from this function indicates the banner was shown if (mediaWiki.centralNotice.bannerData.hideReason) { impressionData.reason = mediaWiki.centralNotice.bannerData.hideReason; } if (mediaWiki.centralNotice.bannerData.cookieCount) { impressionData.banner_count = mediaWiki.centralNotice.bannerData.cookieCount; } return !mediaWiki.centralNotice.bannerData.hideResult; };
</script> <style type="text/css">
- centralNotice.collapsed {
display: none; }
- cn-toggle-box {
float: right; }
- poty2015_round2_banner_1 {
position: relative; z-index: 0; overflow: hidden; padding-top: 1em !important; margin-bottom: 0.5em !important; background-color:#867969; background-image:url('//upload.wikimedia.org/wikipedia/commons/4/45/Wikimedia_Commons_Picture_of_the_Year_2014_Banner_1.jpg'); background-position: top center; border: solid 1px #CCCCCC; font-family: Helvetica, Verdana, sans-serif; height:93px; padding-bottom: 1em; background-repeat: no-repeat;
} .trans-box a {
text-align: right; font-size: 0.8em; padding-right: 6px; color: white; white-space: nowrap; text-decoration: none;
} div#cn-toggle-box {
position: absolute; z-index: 98; top: 2px; right: 6px;
}
- poty-text {
font-size: 1.3em; font-weight: bold; color: white; padding: 16px 30px 10px 30px; line-height: 1.3em; text-align: left;
}
- poty2014-text-1 {
font-size: 120%;
} .cn-full-banner-click {
text-decoration: none;
} </style>