sel all metatags function set_meta() { var name = item_form.header.value; var text = tinyMCE.get("annotation").getContent().replace(/(<([^>]+)>)/ig," ").replace(/(\ )/ig," "); // Meta Title if(!meta_title_touched) item_form.meta_title.value = generate_title(meta_title_template, name, text); // Meta Keywords if(!meta_keywords_touched) item_form.meta_keywords.value = generate_keywords(meta_keywords_template, name, text); // Meta Description if(!meta_description_touched) item_form.meta_description.value = generate_description(meta_description_template, name, text); // Url if(!url_touched) item_form.url.value = generate_url(name); } function translit(url){ url = url.replace(/[\s]+/gi, '_'); return url.replace(/[^0-9a-zа-я_]+/gi, ''); } function autometageneration_init() { tinyMCE.get("annotation").onChange.add(set_meta); tinyMCE.get("annotation").onKeyUp.add(set_meta); var name = item_form.header.value; var text = tinyMCE.get("annotation").getContent().replace(/(<([^>]+)>)/ig," ").replace(/(\ )/ig," "); if(item_form.meta_title.value == '' || item_form.meta_title.value == generate_title(meta_title_template, name, text)) meta_title_touched=false; if(item_form.meta_keywords.value == '' || item_form.meta_keywords.value == generate_keywords(meta_keywords_template, name, text)) meta_keywords_touched=false; if(item_form.meta_description.value == '' || item_form.meta_description.value == generate_description(meta_description_template, name, text)) meta_description_touched=false; if(item_form.url.value == '' || item_form.url.value == generate_url(name)) url_touched=false; } // Attach events function myattachevent(target, eventName, func) { if ( target.addEventListener ) target.addEventListener(eventName, func, false); else if ( target.attachEvent ) target.attachEvent("on" + eventName, func); else target["on" + eventName] = func; } if (window.attachEvent) { window.attachEvent("onload", function(){setTimeout("autometageneration_init();", 1000)}); } else if (window.addEventListener) { window.addEventListener("DOMContentLoaded", autometageneration_init, false); } else { document.addEventListener("DOMContentLoaded", autometageneration_init, false); } myattachevent(item_form.url, 'change', function(){url_touched = true}); myattachevent(item_form.meta_title, 'change', function(){meta_title_touched = true}); myattachevent(item_form.meta_keywords, 'change', function(){meta_keywords_touched = true}); myattachevent(item_form.meta_description, 'change', function(){meta_description_touched = true}); myattachevent(item_form.header, 'keyup', set_meta); myattachevent(item_form.header, 'change', set_meta);