2 var X_URL_BASE_URL = ( function( parts ){
\r
3 var last = 1 < parts.length && parts[ parts.length - 1 ];
\r
4 if( last !== false && ( last === '' || //末尾が/で終わるとき
\r
5 last.indexOf( '.' ) !== -1 ) ){//末尾がファイル名で終わる時
\r
9 return parts.join( '/' );
\r
10 })( location.href.split( '?' )[ 0 ].split( '#' )[ 0 ].split( '/' ) ),
\r
12 X_URL_IS_LOCAL = location.protocol === 'file:' || location.hostname === 'localhost' || location.hostname === '127.0.0.1';
\r
17 BASE_URL : X_URL_BASE_URL,
\r
19 IS_LOCAL : X_URL_IS_LOCAL,
\r
21 toAbsolutePath : X_URL_toAbsolutePath
\r
28 * AS3で相対パスを絶対パスに変換する
\r
29 * http://www.shin-go.net/motionlab/?p=449
\r
31 function X_URL_toAbsolutePath( path ){
\r
36 if( 'http:file:https:'.indexOf( path.substr( 0, 4 ) ) !== -1 ) return path;
\r
38 _ary = X_URL_BASE_URL.split( ss );
\r
39 ary = _ary[ 1 ].split( s );
\r
41 if( path.charAt( 0 ) === s ) return [ _ary[ 0 ], ss, ary[ 0 ], path ].join( '' );
\r
43 if( path.substr( 0, 2 ) === './' ){
\r
44 path = path.substr( 2 );
\r
46 while( path.substr( i, 3 ) === '../' ){
\r
50 if( i ) path = path.substr( i );
\r
52 return [ _ary[ 0 ], ss, ary.join( s ), s, path ].join( '' );
\r