detection.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <!DOCTYPE html >
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Test browser detection</title>
  6. </head>
  7. <body>
  8. <script>
  9. if (window.location.hash.length>5) {
  10. $buoop=JSON.parse(decodeURIComponent(window.location.hash.substr(1)));
  11. }
  12. else {
  13. $buoop={}
  14. }
  15. </script>
  16. <script src="/update.js"></script>
  17. <script src="/static/zepto.min.js"></script>
  18. <style>
  19. body {
  20. font-family: sans-serif;
  21. font-size: 10px;
  22. }
  23. .red {
  24. background-color: rgb(255,200,200);
  25. }
  26. .green {
  27. background-color: rgb(200,255,200);
  28. }
  29. td {
  30. border: 1px solid #aaa;
  31. }
  32. table {
  33. border-collapse: collapse;
  34. }
  35. </style>
  36. <div class="noti">
  37. </div>
  38. <input id="config" size="100"/>
  39. <div>Current browser config:<span id ="dc"></span></div>
  40. <div>Latest:<span id ="latest"></span></div>
  41. <table>
  42. </table>
  43. <script type="text/javascript">
  44. var uas=[["Current Browser",$bu_getBrowser().t,navigator.userAgent]].concat({{ uas|tojson }})
  45. function test() {
  46. $("#config").val(decodeURIComponent(window.location.hash.substr(1)));
  47. if (window.location.hash.length>5) {
  48. $buoop=JSON.parse(decodeURIComponent(window.location.hash.substr(1)));
  49. }
  50. else {
  51. $buoop={}
  52. }
  53. $buoop.nomessage=true;
  54. $buo($buoop);
  55. var vs=$buoop.vsf;
  56. $("table").html(
  57. "<tr>\n\
  58. <td>Title</td>\
  59. <td>Detected as</td>\
  60. <td>ver</td>\
  61. <td>full ver</td>\
  62. <td>notify</td>\
  63. <td>is below</td>\
  64. <td>hide_reasons</td>\
  65. <td>require</td>\
  66. <td>is other</td>\
  67. <td>is insecure</td>\
  68. <td>is latest</td>\
  69. <td>is supported</td>\
  70. <td>mobile</td>\
  71. <td>no_os_update</td>\
  72. <td>age (years)</td>\
  73. <td>engine</td>\
  74. <td>system</td>\
  75. <td>UA string</td>\
  76. </tr>");
  77. for (i in uas) {
  78. var ua=uas[i];
  79. var notify;
  80. str=ua[2];
  81. bb=$bu_getBrowser(str);
  82. $buoop.override_ua=str;
  83. outdated=false;
  84. nn="<td class='normal'></td>";
  85. str=str.substring(11) //strip Mozilla/5.0
  86. var name=bb.t;
  87. //if (bb.mobile)
  88. // name+=" mobile";
  89. var dacond=!(name==ua[1] || (bb.donotnotify && ua[1]==false));
  90. if (dacond)
  91. da=name+"<br/>instead of "+ua[1];
  92. else
  93. da=name
  94. $buo($buoop);
  95. function td(value, cond,name) {
  96. if (value===undefined)
  97. value="?"
  98. if (name && value!=="?") {
  99. if (value)
  100. value=name;
  101. else
  102. value="";
  103. }
  104. if (cond===true)
  105. return "<td class='green'>"+value+"</td>"
  106. if (cond===false)
  107. return "<td class='red'>"+value+"</td>"
  108. return "<td>"+value+"</td>"
  109. }
  110. $("table").append($("<tr>"
  111. +td(ua[0])
  112. +td(da,!dacond)
  113. +td(bb.v)
  114. +td(bb.fullv)
  115. +td($buoop.notified,!!$buoop.notified,$buoop.reasons.join(","))
  116. +td($buoop.is_below_required,$buoop.is_below_required,"below")
  117. +td($buoop.hide_reasons)
  118. +td($buoop.required[bb.n])
  119. +td(bb.other,!bb.other,bb.other||" ")
  120. +td(bb.is_insecure,!bb.is_insecure,"insecure")
  121. +td(bb.is_latest,bb.is_latest,"latest")
  122. +td(bb.is_supported,bb.is_supported, "supported")
  123. +td(bb.mobile,undefined, "mobile")
  124. +td(bb.no_os_update,bb.no_os_update,"no os update")
  125. +td(bb.age_years)
  126. +td(bb.engine+" "+bb.engine_version)
  127. +td(ua[3]||"")
  128. +td("<a href=\"http://browser-update.org/update-browser.html?emulate="+encodeURIComponent(ua[2])+"\">"+str+"</a>")
  129. +"</tr>"
  130. ));
  131. }
  132. $("#dc").html(JSON.stringify(vs));
  133. $("#latest").html(JSON.stringify($bu_.vsakt));
  134. }
  135. test();
  136. window.onhashchange = function() {
  137. test();
  138. }
  139. /*
  140. function iPhoneVersion() {
  141. var h = window.screen.height,w = window.screen.width;
  142. if (w === 375 && h === 667) {
  143. return "6";
  144. }
  145. else if (w === 414 && h === 736) {
  146. return "6+";
  147. }
  148. else if (w === 320 && h === 568) {
  149. return "5";
  150. }
  151. else if (h <= 480) {
  152. return "2-4";
  153. }
  154. return 'none';
  155. }
  156. http://mediag.com/news/popular-screen-resolutions-designing-for-all/
  157. */
  158. //http://www.learnwebcoding.com/javascript/web_browser_useragent_values.php
  159. </script>
  160. </body>
  161. </html>