Last modified: 2012-09-27 01:14:31 UTC
The jsMsg() javascript function (line 775-827 of wikibits.js) doesn't work (as in it should display a message, but instead does nothing and returns false) on the modern skin. An example of the non-workingness of the function would be hitting watch on a page. In all other skins it comes up with a success message, in Modern, it does not. The following modified version of the function would fix the issue: /** * Add a cute little box at the top of the screen to inform the user of * something, replacing any preexisting message. * * @param String -or- Dom Object message HTML to be put inside the right div * @param String className Used in adding a class; should be different for each * call to allow CSS/JS to hide different boxes. null = no class used. * @return Boolean True on success, false on failure */ function jsMsg( message, className ) { if ( !document.getElementById ) { return false; } // We special-case skin structures provided by the software. Skins that // choose to abandon or significantly modify our formatting can just define // an mw-js-message div to start with. var messageDiv = document.getElementById( 'mw-js-message' ); if ( !messageDiv ) { messageDiv = document.createElement( 'div' ); if ( document.getElementById( 'column-content' ) && document.getElementById( 'content' ) ) { // MonoBook, presumably document.getElementById( 'content' ).insertBefore( messageDiv, document.getElementById( 'content' ).firstChild ); } else if ( document.getElementById('content') && document.getElementById( 'article' ) ) { // Non-Monobook but still recognizable (old-style) document.getElementById( 'article').insertBefore( messageDiv, document.getElementById( 'article' ).firstChild ); } else if ( document.getElementById( 'mw_content' ) && document.getElementById( 'mw_contentholder' ) ) { // Modern skin document.getElementById( 'mw_content').insertBefore( messageDiv, document.getElementById( 'mw_contentholder' ) ); } else { return false; } } messageDiv.setAttribute( 'id', 'mw-js-message' ); if( className ) { messageDiv.setAttribute( 'class', 'mw-js-message-'+className ); } if (typeof message === 'object') { while (messageDiv.hasChildNodes()) // Remove old content messageDiv.removeChild(messageDiv.firstChild); messageDiv.appendChild (message); // Append new content } else { messageDiv.innerHTML = message; } return true; } Alternatively the issue could be fixed by adding a <div id="mw-js-message"/> somewhere in the html of the skin. -Sincerely, Bawolff ([[n:user:Bawolff]])
*** Bug 14420 has been marked as a duplicate of this bug. ***
Isn't it possible to use something simpler inside the code above, like this: if ( !messageDiv ) { messageDiv = document.createElement('div'); var container = document.getElementById('content') || document.getElementById('article') || document.getElementById('mw_content'); if (!container) return false; container.insertBefore(messageDiv, container.firstChild) }
Thats probably a good idea. However for this to work you'd have to change the order: if ( !messageDiv ) { messageDiv = document.createElement('div'); var container = document.getElementById('article') || document.getElementById('content') || document.getElementById('mw_content'); if (!container) return false; container.insertBefore(messageDiv, container.firstChild) } as the standard skin defines both an article div and a content div, and otherwise it'd get mixed up with the logo if article is not the first choice.
Created attachment 5465 [details] diff for proposed modifications to wikibits.js Here is the diff for the proposed changes to /skins/common/wikibits.js (note: I've never added an attachment before. if i screw something up, sorry)
Fixed in r44025