| | 138 | //Find out if the build result is already on the server. |
| | 139 | var cachedBuildUrl = getCachedBuildUrl(dependencyResult.depList); |
| | 140 | dojo.io.bind({ |
| | 141 | //Add an URL marker for the server to know if this is an existence query. |
| | 142 | //Mostly helpful in the Safari 2.0 case where it doesn't support HEAD |
| | 143 | //requests. This marker should be used to filter server logs when trying to find |
| | 144 | //download counts. |
| | 145 | url: cachedBuildUrl + "?query=exist", |
| | 146 | method: "HEAD", |
| | 147 | mimetype: "text/plain", |
| | 148 | handle: function(type, data, xhr, kwArgs){ |
| | 149 | var httpStatus = parseInt(xhr.status, 10); |
| | 150 | if(httpStatus >= 400){ |
| | 151 | //Build does not exist. Ask server to make it. |
| | 152 | requestServerBuild(dependencyResult); |
| | 153 | }else{ |
| | 154 | outputBuildResults(dependencyResult); |
| | 155 | window.location = "../" + cachedBuildUrl; |
| | 156 | } |
| | 157 | } |
| | 158 | }); |
| | 159 | } |
| | 160 | |
| | 161 | function requestServerBuild(dependencyResult){ |
| 130 | | depListForm.action = "../webbuild.php"; |
| 131 | | depListForm.depList.value = dependencyResult.depList.join(","); |
| 132 | | depListForm.provideList.value = dependencyResult.provideList && dependencyResult.provideList.length > 0 ? dependencyResult.provideList.join(",") : "null"; |
| 133 | | depListForm.version.value = version; |
| 134 | | depListForm.xdDojoUrl.value = xdDojoUrl; |
| 135 | | depListForm.doCompression.value = document.masterForm.doCompression[1].checked ? true : false; |
| 136 | | |
| | 163 | |
| | 164 | //Ask the server to build the result. |
| | 165 | dojo.io.bind({ |
| | 166 | url: "../webbuild.php", |
| | 167 | method: "POST", |
| | 168 | mimetype: "text/plain", |
| | 169 | content: { |
| | 170 | depList: dependencyResult.depList.join(","), |
| | 171 | provideList: (dependencyResult.provideList && dependencyResult.provideList.length > 0) ? dependencyResult.provideList.join(",") : "null", |
| | 172 | version: version, |
| | 173 | xdDojoUrl: xdDojoUrl |
| | 174 | }, |
| | 175 | handle: function(type, data, xhr, kwArgs){ |
| | 176 | if(type == "load" && dojo.string.trim(data).indexOf("OK") == 0){ |
| | 177 | outputBuildResults(dependencyResult); |
| | 178 | window.location = "../" + getCachedBuildUrl(dependencyResult.depList); |
| | 179 | }else{ |
| | 180 | alert("Build " + type + " [" + data + "]"); |
| | 181 | } |
| | 182 | } |
| | 183 | }); |
| | 184 | |
| | 185 | } |
| | 186 | |
| | 187 | function outputBuildResults(dependencyResult){ |