Skip to content
Permalink
Browse files

iOS version detection in desktop mode is available.

  • Loading branch information...
itozyun committed Jan 16, 2018
1 parent 49f1ed4 commit a19ef71f7b4849771ffbd82a93f5930e08a9e523
Showing with 48 additions and 12 deletions.
  1. +16 −0 README.md
  2. +22 −2 inline-js/01_useragent.js
  3. +10 −10 ua.html
@@ -20,6 +20,22 @@ itozyun の Web ドキュメント・プロジェクトの親プロジェクト
5. インクを節約して印刷 (@media print)
6. 古いブラウザのサポート

## Functions provided by Javascript - Javascript によって提供される機能

1. User Agent detection [Demo](https://itozyun.github.io/web-doc-base/ua.html) [src](https://github.com/itozyun/web-doc-base/blob/master/inline-js/01_useragent.js)
2. Optimal viewport based on user agent judgment [src](https://github.com/itozyun/web-doc-base/blob/master/inline-js/02_dynamicViewPort.js)
3. Adjustment of sidebar [src](https://github.com/itozyun/web-doc-base/blob/master/js/SidebarFixer.js)
4. Click thumbnail image to enlarge [src](https://github.com/itozyun/web-doc-base/blob/master/js/PicaThumnail.js)
5. Extension of blockquote [src](https://github.com/itozyun/web-doc-base/blob/master/js/blockquot.js)

---

1. ユーザーエージェント判定 [Demo](https://itozyun.github.io/web-doc-base/ua.html) [src](https://github.com/itozyun/web-doc-base/blob/master/inline-js/01_useragent.js)
2. ユーザーエージェント判定を元にした最適な viewport [src](https://github.com/itozyun/web-doc-base/blob/master/inline-js/02_dynamicViewPort.js)
3. サイドバーの追従 [src](https://github.com/itozyun/web-doc-base/blob/master/js/SidebarFixer.js)
4. サムネイル画像をクリックで拡大 [src](https://github.com/itozyun/web-doc-base/blob/master/js/PicaThumnail.js)
5. blockquote の拡張 [src](https://github.com/itozyun/web-doc-base/blob/master/js/blockquot.js)

## References - 参照プロジェクト

This project has been referred to the next project.
@@ -170,7 +170,27 @@ var ua = {},
ua[ 'MeeGo' ] = true;
} else if( iOS ){
dpRatio = window.devicePixelRatio === 1;
ua[ 'iOS' ] = getNumber( dav.split( '_' ).join( '.' ), 'OS ' );
v = getNumber( dav.split( '_' ).join( '.' ), 'OS ' );

if( v != v ){
ua[ PC_MODE ] = true;
v =
navigator[ 'mediaDevices' ] ? 11.2 :
widnow[ 'HTMLMeterElement' ] ? 10.3 :
widnow[ 'Proxy' ] ? 10.2 :
window[ 'HTMLPictureElement' ] ? 9.3 :
Number[ 'isNaN' ] ? 9.2 :
// http://uupaa.hatenablog.com/entry/2015/03/03/223344
window[ 'SharedWorker' ] ?
( window[ 'performance' ] && window[ 'performance' ][ 'now' ] ? 8.0 : 8.4 ) :
document.execCommand ? 7.1 :
window[ 'webkitURL' ] ? 6.1 :
window[ 'Worker' ] ? 5.1 :
window[ 'Int8Array' ] ? 4.3 :
window[ 'HTMLAudioElement' ] ? 4.1 : 3.2;
};

ua[ 'iOS' ] = v;

// 4:3 model
v = screenW === screenH * 1.5 || screenW * 1.5 === screenH;
@@ -182,7 +202,7 @@ var ua = {},
break;
case 'iPad' :
case 'iPad Simulator' :
ua[ 'iPad' ] = dpRatio ? '2-|1min-' : '3+|2min+';
ua[ 'iPad' ] = dpRatio ? '2-|1min-' : '3+|2min+';
break;
case 'iPod' :
// case 'iPod Simulator' : // 必要??
20 ua.html
@@ -12,16 +12,16 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width,target-densitydpi=medium-dpi,initial-scale=1,minimum-scale=1,shrink-to-fit=no">
<script>
(function(g,n,x,p,t,q){function d(a,b){return t(a.split(b)[1])}function f(a,b){return 0<=a.indexOf(b)}var a={},u=n.documentElement,b=x.userAgent,c=x.appVersion,v=t(c)||0,e=x.platform,l=n.documentMode,E=p.width,F=p.height,y=g.ontouchstart!==q;p=d(c,"Version/")||d(b,"Version/")||0;var s=g.opera,V=s&&(s.version?t(s.version()):Math.max(d(b,"Opera")||0,p,v)),I=g.opr,z=g.operamini,W=z&&Math.max(z.version?t(z.version())||0:0,d(b,"Opera Mini/")||0,d(b,"Opera Mobi/")||0,p),X=f(b,"UCWEB"),Y=d(b," U2/"),J=!s&&
(n.all||l),K=!J&&u.msContentZoomFactor,A=!K&&g.chrome,Z=f(b,"Safari"),$=f(b.toLowerCase(),"iris");q=u&&u.style.MozAppearance!==q;var u=f(c,"Konqueror"),G=d(b.toUpperCase(),"PLAYSTATION 3"),L=g.pspext&&d(g.pspext.sysGetEnv("x-psp-browser"),"system="),M=d(b,"PlayStation Vita"),aa="Nitro"===e,ba="Nintendo DSi"===e,ca="Nintendo 3DS"===e,N="New Nintendo 3DS"===e||f(b,"iPhone OS 6_0")&&320===E&&240===F,da="Nintendo Wii"===e,ea="Nintendo WiiU"===e,B=!N&&0===e.indexOf("iP")||0===b.indexOf("; iPh OS "),fa=
g.palmGetResource,O=d(b,"Windows Phone")||d(c,"Windows Phone OS ")||d(b,"; wds"),ga=f(c,"ZuneWP"),ha=0===e.indexOf("Win"),ia=0===e.indexOf("Mac"),ja=f(b,"Kobo"),ka=f(b,"Kindle"),la=f(b,"EBRD"),C=f(e,"Android")||q&&f(c,"Android"),P=f(e,"Linux"),ma=f(b,"MeeGo")&&f(b,"NokiaBrowser/8.5.0"),k=d(e,"Android ")||d(c,"Android ")||d(b,"Android ")||d(b,"; Adr "),w=d(c,"Trident/"),Q=d(c,"Edge/"),l=l?l:g.a?n.getElementsByTagName?7:4:n.compatMode?6:(0).toFixed?5.5:g.attachEvent?5:4,R=d(b,"rv:"),h=d(b,"AppleWebKit/"),
D=d(b,"Chrome/"),H=d(b,"OPR/"),S=d(b,"Fennec/"),T=d(b,"Netscape6/")||d(b,"Netscape/")||d(b,"Navigator/");d(b,"NetFront/");d(b,"iCab");var U=A&&534.3>=h,y=y&&(h||q)&&("Linux armv7l"===e||"Linux i686"===e)&&f(b,"Linux x86_64"),r;if(ja)a.Kobo=!0;else if(ka)a.KindlePW=!0;else if(la)a.SonyReader=!0;else if(ea)a.WiiU=!0;else if(da)a.Wii=!0;else if(aa)a.NDS=!0;else if(ba)a.NDSi=!0;else if(ca)a.N3DS=!0;else if(N)a.New3DS=!0;else if(G)a.PS3=!0;else if(L)a.PSP=L;else if(M)a.PSVita=M;else if(fa)a.WebOS=!0;else if(ma)a.MeeGo=
!0;else if(B)switch(b=1===g.devicePixelRatio,a.iOS=d(c.split("_").join("."),"OS "),c=E===1.5*F||1.5*E===F,e){case "iPhone":case "iPhone Simulator":a.iPhone=c?b?"3GS-":"4|4s":"5+";break;case "iPad":case "iPad Simulator":a.iPad=b?"2-|1min-":"3+|2min+";break;case "iPod":a.iPod=c?b?"3-":"4":"5+"}else if(O)a.WinPhone=O;else if(Q&&"ARM"===e)a.WinPhone=10,a.PCMode=!0;else if(ga)a.WinPhone=11===l?8.1:10===l?8:9===l?7.5:7===l?7:"?",a.PCMode=!0;else if(ha)switch(e){case "WinCE":a[e]=!0;break;case "Win16":case "Win32":case "Win64":a[e]=
!0;if(c=b.split("Windows NT 10")[1])switch(c.substr(0,2)){case ".0":c=10;break;default:c="?"}else if(c=b.split("Windows NT ")[1])switch(c.substr(0,3)){case "6.3":c=8.1;break;case "6.2":c=8;break;case "6.1":c=7;break;case "6.0":c="Vista";break;case "5.2":c="2003|XP64";break;case "5.1":c=f(c,"5.1; SV1")?"XPSP2":"XP";break;case "5.0":c=f(c,"5.01")?"2kSP1":2E3;break;case "4.0":c="NT";break;default:c="?"}else if(c=b.split("Windows ")[1])switch(c.substr(0,2)){case "98":c=f(c,"98; Win 9x 4.90")?"ME":"98|98SE";
break;case "95":c=95;break;case "3.":c=t(c);break;default:c="?"}else c="?";a.Windows=c}else if(ia)switch(a.Mac=!0,e){case "MacPowerPC":e="MacPPC";case "MacPPC":case "Mac68K":case "MacIntel":a[e]=!0}else C&&q?(f(b,"Android 4.4;")?a.Android="2.3+":4<=k?a.Android=k:C&&(a.Android="2.2+"),y&&(a.PCMode=!0)):C&&s?k?a.Android=k:(a.Android="1.6+",a.PCMode=!0):k?a.Android=k:P&&y?(r=!0,a.Android=A&&!U||I||H?k="4+":n.registerElement?k=n.execCommand?4.4:5:g.Int8Array?k=x.connection?g.searchBoxJavaBridge_||A?Number.isNaN?
4.1:4:4.2:4.4:k=529>h?1.5:531>h?2:534>h?g.HTMLAudioElement?2.3:2.2:3):P&&(a.Linux=!0);G?a.Sony=G:z?a.OperaMin=W:X?a.UCWEB=Y:s?a.Opera=a.Prsto=V:J?(w=w?w+4|0:l,w!==l&&(a.IEHost=w),a.IE=l,10<=l&&8<=a.Windows&&9>a.Windows&&0===g.screenY&&g.innerHeight+1!==g.outerHeight&&(a.ModernIE=l),a.Mac&&(a.MacIE=l)):K?a.Edge=Q:q?(a.Gecko=R,S?a.Fennec=S:C?a.Fennec=R:T&&(a.NN=T)):I||H?(a.OPR=H,a.Blink=D,r&&(a.PCMode=!0)):k&&U?(a.AOSP=k,r&&(a.PCMode=!0)):A?(a.Blink=D,r&&(a.PCMode=!0)):k&&n.registerElement?(a.CrWV=
k,r&&(a.PCMode=!0)):k&&(p||r)?(a.AOSP=k,r&&(a.PCMode=!0)):u?a.Khtml=v:h&&(a.WebKit=h,D?a.Chrome=D:$?a.Iris=h:Z&&(p?a.Safari=p:528.16>=h&&(a.Safari=73>h?.8:85>h?.9:100>h?1:125>h?1.1:312>h?1.2:412>h?1.3:419.3>=h?2:525.13>=h?3:525.25>=h?3.1:3.2)));var B=a.iOS,v=a.AOSP,m;6>B?(m="minimum-scale=1,",m=5>B?m+"maximum-scale=1":m+"initial-scale=1"):v&&(m="width=device-width,target-densitydpi=medium-dpi,",m=3>v?m+"user-scalable=no":m+"initial-scale=1,minimum-scale=1");m&&n.write('<meta name="viewport" content="'+
m+'">');g.ua=a})(window,document,navigator,screen,parseFloat);
(function(e,m,p,s,x,q){function d(a,b){return x(a.split(b)[1])|0}function g(a,b){return 0<=a.indexOf(b)}var a={},u=m.documentElement,c=p.userAgent,b=p.appVersion,G=x(b)|0,f=p.platform,l=m.documentMode,D=s.width;s=s.height;var y=e.ontouchstart!==q,v=d(b,"Version/")||d(c,"Version/"),t=e.opera,V=t&&(t.version?x(t.version()):Math.max(d(c,"Opera"),v,G)),H=e.opr,I=e.operamini,W=I&&Math.max(d(c,"Opera Mini/"),d(c,"Opera Mobi/"),v),X=g(c,"UCWEB"),Y=d(c," U2/"),J=!t&&(m.all||l),K=!J&&u.msContentZoomFactor,
z=!K&&e.chrome,Z=g(c,"Safari"),$=g(c.toLowerCase(),"iris");q=u&&u.style.MozAppearance!==q;var u=g(b,"Konqueror"),E=d(c.toUpperCase(),"PLAYSTATION 3"),L=e.pspext&&d(e.pspext.sysGetEnv("x-psp-browser"),"system="),M=d(c,"PlayStation Vita"),aa="Nitro"===f,ba="Nintendo DSi"===f,ca="Nintendo 3DS"===f,N="New Nintendo 3DS"===f||g(c,"iPhone OS 6_0")&&320===D&&240===s,da="Nintendo Wii"===f,ea="Nintendo WiiU"===f,A=!N&&0===f.indexOf("iP")||0===c.indexOf("; iPh OS "),fa=e.palmGetResource,O=d(c,"Windows Phone")||
d(b,"Windows Phone OS ")||d(c,"; wds"),ga=g(b,"ZuneWP"),ha=0===f.indexOf("Win"),ia=0===f.indexOf("Mac"),ja=g(c,"Kobo"),ka=g(c,"Kindle"),la=g(c,"EBRD"),B=g(f,"Android")||q&&g(b,"Android"),P=g(f,"Linux"),ma=g(c,"MeeGo")&&g(c,"NokiaBrowser/8.5.0"),k=d(f,"Android ")||d(b,"Android ")||d(c,"Android ")||d(c,"; Adr "),w=d(b,"Trident/"),Q=d(b,"Edge/"),l=l?l:e.a?m.getElementsByTagName?7:4:m.compatMode?6:(0).toFixed?5.5:e.attachEvent?5:4,R=d(c,"rv:"),h=d(c,"AppleWebKit/"),C=d(c,"Chrome/"),F=d(c,"OPR/"),S=d(c,
"Fennec/"),T=d(c,"Netscape6/")||d(c,"Netscape/")||d(c,"Navigator/");d(c,"NetFront/");d(c,"iCab");var U=z&&534.3>=h,y=y&&(h||q)&&("Linux armv7l"===f||"Linux i686"===f)&&g(c,"Linux x86_64"),r;if(ja)a.Kobo=!0;else if(ka)a.KindlePW=!0;else if(la)a.SonyReader=!0;else if(ea)a.WiiU=!0;else if(da)a.Wii=!0;else if(aa)a.NDS=!0;else if(ba)a.NDSi=!0;else if(ca)a.N3DS=!0;else if(N)a.New3DS=!0;else if(E)a.PS3=!0;else if(L)a.PSP=L;else if(M)a.PSVita=M;else if(fa)a.WebOS=!0;else if(ma)a.MeeGo=!0;else if(A)switch(c=
1===e.devicePixelRatio,b=d(b.split("_").join("."),"OS "),b!=b&&(a.PCMode=!0,b=p.mediaDevices?11.2:widnow.HTMLMeterElement?10.3:widnow.Proxy?10.2:e.HTMLPictureElement?9.3:Number.isNaN?9.2:e.SharedWorker?e.performance&&e.performance.now?8:8.4:m.execCommand?7.1:e.webkitURL?6.1:e.Worker?5.1:e.Int8Array?4.3:e.HTMLAudioElement?4.1:3.2),a.iOS=b,b=D===1.5*s||1.5*D===s,f){case "iPhone":case "iPhone Simulator":a.iPhone=b?c?"3GS-":"4|4s":"5+";break;case "iPad":case "iPad Simulator":a.iPad=c?"2-|1min-":"3+|2min+";
break;case "iPod":a.iPod=b?c?"3-":"4":"5+"}else if(O)a.WinPhone=O;else if(Q&&"ARM"===f)a.WinPhone=10,a.PCMode=!0;else if(ga)a.WinPhone=11===l?8.1:10===l?8:9===l?7.5:7===l?7:"?",a.PCMode=!0;else if(ha)switch(f){case "WinCE":a[f]=!0;break;case "Win16":case "Win32":case "Win64":a[f]=!0;if(b=c.split("Windows NT 10")[1])switch(b.substr(0,2)){case ".0":b=10;break;default:b="?"}else if(b=c.split("Windows NT ")[1])switch(b.substr(0,3)){case "6.3":b=8.1;break;case "6.2":b=8;break;case "6.1":b=7;break;case "6.0":b=
"Vista";break;case "5.2":b="2003|XP64";break;case "5.1":b=g(b,"5.1; SV1")?"XPSP2":"XP";break;case "5.0":b=g(b,"5.01")?"2kSP1":2E3;break;case "4.0":b="NT";break;default:b="?"}else if(b=c.split("Windows ")[1])switch(b.substr(0,2)){case "98":b=g(b,"98; Win 9x 4.90")?"ME":"98|98SE";break;case "95":b=95;break;case "3.":b=x(b);break;default:b="?"}else b="?";a.Windows=b}else if(ia)switch(a.Mac=!0,f){case "MacPowerPC":f="MacPPC";case "MacPPC":case "Mac68K":case "MacIntel":a[f]=!0}else B&&q?(g(c,"Android 4.4;")?
a.Android="2.3+":4<=k?a.Android=k:B&&(a.Android="2.2+"),y&&(a.PCMode=!0)):B&&t?k?a.Android=k:(a.Android="1.6+",a.PCMode=!0):k?a.Android=k:P&&y?(r=!0,a.Android=z&&!U||H||F?k="4+":m.registerElement?k=m.execCommand?4.4:5:e.Int8Array?k=p.connection?e.searchBoxJavaBridge_||z?Number.isNaN?4.1:4:4.2:4.4:k=529>h?1.5:531>h?2:534>h?e.HTMLAudioElement?2.3:2.2:3):P&&(a.Linux=!0);E?a.Sony=E:I?a.OperaMin=W:X?a.UCWEB=Y:t?a.Opera=a.Prsto=V:J?(w=w?w+4|0:l,w!==l&&(a.IEHost=w),a.IE=l,10<=l&&8<=a.Windows&&9>a.Windows&&
0===e.screenY&&e.innerHeight+1!==e.outerHeight&&(a.ModernIE=l),a.Mac&&(a.MacIE=l)):K?a.Edge=Q:q?(a.Gecko=R,S?a.Fennec=S:B?a.Fennec=R:T&&(a.NN=T)):H||F?(a.OPR=F,a.Blink=C,r&&(a.PCMode=!0)):k&&U?(a.AOSP=k,r&&(a.PCMode=!0)):z?(a.Blink=C,r&&(a.PCMode=!0)):k&&m.registerElement?(a.CrWV=k,r&&(a.PCMode=!0)):k&&(v||r)?(a.AOSP=k,r&&(a.PCMode=!0)):u?a.Khtml=G:h&&(a.WebKit=h,C?a.Chrome=C:$?a.Iris=h:Z&&(v?a.Safari=v:528.16>=h&&(a.Safari=73>h?.8:85>h?.9:100>h?1:125>h?1.1:312>h?1.2:412>h?1.3:419.3>=h?2:525.13>=
h?3:525.25>=h?3.1:3.2)));A=a.iOS;p=a.AOSP;var n;6>A?(n="minimum-scale=1,",n=5>A?n+"maximum-scale=1":n+"initial-scale=1"):p&&(n="width=device-width,target-densitydpi=medium-dpi,",n=3>p?n+"user-scalable=no":n+"initial-scale=1,minimum-scale=1");n&&m.write('<meta name="viewport" content="'+n+'">');e.ua=a})(window,document,navigator,screen,parseFloat);
</script>
<script>
(function(){

0 comments on commit a19ef71

Please sign in to comment.
You can’t perform that action at this time.