src/main/java/de/ipb_halle/molecularfaces/component/molplugin/MarvinJSRenderer.java
/**
	 * Encodes the JavaScript part of the plugin editor into the writer.
	 * <p>
	 * Note: Different components of this plugin type will use one and the same
	 * JavaScript variable, which will be overwritten in case it already exists.
	 * 
	 * @param context
	 * @param writer
	 * @param plugin
	 * @param iframeId      DOM id of the &lt;iframe&gt; element
	 * @param hiddenInputId DOM id of the hidden &lt;input&gt; element
	 */
Encodes the JavaScript part of the plugin editor into the writer.

Note: Different components of this plugin type will use one and the same
JavaScript variable, which will be overwritten in case it already exists.


Encodes the JavaScript part of the plugin editor into the writer . Note : Different components of this plugin type will use one and the same JavaScript variable which will be overwritten in case it already exists .
private void encodeEditorJS(FacesContext context, ResponseWriter writer, MolPluginCore plugin, String iframeId,
			String hiddenInputId) throws IOException {
		writer.startElement("script", plugin);
		writer.writeAttribute("type", "text/javascript", null);
		String installPath = webXml.getContextParam(MarvinJSComponent.WEBXML_MARVINJS_BASE_URL, context, "");
		String license = webXml.getContextParam(MarvinJSComponent.WEBXML_MARVINJS_LICENSE_URL, context, "");
		StringBuilder sb = new StringBuilder(512 + installPath.length() + license.length());
		sb.append(plugin.getResourceLoader().encodeLoadExtResources(loaderJSVar));
		Formatter fmt = new Formatter(sb);
		String widgetVar = plugin.getWidgetVar();
		if ((widgetVar != null) && (!widgetVar.isEmpty())) {
			fmt.format("var %s = ", widgetVar);
		}
		fmt.format("%s.status().then(() => {", loaderJSVar);
		fmt.format("let editorPromise = molecularfaces.MarvinJSEditor"
				+ ".newEditor(\"%s\", document.getElementById(\"%s\").getAttribute(\"value\"), \"%s\", \"%s\", %d, %d, \"%s\");",
				iframeId, hiddenInputId, installPath, license, plugin.getHeight(), plugin.getWidth(),
				plugin.getFormat());
		/*
		 * Register an on-change callback to fill the value of the hidden <input>
		 * element.
		 */
		fmt.format("editorPromise.then(editor => "
				+ "editor.getOnChangeSubject().addChangeCallback((mol) => { "
				+ "document.getElementById(\"%s\").setAttribute(\"value\", mol); }));",
				hiddenInputId);
		fmt.close();
		sb.append("return editorPromise;");
		sb.append("});");
		writer.writeText(sb, null);
		writer.endElement("script");
	}
private void encodeEditorJS ( FacesContext context , ResponseWriter writer , MolPluginCore plugin , String iframeId , String hiddenInputId ) throws IOException { writer . startElement ( "script" , plugin ) ; writer . writeAttribute ( "type" , "text/javascript" , null ) ; String installPath = webXml . getContextParam ( MarvinJSComponent . WEBXML_MARVINJS_BASE_URL , context , "" ) ; String license = webXml . getContextParam ( MarvinJSComponent . WEBXML_MARVINJS_LICENSE_URL , context , "" ) ; StringBuilder sb = new StringBuilder ( 512 + installPath . length ( ) + license . length ( ) ) ; sb . append ( plugin . getResourceLoader ( ) . encodeLoadExtResources ( loaderJSVar ) ) ; Formatter fmt = new Formatter ( sb ) ; String widgetVar = plugin . getWidgetVar ( ) ; if ( ( widgetVar != null ) && ( ! widgetVar . isEmpty ( ) ) ) { fmt . format ( "var %s = " , widgetVar ) ; } fmt . format ( "%s.status().then(() => {" , loaderJSVar ) ; fmt . format ( "let editorPromise = molecularfaces.MarvinJSEditor" + ".newEditor(\"%s\", document.getElementById(\"%s\").getAttribute(\"value\"), \"%s\", \"%s\", %d, %d, \"%s\");" , iframeId , hiddenInputId , installPath , license , plugin . getHeight ( ) , plugin . getWidth ( ) , plugin . getFormat ( ) ) ; /*
		 * Register an on-change callback to fill the value of the hidden <input>
		 * element.
		 */ fmt . format ( "editorPromise.then(editor => " + "editor.getOnChangeSubject().addChangeCallback((mol) => { " + "document.getElementById(\"%s\").setAttribute(\"value\", mol); }));" , hiddenInputId ) ; fmt . close ( ) ; sb . append ( "return editorPromise;" ) ; sb . append ( "});" ) ; writer . writeText ( sb , null ) ; writer . endElement ( "script" ) ; }
Encodes the JavaScript part of the plugin editor into the writer.
Encodes the JavaScript part of the plugin editor into the writer .
// resource loading // Register a JS variable if required. // after resource loading finished // Start editor, set the molecule from the hidden <input> element's value. // Return the editor object embedded in another Promise that is written into widgetVar. // end of then() block of the ResourcesLoader's Promise