/*
Elxis CMS - plugin video
*/

function videoOnLoadInterface() {
	let pvlinks = document.querySelectorAll('a[data-plgvidfile]');//works on both articles and categories
	if (pvlinks.length > 0) {
		for (let z=0; z < pvlinks.length; z++) {
			pvlinks[z].addEventListener('click', function(e){
				let vfile = this.getAttribute('data-plgvidfile');
				e.preventDefault();
				addPluginCode('{video}'+vfile+'{/video}');
			}, false);
		}
	}
}

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