Last modified: 2012-09-27 01:14:31 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T17695, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 15695 - jsMsg() javascript function in wikibits.js doesn't work on modern skin
jsMsg() javascript function in wikibits.js doesn't work on modern skin
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Interface (Other open bugs)
1.13.x
All All
: Normal minor (vote)
: ---
Assigned To: River Tarnell
:
: 14420 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-23 01:53 UTC by Bawolff (Brian Wolff)
Modified: 2012-09-27 01:14 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
diff for proposed modifications to wikibits.js (2.94 KB, patch)
2008-10-25 07:00 UTC, Bawolff (Brian Wolff)
Details

Description Bawolff (Brian Wolff) 2008-09-23 01:53:33 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]])
Comment 1 Chad H. 2008-09-23 12:43:31 UTC
*** Bug 14420 has been marked as a duplicate of this bug. ***
Comment 2 AlexSm 2008-09-23 14:08:42 UTC
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)
}
Comment 3 Bawolff (Brian Wolff) 2008-09-26 13:40:57 UTC
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.
Comment 4 Bawolff (Brian Wolff) 2008-10-25 07:00:31 UTC
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)
Comment 5 Aaron Schulz 2008-11-28 18:41:36 UTC
Fixed in r44025

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links