Marvin JS Example to customize service

Back to index

The Clean2D webservice is not available at startup (its icon is missing from the toolbar). You have an input form where you can specify the location of the Clean2D webservice. As you apply the form, it disappears and the Clean2D service is registered to the sketcher with the given URL. After that, the Clean icon appears on the toolbar and you can perform clean operation on the drawn structure.

Clean operation can fail in the following cases:

Clean2D Webservice location:

Initialize the input form at startup. When the Apply Service button is submitted, the setServices function of the sketcher is called to apply the given service to the editor. The function expects a JavaScript object that describes one or more webservices. Finally, hide the input form to prevent applying further services.

			$(document).ready(function handleDocumentReady (e) {
			MarvinJSUtil.getEditor("#sketch").then(function (sketcherInstance) {
				marvinSketcherInstance = sketcherInstance;
			}, function () {
				alert("Cannot retrieve sketcher instance from iframe");

		function initControls () {
			$("#restoreButton").on("click", resetForm);
			$("#applyButton").on("click", function (e) {


		function resetForm() {

		function submitService(url) {
			var services = {
				"clean2dws" : (url == "") ? null : url
Back to index