腾讯 求判断用户平台代码详解

刚看WEB前端代码,就看到了腾讯的这段代码,不懂,求详细指教

 if(window.location.toString().indexOf('pref=padindex') != -1){
}else{
    if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){  
      if(window.location.href.indexOf("?mobile")<0){
        try{
            if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
                window.location.href="http://xw.qq.com/index.htm";
            }else if(/iPad/i.test(navigator.userAgent)){
                window.location.href="http://www.qq.com/pad/"
            }else{
                window.location.href="http://xw.qq.com/simple/s/index/"
            }
        }catch(e){}
    }
    }
}

判断用户使用什么设备登录的,然后根据不同设备跳转不同页面
贴出来这部分应该是判断移动端的