source: Dev/trunk/src/client/dojox/io/proxy/xip_client.html

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.9 KB
Line 
1<!--
2        /*
3                Copyright (c) 2004-2011, The Dojo Foundation
4                All Rights Reserved.
5       
6                Licensed under the Academic Free License version 2.1 or above OR the
7                modified BSD license. For more information on Dojo licensing, see:
8       
9                        http://dojotoolkit.org/community/licensing.shtml
10        */
11-->
12<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
13        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
14
15<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
16<head>
17        <title></title>
18        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
19        <!-- Security protection: uncomment the start and end script tags to enable. -->
20        <!-- script type="text/javascript" -->
21        // <!--
22       
23        function pollHash(){
24                //Can't use location.hash because at least Firefox does a decodeURIComponent on it.
25                var urlParts = window.location.href.split("#");
26                if(urlParts.length == 2){
27                        var newHash = urlParts[1];
28                        if(newHash != xipCurrentHash){
29                                try{
30                                        callMaster(xipStateId, newHash);
31                                }catch(e){
32                                        //Make sure to not keep processing the error hash value.
33                                        xipCurrentHash = newHash;
34                                        throw e;
35                                }
36                                xipCurrentHash = newHash;
37                        }
38                }
39        }
40
41        function unpackMessage(encodedMessage){
42                var parts = encodedMessage.split(":");
43                var command = parts[1];
44                encodedMessage = parts[2] || "";
45
46                var config = null;
47                if(command == "init"){
48                        var configParts = encodedMessage.split("&");
49                        config = {};
50                        for(var i = 0; i < configParts.length; i++){
51                                var nameValue = configParts[i].split("=");
52                                config[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
53                        }
54                }
55                return {command: command, message: encodedMessage, config: config};
56        }
57
58        //************** Init **************************
59        xipCurrentHash = "";
60       
61        //Decode the init params
62        var fragId = window.location.href.split("#")[1];
63        var config = unpackMessage(fragId).config;
64
65        xipStateId = config.id;
66        xipMasterFrame = parent.parent;
67
68        //Set up an HTML5 messaging publisher if postMessage exists.
69        //As of this writing, this is only useful to get Opera 9.25+ to work.
70        if(typeof document.postMessage != "undefined"){
71                callMaster = function(stateId, message){
72                        xipMasterFrame.document.postMessage(stateId + "#" + message);
73                }
74        }else{
75                var parts = config.callback.split(".");
76                xipCallbackObject = xipMasterFrame;
77                for(var i = 0; i < parts.length - 1; i++){
78                        xipCallbackObject = xipCallbackObject[parts[i]];
79                }
80                xipCallback = parts[parts.length - 1];
81
82                callMaster = function(stateId, message){
83                        xipCallbackObject[xipCallback](stateId + "#" + message);
84                }
85        }
86
87        //Call the master frame to let it know it is OK to start sending.
88        callMaster(xipStateId, "0:loaded");
89       
90        //Start counter to inspect hash value.
91        setInterval(pollHash, 10);
92
93        // -->
94        <!-- </script> -->
95</head>
96<body>
97        <h4>The Dojo Toolkit -- xip_client.html</h4>
98
99        <p>This file is used for Dojo's XMLHttpRequest Iframe Proxy. This is the "client" file used
100        internally by dojox.io.proxy.xip.</p>
101</body>
102</html>
Note: See TracBrowser for help on using the repository browser.