r105406 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105405‎ | r105406 | r105407 >
Date:01:37, 7 December 2011
Author:brion
Status:ok
Tags:
Comment:
fix for onlinestatusbar ajax loader:
* since we're building HTML text, use mw.html.element() to build source instead of $('<img>') to build a DOM element
* break a couple things up into multiple lines to make them easier to read/maintain
* use wgExtensionAssetsPath rather than wgScriptPath to ensure this'll work on configs like Wikimedia's where the assets are loaded from another domain
Modified paths:
  • /trunk/extensions/OnlineStatusBar/ext.onlinestatusbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/ext.onlinestatusbar.js
@@ -17,11 +17,18 @@
1818 onlinestatususer: mw.config.get('wgTitle'),
1919 format: 'json'
2020 },
21 - success: function(data) {
 21+ success: function( data ) {
2222 // code to update the statusbar based on the returned message
23 - var $icon = $("<img>").attr("src",mw.config.values.wgScriptPath+"/extensions/OnlineStatusBar/status"+({offline:'red',online:'green',away:'orange'})[data.onlinestatus.result]+'.png');
 23+ var statusMap = {
 24+ offline:'red',
 25+ online:'green',
 26+ away:'orange'
 27+ };
 28+ var imgName = statusMap[data.onlinestatus.result] + '.png';
 29+ var $icon = mw.html.element('img', {
 30+ src: mw.config.values.wgExtensionAssetsPath + "/OnlineStatusBar/status" + imgName
 31+ });
2432 $statusbar.html(mw.msg('onlinestatusbar-line', wgTitle,$icon,data.onlinestatus.result));
25 - //$statusbar.text(mw.config.values.wgTitle +" is now ").append($("<img>").attr("src",mw.config.values.wgScriptPath+"/extensions/OnlineStatusBar/status"+({offline:'red',online:'green',away:'orange'})[data.onlinestatus.result]+'.png')).append(data)
2633 }
2734 });
2835 }

Status & tagging log