we must not make json_request object global as it interferes with registered plugins from different windows

Example was tracker site config opened in an iframe, then stopped further et2_load responses to the main window
because it still used window object from the iframe and therefore could not find the node
This commit is contained in:
Ralf Becker 2021-06-18 11:09:53 +02:00
parent 5a209a00f0
commit 45758aaada

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel (as AT stylite.de) * @author Andreas Stöckel (as AT stylite.de)
* @author Ralf Becker <RalfBecker@outdoor-training.de> * @author Ralf Becker <RalfBecker@outdoor-training.de>
*/ */
@ -59,7 +59,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
* @param {object} _sender * @param {object} _sender
* @param {egw} _egw * @param {egw} _egw
*/ */
window.json_request = function(_menuaction, _parameters, _callback, _context, const json_request = function(_menuaction, _parameters, _callback, _context,
_async, _sender, _egw) _async, _sender, _egw)
{ {
// Copy the parameters // Copy the parameters
@ -105,7 +105,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
* @param {function} error option error callback(_msg) used instead our default this.error * @param {function} error option error callback(_msg) used instead our default this.error
* @param {int} reconnect timeout in ms (internal) * @param {int} reconnect timeout in ms (internal)
*/ */
window.json_request.prototype.openWebSocket = function(url, tokens, account_id, error, reconnect) json_request.prototype.openWebSocket = function(url, tokens, account_id, error, reconnect)
{ {
const min_reconnect_time = 1000; const min_reconnect_time = 1000;
const max_reconnect_time = 300000; const max_reconnect_time = 300000;
@ -193,7 +193,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
* *
* @return {jqXHR|boolean} jQuery jqXHR request object or for async==="keepalive" boolean is returned * @return {jqXHR|boolean} jQuery jqXHR request object or for async==="keepalive" boolean is returned
*/ */
window.json_request.prototype.sendRequest = function(async, method, error) json_request.prototype.sendRequest = function(async, method, error)
{ {
if(typeof async != "undefined") if(typeof async != "undefined")
{ {
@ -244,7 +244,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
* @param {XMLHTTP} _xmlhttp * @param {XMLHTTP} _xmlhttp
* @param {string} _err * @param {string} _err
*/ */
window.json_request.prototype.handleError = function(_xmlhttp, _err) { json_request.prototype.handleError = function(_xmlhttp, _err) {
// Don't error about an abort // Don't error about an abort
if(_err !== 'abort') if(_err !== 'abort')
{ {
@ -271,7 +271,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
} }
}; };
window.json_request.prototype.handleResponse = function(data) { json_request.prototype.handleResponse = function(data) {
if (data && typeof data.response != 'undefined') if (data && typeof data.response != 'undefined')
{ {
if (egw.preference('show_generation_time', 'common', false) == "1") if (egw.preference('show_generation_time', 'common', false) == "1")