r73655 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73654‎ | r73655 | r73656 >
Date:14:18, 24 September 2010
Author:catrope
Status:deferred
Tags:
Comment:
1.16wmf4: Fix JS errors about $j.os apparently not being defined in some strange cases. Trunk equivalent uses something different and probably doesn't have this bug
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.js
@@ -27,16 +27,20 @@
2828 }
2929 // Detect operating system
3030 var os = 'other';
31 - switch ( $j.os.name ) {
32 - case 'win': os = 'windows'; break;
33 - case 'mac': os = 'macos'; break;
34 - case 'linux': os = 'linux'; break;
 31+ if ( typeof $j.os != 'undefined' && typeof $j.os.name != 'undefined' ) {
 32+ switch ( $j.os.name ) {
 33+ case 'win': os = 'windows'; break;
 34+ case 'mac': os = 'macos'; break;
 35+ case 'linux': os = 'linux'; break;
 36+ }
3537 }
36 - switch ( $j.browser.name ) {
37 - case 'iemobile': os = 'windowsmobile'; break;
38 - case 'iphone': os = 'iphoneos'; break;
39 - case 'ipod': os = 'iphoneos'; break;
40 - case 'ipad': os = 'iphoneos'; break;
 38+ if ( typeof $j.browser != 'undefined' && typeof $j.browser.name != 'undefined' ) {
 39+ switch ( $j.browser.name ) {
 40+ case 'iemobile': os = 'windowsmobile'; break;
 41+ case 'iphone': os = 'iphoneos'; break;
 42+ case 'ipod': os = 'iphoneos'; break;
 43+ case 'ipad': os = 'iphoneos'; break;
 44+ }
4145 }
4246 return {
4347 'survey-browser': browser, 'survey-os': os, 'survey-res-x': screen.width, 'survey-res-y': screen.height

Status & tagging log