/**
* windowName transport plugin 0.9.1 for jQuery
*
* Thanks to Kris Zyp
* for the original idea and some code. Original BSD license below.
*
* Licensed under GPLv3: http://www.gnu.org/licenses/gpl-3.0.txt
* @author Marko Mrdjenovic
*
**/
/*
Copyright (c) 2004-2008, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/license
*/
(function ($) {
$ = $ || window.jQuery;
var origAjax = $.ajax, idx = 0;
$.extend({
ajax: function (s) {
var remote = /^(?:\w+:)?\/\/([^\/?#]+)/,
data = '', status = '', requestDone = false,
xhr = null, type = s.type.toUpperCase(), ival = setTimeout(function () {}, 0),
onreadystatechange = null, success = null, complete = null,
localdom = remote.exec(s.url);
if (s.windowname || (type === 'POST' && localdom && localdom[1] !== location.host)) {
xhr = function () {
var url = '',
frameName = '',
defaultName = 'jQuery.windowName.transport.frame',
wnival = setTimeout(function () {}, 0),
frame = null, form = null,
u = {};
function cleanup() {
clearTimeout(wnival);
try {
delete window.jQueryWindowName[frameName];
} catch (er) {
window.jQueryWindowName[frameName] = function () {};
}
setTimeout(function () {
$(frame).remove();
$(form).remove();
}, 100);
}
function setData() {
try {
var data = frame.contentWindow.name;
if (typeof data === 'string') {
if (data === defaultName) {
u.status = 501;
u.statusText = 'Not Implemented';
} else {
u.status = 200;
u.statusText = 'OK';
u.responseText = data;
}
u.readyState = 4; // we are done now
u.onreadystatechange();
cleanup();
}
} catch (er) {}
}
u = {
abort: function () {
cleanup();
},
getAllResponseHeaders: function () {
return '';
},
getResponseHeader: function (key) {
return '';
},
open: function (m, u) {
url = u;
this.readyState = 1;
this.onreadystatechange();
},
send: function (data) {
if (data.indexOf('windowname=') < 0) { // tell the server we want windowname transport
data += (data === ''? '' : '&') + 'windowname=' + (s.windowname || 'true');
}
// prepare frame
frameName = "jQueryWindowName" + ('' + Math.random()).substr(2, 8);
window.jQueryWindowName = window.jQueryWindowName || {};
window.jQueryWindowName[frameName] = function () {};
var fmethod = null, faction = null, ftarget = null, fsubmit = null,
local = window.location.href.substr(0, window.location.href.indexOf('/', 8)),
locallist = ['/robots.txt', '/crossdomain.xml'];
form = document.createElement('form');
if ($.browser.msie) {
try {
frame = document.createElement('