Sha256: d71444d7e3341440832ec23825fe82885996011ce5017d677f65d17c86b7fab7

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

function getJsonpCallback(url){
	var result = null;
	var idMatch = url.match(/jsonp=(.*?)(&|$)/);
	if(idMatch){
		result = idMatch[1];
	}else{
		//jsonp didn't match, so maybe it is the jsonCallback thing.
		idMatch = url.match(/callback=(.*?)(&|$)/);
		if(idMatch){
			result = idMatch[1];
		}
	}
	
	if(result){
		result = decodeURIComponent(result);
	}
	return result;
}

function findJsonpDone(){
	var result = false;
	var scriptUrls = getScriptUrls();
	
	for(var i = 0; i < scriptUrls.length; i++){
		var jsonp = getJsonpCallback(scriptUrls[i]);
		if(jsonp){
			eval(jsonp + "({animalType: 'mammal'});");
			result = true;
			break;
		}
	}
	return result;
}

function getScriptUrls(){
	//Get the script tags in the page to figure what state we are in.
	var scripts = document.getElementsByTagName('script');
	var scriptUrls = new Array();
	for(var i = 0; scripts && i < scripts.length; i++){
		var scriptTag = scripts[i];
		if(scriptTag.id.indexOf("dojoIoScript") == 0){
			scriptUrls.push(scriptTag.src);
		}
	}

	return scriptUrls;
}

function doJsonpCallback(){
	if(!findJsonpDone()){
		 alert('ERROR: Could not jsonp callback!');
	}
}

//Set a timeout to do the callback check, since MSIE won't see the SCRIPT tag until
//we complete processing of this page.
setTimeout(function(){doJsonpCallback();}, 300);

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
dojo_src-1.5.0 dojo/dojo/tests/io/scriptJsonp.js
dojo_src-1.4.3 dojo/dojo/tests/io/scriptJsonp.js
dojo_src-1.4.102 dojo/dojo/tests/io/scriptJsonp.js
dojo-pkg-1.132.0 data/dojo-release-1.3.2-src/dojo/tests/io/scriptJsonp.js
dojo-pkg-1.111.0 data/dojo-release-1.1.1-src/dojo/tests/io/scriptJsonp.js
dojo-pkg-1.120.0 data/dojo-release-1.2.0-src/dojo/tests/io/scriptJsonp.js
dojo-pkg-1.121.0 data/dojo-release-1.2.1-src/dojo/tests/io/scriptJsonp.js
dojo-pkg-1.122.0 data/dojo-release-1.2.2-src/dojo/tests/io/scriptJsonp.js
dojo-pkg-1.123.0 data/dojo-release-1.2.3-src/dojo/tests/io/scriptJsonp.js
dojo-pkg-1.130.0 data/dojo-release-1.3.0-src/dojo/tests/io/scriptJsonp.js
dojo-pkg-1.131.0 data/dojo-release-1.3.1-src/dojo/tests/io/scriptJsonp.js