2015-01-23 20:32:32 +01:00
|
|
|
/**
|
|
|
|
* EGroupware eTemplate2 - JS widget class containing javascript
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
2021-06-07 17:33:53 +02:00
|
|
|
* @link https://www.egroupware.org
|
2015-01-23 20:32:32 +01:00
|
|
|
* @author Ralf Becker
|
|
|
|
*/
|
|
|
|
/*egw:uses
|
2020-02-13 10:25:00 +01:00
|
|
|
et2_core_widget;
|
2015-01-23 20:32:32 +01:00
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
import { et2_register_widget } from "./et2_core_widget";
|
|
|
|
import { et2_widget } from "./et2_core_widget";
|
2015-01-23 20:32:32 +01:00
|
|
|
/**
|
|
|
|
* Function which executes the encapsulated script data.
|
|
|
|
*
|
|
|
|
* This should only be used for customization and NOT for regular EGroupware code!
|
|
|
|
*
|
2021-06-07 17:33:53 +02:00
|
|
|
* We can NOT create a script tag containing the content, as this violates our CSP policy!
|
2015-01-23 20:32:32 +01:00
|
|
|
*
|
|
|
|
* We use new Function(_content) instead. Therefore you have to use window to address global context:
|
|
|
|
*
|
|
|
|
* window.some_func = function() {...}
|
|
|
|
*
|
|
|
|
* instead of not working
|
|
|
|
*
|
|
|
|
* function some_funct() {...}
|
|
|
|
*
|
|
|
|
* @augments et2_widget
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
export class et2_script extends et2_widget {
|
|
|
|
constructor(_parent, _attrs, _child) {
|
|
|
|
super();
|
2020-02-13 10:25:00 +01:00
|
|
|
// Allow no child widgets
|
2021-06-07 17:33:53 +02:00
|
|
|
this.supportedWidgetClasses = [];
|
2020-02-13 10:25:00 +01:00
|
|
|
}
|
|
|
|
;
|
|
|
|
/**
|
|
|
|
* We can NOT create a script tag containing the content, as this violoates our CSP policy!
|
|
|
|
*
|
|
|
|
* @param {string} _content
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
loadContent(_content) {
|
2020-02-13 10:25:00 +01:00
|
|
|
try {
|
|
|
|
var func = new Function(_content);
|
|
|
|
func.call(window);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
this.egw.debug('error', 'Error while executing script: ', _content, e);
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
et2_register_widget(et2_script, ["script"]);
|
2020-02-13 10:25:00 +01:00
|
|
|
//# sourceMappingURL=et2_widget_script.js.map
|