Index: trunk/extensions/OnlineStatusBar/ext.onlinestatusbar.js |
— | — | @@ -17,11 +17,18 @@ |
18 | 18 | onlinestatususer: mw.config.get('wgTitle'), |
19 | 19 | format: 'json' |
20 | 20 | }, |
21 | | - success: function(data) { |
| 21 | + success: function( data ) { |
22 | 22 | // 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 | + }); |
24 | 32 | $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) |
26 | 33 | } |
27 | 34 | }); |
28 | 35 | } |