JSFiddle - React, Tailwind, and code Playground

by John Doe

HTML

<input class="" name="Irszam" type="text">

JavaScript

function PostCode(config) {
	this.cache = {};
	var $this = this;
	this.lastPostCode = 0;
	this.prefix = '';
	if (config.manualInputId) {
		this.postCodeInput = config.postCodeInput;
		this.postCodeSignInput = config.postCodeSignInput;
		this.cityInput = config.cityInput;
	} else if (config.inputName && config.inputName.indexOf("Irszam") > -1) {
		var prefix = config.inputName.substr(0, config.inputName.indexOf("Irszam"));
		this.postCodeInput = prefix + "Irszam";
		this.postCodeSignInput = prefix + "IrszamJel";
		this.cityInput = prefix + "Helyseg";
		this.prefix = prefix;
	} else if (config.prefix) {
		this.postCodeInput = config.prefix + "Irszam";
		this.postCodeSignInput = config.prefix + "IrszamJel";
		this.cityInput = config.prefix + "Helyseg";
		this.prefix = config.prefix;
	} else {
		return {};
	}
	if (config.kozterulet) {
		this.kozterulet = config.kozterulet;
	}
	if (config.ktid) {
		this.ktid = config.ktid;
	}
	this.ktidLoad = true;

	this.postCodeInputObject = $("#" + this.postCodeInput);


	this.postCodeSignInputObject = $("#" + this.postCodeSignInput);
	if (this.postCodeSignInputObject.length == 0) {
		this.postCodeSignInputObject = $('<input>').attr({
			type: 'hidden',
			id: this.postCodeSignInput,
			name: this.postCodeSignInput
		}).insertAfter(this.postCodeInputObject);
	}

	this.cityInputObject = $("#" + this.cityInput);
	if (this.cityInputObject.length == 0) {
		this.cityInputObject = $('<select/>').attr({
			id: this.cityInput,
			name: this.cityInput
		}).insertAfter(this.postCodeInputObject);
	}

	this.cityWrapperObject = $("<div style='display:inline'></div>");
	this.cityWrapperObject.insertBefore(this.cityInputObject);
	this.cityInputObject.appendTo(this.cityWrapperObject);
	this.cityWrapperSpan = $("<span></span>").appendTo(this.cityWrapperObject);

	this.processData = function (data, first) {
		var postCodeSign = null;
		if (first) {
			postCodeSign = $this.postCodeSignInputObject.val();
		}
		$this.cityInputObject.empty();
		if...