• R/O
  • HTTP
  • SSH
  • HTTPS

clientJs: コミット

クライアント側 js 開発用


コミットメタ情報

リビジョン512e08f4d38eab417f9651277e8a50c08535cb07 (tree)
日時2016-02-10 16:56:24
作者itozyun <itozyun@user...>
コミッターitozyun

ログメッセージ

Version 0.6.210, add Android browser PC mode detection.

変更サマリ

差分

--- a/0.6.x/js/01_core/02_XUA.js
+++ b/0.6.x/js/01_core/02_XUA.js
@@ -17,7 +17,7 @@ var X_UA = X[ 'UA' ] = {},
1717 dav = navigator.appVersion,
1818 tv = parseFloat(dav),
1919 sys = navigator.platform,
20- tridentToVer, i, j, v;
20+ tridentToVer, i, j, v, androidBrowserPCMode;
2121
2222 console.log( ' userAgent : ' + dua );
2323 console.log( '-' );
@@ -233,9 +233,8 @@ var X_UA = X[ 'UA' ] = {},
233233 * @alias X.UA.Linux
234234 * @type {boolean}
235235 */
236- X_UA[ 'Linux' ] = true;
237-
238- if( v = dua.split( 'Android ' )[ 1 ] ){
236+ if( ( v = dua.split( 'Android ' )[ 1 ] ) ||
237+ ( v = sys.split( 'Android ' )[ 1 ] ) ){ // PCモードの Android Firefox では platform に Android 0.0.0 が存在
239238 v = v.split( '.' );
240239 /**
241240 * @alias X.UA.AndroidMajor
@@ -265,6 +264,30 @@ var X_UA = X[ 'UA' ] = {},
265264 */
266265 X_UA[ 'Android' ] = X_UA[ 'AndroidMajor' ] + X_UA[ 'AndroidMinor' ] / 10;
267266 console.log( '>> Android : ' + X_UA[ 'Android' ] );
267+ } else
268+ if( ( sys === 'Linux armv7l' || sys === 'Linux i686' ) && window.ontouchstart !== undefined && ( v = parseFloat( dua.split( 'WebKit\/' )[ 1 ] ) ) ){
269+ // https://ja.wikipedia.org/wiki/WebKit
270+ // http://www.au.kddi.com/developer/android/kishu/ua/
271+ // webkit version to Android version...
272+ androidBrowserPCMode = !window.chrome || v < 534.3; // 4.0 & 3.x には chrome がいる...
273+ v =
274+ v < 529 ? 1.5 : // <= 528.5
275+ v < 531 ? 2.0 : // 530 2.0~2.1
276+ // 533 2.2~2.3
277+ v < 534 ? ( window.HTMLAudioElement ? 2.3 : 2.2 ) :
278+ v < 534.3 ? (
279+ !navigator[ 'connection' ] ? 4.4 :
280+ document.execCommand && window.history && history.pushState ? 4.2/* & 4.3 */ : // ここに 4.1, 4.0 も入ってくる...
281+ document.execCommand ? 4.1 :
282+ window[ 'Int8Array' ] ? 4 : 3 ) : // 534 - 3.x~4.x , 534.13=3.x
283+ v < 535 ? 4.0 : // 534.30 = 4.0-4.1
284+ v < 536 ? 4.1 : // 535.19 = 4.1
285+ v < 538 ? 4.4 : 0;// 537.36 = 4.4.2-5.x
286+ if( v ){
287+ // PC版で見る、にチェックが付いている場合、ユーザーエージェント文字列にも platform にも Android の文字列が存在しない(標準ブラウザ&Chrome)
288+ // Audio でタッチが必要か?の判定にとても困る...
289+ X_UA[ 'Android' ] = v;
290+ };
268291 };
269292 };
270293
@@ -350,7 +373,7 @@ var X_UA = X[ 'UA' ] = {},
350373 * @alias X.UA.EdgeMobile
351374 * @type {number}
352375 */
353- X_UA[ 'EdgeMobile' ] = v;
376+ X_UA[ 'EdgeMobile' ] = v;
354377 };
355378
356379 } else
@@ -620,11 +643,11 @@ var X_UA = X[ 'UA' ] = {},
620643 } else
621644
622645 // Android 標準ブラウザ AOSP と ChromeWeb View, Sブラウザがある
623- if( ( v = X_UA[ 'Android' ] ) && ( dua.indexOf( 'Chrome\/' ) < 0 || 0 < dua.indexOf( 'Version\/' ) ) ){ // Chrome/ を含まない または Version/ を含む
646+ if( ( v = X_UA[ 'Android' ] ) && ( dua.indexOf( 'Chrome\/' ) < 0 || 0 < dua.indexOf( 'Version\/' ) || androidBrowserPCMode ) ){ // Chrome/ を含まない または Version/ を含む
624647
625648 /* if( window.chrome ){ // Android3.1 のAOSPブラウザで .chrome がいた、、、
626649 } else */
627- if( dua.indexOf( 'Version\/' ) < 0 && 0 < dua.indexOf( 'Chrome\/' ) ){
650+ if( dua.indexOf( 'Version\/' ) < 0 && 0 < dua.indexOf( 'Chrome\/' ) && !androidBrowserPCMode ){
628651 /**
629652 * Android 標準ブラウザ Chrome WebView ブラウザ
630653 * @alias X.UA.ChromeWV
--- a/0.6.x/js/01_core/07_XString.js
+++ b/0.6.x/js/01_core/07_XString.js
@@ -3,6 +3,33 @@
33 // ------------ local variables -------------------------------------------- //
44 // ------------------------------------------------------------------------- //
55 var X_String_CRLF = String.fromCharCode( 13 ) + String.fromCharCode( 10 );
6+ X_String_CHAR_REFS = {"&iexcl;":161,"&cent;":162,"&pound;":163,"&curren;":164,"&yen;":165,"&brvbar;":166,"&sect;":167,"&uml;":168,"&copy;":169,
7+"&ordf;":170,"&laquo;":171,
8+"&not;":172,"&shy;":173,"&reg;":174,"&macr;":175,"&deg;":176,"&plusmn;":177,"&sup2;":178,"&sup3;":179,"&acute;":180,"&micro;":181,"&para;":182,
9+"&middot;":183,"&cedil;":184,"&sup1;":185,"&ordm;":186,"&raquo;":187,"&frac14;":188,"&frac12;":189,"&frac34;":190,"&iquest;":191,"&Agrave;":192,
10+"&Aacute;":193,"&Acirc;":194,"&Atilde;":195,"&Auml;":196,"&Aring;":197,"&AElig;":198,"&Ccedil;":199,"&Egrave;":200,"&Eacute;":201,"&Ecirc;":202,
11+"&Euml;":203,"&Igrave;":204,"&Iacute;":205,"&Icirc;":206,"&Iuml;":207,"&ETH;":208,"&Ntilde;":209,"&Ograve;":210,"&Oacute;":211,"&Ocirc;":212,
12+"&Otilde;":213,"&Ouml;":214,"&times;":215,"&Oslash;":216,"&Ugrave;":217,"&Uacute;":218,"&Ucirc;":219,"&Uuml;":220,"&Yacute;":221,"&THORN;":222,
13+"&szlig;":223,"&agrave;":224,"&aacute;":225,"&acirc;":226,"&atilde;":227,"&auml;":228,"&aring;":229,"&aelig;":230,"&ccedil;":231,"&egrave;":232,
14+"&eacute;":233,"&ecirc;":234,"&euml;":235,"&igrave;":236,"&iacute;":237,"&icirc;":238,"&iuml;":239,"&eth;":240,"&ntilde;":241,"&ograve;":242,
15+"&oacute;":243,"&ocirc;":244,"&otilde;":245,"&ouml;":246,"&divide;":247,"&oslash;":248,"&ugrave;":249,"&uacute;":250,"&ucirc;":251,"&uuml;":252,
16+"&yacute;":253,"&thorn;":254,"&yuml;":255,"&OElig;":338,"&oelig;":339,"&Scaron;":352,"&scaron;":353,"&Yuml;":376,"&circ;":710,"&tilde;":732,"&fnof;":402,
17+"&Alpha;":913,"&Beta;":914,"&Gamma;":915,"&Delta;":916,"&Epsilon;":917,"&Zeta;":918,"&Eta;":919,"&Theta;":920,"&Iota;":921,"&Kappa;":922,"&Lambda;":923,
18+"&Mu;":924,"&Nu;":925,"&Xi;":926,"&Omicron;":927,"&Pi;":928,"&Rho;":929,"&Sigma;":931,"&Tau;":932,"&Upsilon;":933,"&Phi;":934,"&Chi;":935,"&Psi;":936,
19+"&Omega;":937,"&alpha;":945,"&beta;":946,"&gamma;":947,"&delta;":948,"&epsilon;":949,"&zeta;":950,"&eta;":951,"&theta;":952,"&iota;":953,"&kappa;":954,
20+"&lambda;":955,"&mu;":956,"&nu;":957,"&xi;":958,"&omicron;":959,"&pi;":960,"&rho;":961,"&sigmaf;":962,"&sigma;":963,"&tau;":964,"&upsilon;":965,"&phi;":966,
21+"&chi;":967,"&psi;":968,"&omega;":969,"&thetasym;":977,"&upsih;":978,"&piv;":982,"&ensp;":8194,"&emsp;":8195,"&thinsp;":8201,"&zwnj;":8204,"&zwj;":8205,
22+"&lrm;":8206,"&rlm;":8207,"&ndash;":8211,"&mdash;":8212,"&lsquo;":8216,"&rsquo;":8217,"&sbquo;":8218,"&ldquo;":8220,"&rdquo;":8221,"&bdquo;":8222,
23+"&dagger;":8224,"&Dagger;":8225,"&bull;":8226,"&hellip;":8230,"&permil;":8240,"&prime;":8242,"&Prime;":8243,"&lsaquo;":8249,"&rsaquo;":8250,"&oline;":8254,
24+"&frasl;":8260,"&euro;":8364,"&image;":8465,"&ewierp;":8472,"&real;":8476,"&trade;":8482,"&alefsym;":8501,"&larr;":8592,"&uarr;":8593,"&rarr;":8594,
25+"&darr;":8595,"&harr;":8596,"&crarr;":8629,"&lArr;":8656,"&uArr;":8657,"&rArr;":8658,"&dArr;":8659,"&hArr;":8660,"&forall;":8704,"&part;":8706,
26+"&exist;":8707,"&empty;":8709,"&nabla;":8711,"&isin;":8712,"&notin;":8713,"&ni;":8715,"&prod;":8719,"&sum;":8721,"&minus;":8722,"&lowast;":8727,
27+"&radic;":8730,"&prop;":8733,"&infin;":8734,"&ang;":8736,"&and;":8743,"&or;":8744,"&cap;":8745,"&cup;":8746,"&int;":8747,"&there4;":8756,"&sim;":8764,
28+"&cong;":8773,"&asymp;":8776,"&ne;":8800,"&equiv;":8801,"&le;":8804,"&ge;":8805,
29+"&sub;":8834,"&sup;":8835,"&nsub;":8836,"&sube;":8838,"&supe;":8839,"&oplus;":8853,"&otimes;":8855,"&perp;":8869,"&sdot;":8901,
30+"&lceil;":8968,"&rceil;":8969,"&lfloor;":8970,"&rfloor;":8971,"&lang;":9001,"&rang;":9002,"&loz;":9674,"&spades;":9824,"&clubs;":9827,
31+"&hearts;":9829,"&diams;":9830
32+};
633
734 // ------------------------------------------------------------------------- //
835 // --- interface ----------------------------------------------------------- //
@@ -131,14 +158,26 @@ function X_String_whiteSpaceToTag( text ){
131158 * @return {string} html文字列
132159 */
133160 function X_String_chrReferanceTo( str ){
161+ var refs, i, l, ref;
162+
134163 if( str == null || str === '' ) return '';
135- return str.toString()
164+ if( str.indexOf( '&' ) === -1 ) return str;
165+
166+ str = str.toString()
136167 .split( '&quot;' ).join( '"' )
137168 .split( '&apos;' ).join( "'" )
138169 .split( '&lt;' ).join( '<' )
139170 .split( '&gt;' ).join( '>' )
140- .split( '&nbsp;' ).join( ' ' )
141- .split( '&amp;' ).join( '&' ); // last!
171+ .split( '&nbsp;' ).join( ' ' );
172+
173+ if( str.indexOf( '&' ) === -1 ) return str;
174+
175+ refs = X_String_CHAR_REFS;
176+ for( k in refs ){
177+ str = str.split( k ).join( String.fromCharCode( refs[ k ] ) );
178+ };
179+
180+ return str.split( '&amp;' ).join( '&' ); // last!
142181 };
143182
144183 /**
--- a/0.6.x/js/02_dom/20_XNode.js
+++ b/0.6.x/js/02_dom/20_XNode.js
@@ -1110,7 +1110,7 @@ function X_Node_html( html ){
11101110 if( !this[ '_tag' ] ) return this[ 'text' ]( html );
11111111
11121112 this[ 'empty' ]();
1113- if( html ){
1113+ if( html += '' ){
11141114 X_Node_append.apply( this, X_HtmlParser_parse( html, true ) );
11151115 };
11161116 return this;
旧リポジトリブラウザで表示