OSDN Git Service

Version 0.6.159, fix X.Class & X.XHR.Gadget.
[pettanr/clientJs.git] / 0.6.x / js / 06_net / 05_XXHRGadget.js
index 1d294e0..443d455 100644 (file)
@@ -1,3 +1,5 @@
+//{+xhrgadget"OpenSocialガジェット通信プロキシ"(Xドメインは元よりXプロトコルな擬似xhr通信を可能にする)[+xhr]\r
+\r
 /*\r
  * gadgets.io.makeRequest\r
  * \r
@@ -15,8 +17,6 @@
  * \r
  */\r
 \r
-\r
-\r
 var X_NET_GIMR_canUse         = 5.5 <= X_UA[ 'IE' ] || !X_UA[ 'IE' ],\r
        \r
        X_NET_GIMR_iframeName     = 'gadgetProxy_' + ( Math.random() * 100000 | 0 ),\r
@@ -42,7 +42,7 @@ var X_NET_GIMR_canUse         = 5.5 <= X_UA[ 'IE' ] || !X_UA[ 'IE' ],
        \r
        X_NET_GIMR_lastHashString,\r
        \r
-       X_NET_GIMR_isReceiveBatches, X_NET_GIMR_receivedString;\r
+       X_NET_GIMR_isReceiveBatches, X_NET_GIMR_receivedString = '';\r
 \r
 \r
 function X_NET_GIMR_detectImageOverIframe(){\r
@@ -75,26 +75,26 @@ function X_NET_GIMR_detectImageOverIframe(){
                                                n   = parseInt( ret );\r
                                                \r
                                                if( X_NET_GIMR_isReceiveBatches ){\r
-                                                       X_NET_GIMR_receivedString += ret;\r
+                                                       X_NET_GIMR_receivedString += X_Net_GIMR_decodeLocationHash( ret );                                              \r
                                                        if( --X_NET_GIMR_isReceiveBatches ){\r
                                                                iwin.location.href = X_NET_GIMR_GADGET_URL + '#_recived_' + X_NET_GIMR_isReceiveBatches;\r
                                                                return;\r
                                                        };\r
                                                } else\r
                                                if( 1 < n ){\r
-                                                       X_NET_GIMR_receivedString   = ret.substr( ( n + ':' ).length );\r
+                                                       ret = ret.substr( ( n + ':' ).length );\r
+                                                       X_NET_GIMR_receivedString   = X_Net_GIMR_decodeLocationHash( ret );\r
                                                        X_NET_GIMR_isReceiveBatches = --n;\r
                                                        iwin.location.href = X_NET_GIMR_GADGET_URL + '#_recived_' + X_NET_GIMR_isReceiveBatches;\r
                                                        // speedup\r
                                                        X_NET_GIMR_timerID = X_Timer_add( 16, 0, X_NET_GIMR_detectImageOverIframe );\r
                                                        return X_Callback_UN_LISTEN;\r
                                                } else {\r
-                                                       X_NET_GIMR_receivedString = ret;\r
+                                                       X_NET_GIMR_receivedString = X_Net_GIMR_decodeLocationHash( ret );\r
                                                };\r
 \r
-                                               zero = String.fromCharCode( 0 );\r
-                                               console.log( _builtin_decodeURI( X_NET_GIMR_receivedString ).split( zero + '002' ).join( '--' ).split( zero + 'E0F' ).join( '--' ) );\r
-                                               ret = X_String_parseTrustedJsonString( _builtin_decodeURI( X_NET_GIMR_receivedString ).split( zero + '002' ).join( '。' ).split( zero + 'F0E' ).join( '.' ) );\r
+                                               ret = X_String_parseTrustedJsonString( X_NET_GIMR_receivedString );\r
+                                               \r
                                                \r
                                                X_NET_GIMR_receivedString = '';\r
                                                \r
@@ -132,6 +132,26 @@ function X_NET_GIMR_detectImageOverIframe(){
                };\r
        };\r
 };\r
+/*\r
+(function( i, l, res ){\r
+       var start = X.Timer.now(), loc = location, res = [], hash;\r
+       for( ; i < l; ++i ){\r
+               loc.replace = chr = '#' + String.fromCharCode( i );\r
+               hash = _builtin_decodeURI( loc.hash );\r
+               if( _builtin_decodeURI( chr ) !== hash ) res.push( i + ':' + _builtin_decodeURI( chr ) );\r
+               if( start + 16 < X.Timer.now() ){\r
+                       //console.log( i + ' / ' + l + ' ' + start + ' ' + X.Timer.now()  );\r
+                       X.Timer.once( 16, arguments.callee, [ ++i, l, res ] );\r
+                       return;\r
+               };\r
+       };\r
+       alert( res.length + '\n' + res.join() );\r
+})( 0xff, 0xffff, [] ); */\r
+\r
+// http://outcloud.blogspot.jp/2015/06/gecko-location-hash.html\r
+function X_Net_GIMR_decodeLocationHash( str ){\r
+       return X_UA[ 'Gecko' ] ? unescape( str ) : decodeURIComponent( str );\r
+};\r
 \r
 // コマンドが長い場合、分割する\r
 function X_NET_GIMR_toJSONString( obj ){\r
@@ -245,3 +265,4 @@ X_TEMP.X_Net_GIMR_props = {
                }\r
        };\r
 \r
+//}+xhrgadget
\ No newline at end of file