|
|
Line 1: |
Line 1: |
| /* All JavaScript here will be loaded for users of the Vector skin */ | | /* All JavaScript here will be loaded for users of the Vector skin */ |
|
| |
| // Ensure the DOM is ready and jQuery is available
| |
| $( function () {
| |
| // Define the HTML for your ad slot.
| |
| // This will render the AdManager slot defined in MediaWiki:AdManager-top
| |
| // The <ad slot="top" /> is a parser function processed by MediaWiki on the server,
| |
| // but since we're injecting via JS, we're essentially telling the browser
| |
| // to render whatever HTML is stored in MediaWiki:AdManager-top.
| |
| // So, make sure MediaWiki:AdManager-top contains the *actual* ad code (HTML/JS).
| |
| var adHtml = '<div class="my-ad-container" style="margin: 10px auto; text-align: center;">' +
| |
| '<ad slot="top" />' + // This will be processed by MediaWiki's parser
| |
| '</div>';
| |
|
| |
| // Find the main content area and prepend the ad HTML
| |
| // The ID for the main content area is typically 'bodyContent' in Vector 2022
| |
| var bodyContent = $( '#bodyContent' );
| |
| if ( bodyContent.length ) {
| |
| bodyContent.prepend( adHtml );
| |
| }
| |
|
| |
| // You can add other slots similarly:
| |
| var bottomAdHtml = '<div class="my-ad-container" style="margin-top: 20px; text-align: center;"><ad slot="bottom" /></div>';
| |
| if ( bodyContent.length ) {
| |
| bodyContent.append( bottomAdHtml );
| |
| }
| |
| } );
| |