MediaWiki:Centralnotice-template-wm2015scholarcfp
<style type="text/css">
- centralNotice.collapsed #{{{banner}}} {
display: none !important;
}
- {{{banner}}} {
position: relative; margin-bottom: 0.5em; background: #eee url('//upload.wikimedia.org/wikipedia/commons/0/0d/Gray-gradient1.png') repeat-x; border: solid 1px #000; height: 75px; display: none;
}
- {{{banner}}} a.scholar-full-banner-click {
display: block; height: 100%; width: 100%; cursor: pointer;
}
- {{{banner}}} a:hover {
text-decoration: none;
}
- {{{banner}}}-logo {
position: absolute; top: 15px; left: 15px; background: url('//upload.wikimedia.org/wikipedia/commons/thumb/5/57/Wikimania.svg/30px-Wikimania.svg.png') no-repeat; height: 40px; width: 30px;
}
- {{{banner}}}-content {
font-size: 14px; /* font-size: 2vmin; */ font-weight: bold; color: black; padding: 14px 40px 0 60px; text-align: center; line-height: 1.4;
}
- {{{banner}}}-text:hover {
text-decoration: underline;
}
- {{{banner}}} div#scholar-toggle-box {
position: absolute; top: 0; right: 0; height: 32px; width: 27px;
}
- {{{banner}}} div#scholar-translation-link {
position: absolute; right: 5px; bottom: 5px; font-size: 0.8em; white-space: nowrap;
}
- {{{banner}}} #scholar-translation-link:hover {
text-decoration: underline;
}
.rtl #scholar-translation-link {
text-align: left;
} </style>
<script type="text/javascript"> // Based on stew2014vote banner by User:Snowolf var wgHideScholar2015Notice = {
'notice':null, 'min_edit_count':50, // minimum crosswiki edit count to show banner 'cookie_key':'WMScholarBannerShow', /********* ** Log error *********/ 'log':function( text ) { /*if( !window.console || !console.log ) return; console.log( 'wgHideScholar2015Notice: ' + text );*/ }, /********* ** Initialize script *********/ 'initialize':function() { /* not logged in */ if( typeof mw.config.get( 'wgUserName' ) === 'undefined' ) return; /* get elements */ this.notice = document.getElementById('{{{banner}}}'); if( !this.notice ) return this.log( 'could not locate #{{{banner}}}' ); /* already checked */ var pos = document.cookie.indexOf( this.cookie_key + '=' ); if( pos > -1 ) { if( document.cookie.charAt(pos + this.cookie_key.length + 1) == 1) this.notice.style.display = 'block'; return; } /* initialize AJAX request */ this.sendAjaxRequest(); }, /********* ** Send AJAX request *********/ 'sendAjaxRequest':function() { var uri = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?action=query&meta=globaluserinfo&guiprop=merged|unattached&format=json&rawcontinue=&guiuser=' + encodeURIComponent( mw.config.get( 'wgUserName' ) ); var request = sajax_init_object(); request.onreadystatechange = this.onAjaxStateChange; request.open( 'GET', uri, true/*asynchronous*/ ); request.send( ); }, /********* ** Handle AJAX request state change *********/ 'onAjaxStateChange':function() { /* request in progress */ if( this.readyState !== 4 ) return; /* request failed */ if( this.status !== 200 ) return this.log( 'AJAX error ' + this.status + ': ' + this.statusText ); /* parse */ result = eval( '(' + this.responseText + ')' ); wgHideScholar2015Notice.checkMinEdit( result ); }, /********* ** Check minimum edit count to show banner *********/ 'checkMinEdit':function( data ) { if( data.error ) return this.log( 'API error ' + data.error.code + ': ' + data.error.info ); /* merge lists */ var wikis = data.query.globaluserinfo.merged; wikis.concat( data.query.globaluserinfo.unattached ); if( wikis.length === 0 ) return this.log( 'API returned no wikis (how can this happen?)' ); /* get edit count */ var edit_count = 0; var eligible; for( var i = 0, len = wikis.length; i < len; i++ ) { edit_count = edit_count + parseInt(wikis[i].editcount, 10); //this.log( wikis[i].wiki + ': edits=' + wikis[i].editcount + ' (total=' + edit_count + ')' ); eligible = (edit_count >= this.min_edit_count); if( eligible ) break; } /* hide notice and store result */ this.log( 'checked likely eligibility: ' + eligible + ' (' + edit_count + ' edits)' ); if( !eligible ) { this.setCookie( this.cookie_key, '0' ); this.notice.style.display = 'none'; } else { this.setCookie( this.cookie_key, '1' ); this.notice.style.display = 'block'; } }, /********* ** Set cookie *********/ 'setCookie':function( key, value ) { // set expiry to end of scholarships application var expiryDate = new Date(Date.UTC(2015, 1, 17, 0, 0, 0, 0)); // set cookie document.cookie = key + '=' + value + ';expires=' + expiryDate.toGMTString(); }
}; wgHideScholar2015Notice.initialize(); </script>