Index: trunk/extensions/OnlineStatusBar/ext.onlinestatusbar.js |
— | — | @@ -2,32 +2,32 @@ |
3 | 3 | |
4 | 4 | $(function() { |
5 | 5 | |
6 | | - $statusbar = $('#status-top'); |
| 6 | +var $statusbar = $('#status-top'), |
7 | 7 | $iconbar = $('.onlinestatusbaricon'); |
8 | 8 | |
9 | | - // Only do the rest if we have the statusbar! |
10 | | - if ($statusbar.length > 0) { |
11 | | - function updateOnlineStatusBar() { |
12 | | - // ... code to fetch and update |
13 | | - $.ajax({ |
| 9 | +// Only do the rest if we have the statusbar! |
| 10 | +if ($statusbar.length > 0) { |
| 11 | + function updateOnlineStatusBar() { |
| 12 | + // ... code to fetch and update |
| 13 | + $.ajax({ |
14 | 14 | url: mw.config.get('wgScriptPath') + '/api' + mw.config.get('wgScriptExtension'), |
15 | 15 | data: { |
16 | | - action: "query", |
17 | | - prop: "onlinestatus", |
18 | | - onlinestatususer: mw.config.get('wgTitle'), |
19 | | - format: 'json' |
20 | | - }, |
21 | | - success: function(data) { |
22 | | - // code to update the statusbar based on the returned message |
23 | | - $icon = $("<img>").attr("src",mw.config.values.wgScriptPath+"/extensions/OnlineStatusBar/status"+({offline:'red',online:'green',away:'orange'})[data.onlinestatus.result]+'.png'); |
24 | | - $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 | | - } |
27 | | -}); |
28 | | - } |
| 16 | + action: "query", |
| 17 | + prop: "onlinestatus", |
| 18 | + onlinestatususer: mw.config.get('wgTitle'), |
| 19 | + format: 'json' |
| 20 | + }, |
| 21 | + success: function(data) { |
| 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'); |
| 24 | + $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 | + } |
| 27 | + }); |
| 28 | + } |
29 | 29 | |
30 | | - // Update the status every couple minutes if we leave the page open |
31 | | - window.setInterval(updateOnlineStatusBar, 120 * 1000); |
| 30 | + // Update the status every couple minutes if we leave the page open |
| 31 | + window.setInterval(updateOnlineStatusBar, 120 * 1000); |
32 | 32 | updateOnlineStatusBar(); |
33 | 33 | } |
34 | 34 | |