NewTicketWizardServiceForm.js 1.38 KB
/**
 * NewTicketWizard module - SeTIC - UFSC - http://setic.ufsc.br/
 * Rodrigo Gonçalves - rodrigo.g@ufsc.br
 * 
 * Version 2017-12-19 - Conversion to JS Module, to support OTRS 6
 * 
 * 
 */

var Core = Core || {};
Core.Agent = Core.Agent || {};
Core.Agent.Admin = Core.Agent.Admin || {};

Core.Agent.Admin.NewTicketWizardServiceForm = (function (TargetNS) {
	TargetNS.mostraEsconde = function(id) {
		idJSON = "#json" + id + "Dlg";
		id = "#" + id;
		$(idJSON).toggle();
		$(idJSON).width($(id).width());
	}
	
	
	
	TargetNS.Init  = function() {
		$("#jsonFormUIDlg").toggle();
		$("#jsonSchemaDlg").toggle();
		$("#jsonCustomPropsDlg").toggle();
		
		setInterval(function() {
			var code = $("#CustomProps").val();
			$("#jsCode").html(code);
			$("#jsCode").chili();			
		}, 1000);
		
		
		setInterval(function() {
			var json = "{" + $("#Schema").val() + "}";
			try {
				json = JSON.parse(json);
				$("#jsonSchema").JSONView(json);
			} catch(err) {
				$("#jsonSchema").JSONView({error: "Invalid JSON!"});
			}
		}, 1000);
		
		setInterval(function() {
			var json = "{" + $("#FormUI").val() + "}";
			try {
				json = JSON.parse(json);
				$("#jsonForm").JSONView(json);
			} catch(err) {
				$("#jsonForm").JSONView({error: "Invalid JSON!"});
			}
		}, 1000);
	}
	
	Core.Init.RegisterNamespace(TargetNS, 'APP_MODULE');
	
	return TargetNS;
	
	
}(Core.Agent.Admin.NewTicketWizardServiceForm || {}));