OSDN Git Service

Version 0.6.107, cleanup X.NodeCSS, fix X.Node.Event for touch, add unescape for...
[pettanr/clientJs.git] / 0.6.x / js / 06_net / 02_XNetJSONP.js
index 806396c..45cfec5 100644 (file)
@@ -26,9 +26,9 @@ X.Net.JSONP = {
                        X_NET_JSONPWrapper._busy = false;
                        
                        X_NET_JSONPWrapper
-                               .asyncDispatch( 0, {
+                               .asyncDispatch( {
                                        type : jsonString ? X.Event.SUCCESS : X.Event.ERROR,
-                                       data : jsonString //eval( jsonString )
+                                       data : jsonString //window.JSON ? JSON.parse( jsonString ) : eval( jsonString )
                                } );
                        
                        console.log( 'ms : ' + time + ' speed : ' + ( ( jsonString.length + ( opt_json2FileSize || 0 ) ) / time * 1000 ) + ' バイト/秒.' );
@@ -52,15 +52,13 @@ function X_NET_JSONP_loadScriptInNinjaIframe( url ){
        // TODO '<scr'+'ipt> 化 恐らくアンチウイルスソフトが反応しないための対策
        // TODO postMessage の利用
 
-       // numonLoad
-
        if( X_UA.Opera ){
                html = [
                        ( window[ 'JSON' ] ? '' : '<script src="' + json2Path + '"></script>' ),
                        '<script>',
                                'onunload=function(){im.onload=im.onerror=""};',
                                'nw=+new Date;',
-                               'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw);nw=0}}',
+                               'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw', window[ 'JSON' ] ? json2FileSize : 0 ,');nw=0}}',
                        '</script>',    
                        '<script id="jp"></script>',
                        '<img id="im" src="', url, '" onload="jp.src=im.src" onerror="jp.src=im.src">'
@@ -69,6 +67,9 @@ function X_NET_JSONP_loadScriptInNinjaIframe( url ){
        } else
        if( X_UA.IE8 ){
                html = [
+                       // JavaScriptでunicode文字列をunescapeする
+                       // http://perutago.seesaa.net/article/202801583.html
+                       
                        // http://blog.livedoor.jp/dankogai/archives/51503830.html              
                        // Ajax - IE8にもJSON入ってます。使えるとは限らないけど
                        // Compatibility mode (別名Quirks mode) では、JSONオブジェクトは無効になります。iframeもだめです
@@ -76,7 +77,7 @@ function X_NET_JSONP_loadScriptInNinjaIframe( url ){
                        '<script>',
                                'onunload=function(){clearTimeout(id)};',
                                'nw=0;', // なぜか必要,,,
-                               'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',parent.JSON.stringify(o),-nw)}',
+                               'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',parent.JSON.stringify(o).replace(/\\\\u([a-fA-F0-9]{4})/g,function(a,b){return String.fromCharCode(parseInt(b,16))}),-nw)}',
                                'function tm(){jp.src="', url ,'";nw=+new Date}',
                                'id=setTimeout(tm,16);',
                        '</script>'