/*
Elxis CMS - plugin Automatic Links
Created by Ioannis Sannos
Copyright (c) 2006-2025 elxis.org
https://www.elxis.org
*/

/* ADD AUTOLINKS CODE */
function addAutolinkCode() {
	var kwords = document.getElementById('autolink_keys').value;
	var pcode = '{autolinks}'+kwords+'{/autolinks}';
	addPluginCode(pcode);
}

function plugAutoLinksOnLoadInterface() {
	document.getElementById('pautolinksaddcode').addEventListener('click', function(e){
		e.preventDefault();
		addAutolinkCode();
	}, false);
}

if (document.getElementById('pautolinksaddcode')) {
	plugAutoLinksOnLoadInterface();
} else {
	if (document.readyState != 'loading') {
		plugAutoLinksOnLoadInterface();
	} else if (document.addEventListener) {
		document.addEventListener('DOMContentLoaded', function(){ plugAutoLinksOnLoadInterface(); });
	} else {
		document.attachEvent('onreadystatechange', function() { if (document.readyState == 'complete') { plugAutoLinksOnLoadInterface(); } });
	}
}
