<%@ page contentType="text/javascript;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/jdnevnik.tlb" prefix="jd" %> var shownOnce = false; function showHide(control) { if (document.getElementById(control).style.display == 'none') { document.getElementById(control).style.display = ''; if (control == 'advancedOptionsCell') { document.getElementById('titleCell').style.display='none'; document.getElementById('textCell').style.display='none'; document.getElementById('submitCell').style.display='none'; document.getElementById('titleCell').style.display='none'; document.getElementById('textCell').style.display='none'; document.getElementById('submitCell').style.display='none'; } else { document.getElementById('mainCell').style.marginRight="250px"; document.getElementById('mainCell').style.marginRight="250px"; document.getElementById('mainCell').style.width="500px"; document.getElementById('textCell').style.width=document.getElementById('mainCell').style.width; document.getElementById('titleCell').style.width="496px"; document.getElementById('submitCell').style.width=document.getElementById('mainCell').style.width; document.getElementById('text').style.width="455px"; document.getElementById('submitCell').getElementsByTagName("a")[0].innerHTML = ''; } if (!shownOnce) { if (document.onShowHideDefaults) onShowHideDefaults(); if (onShowHide) { onShowHide(); } shownOnce = true; } } else { document.getElementById(control).style.display = 'none'; if (control == 'advancedOptionsCell') { document.getElementById('titleCell').style.display=''; document.getElementById('textCell').style.display=''; document.getElementById('submitCell').style.display=''; document.getElementById('titleCell').style.display=''; document.getElementById('textCell').style.display=''; document.getElementById('submitCell').style.display=''; } else { document.getElementById('mainCell').style.marginRight="1px"; document.getElementById('mainCell').style.marginRight="1px"; document.getElementById('mainCell').style.width="720px"; document.getElementById('textCell').style.width="716px"; document.getElementById('titleCell').style.width="712px"; document.getElementById('submitCell').style.width=document.getElementById('textCell').style.width; document.getElementById('text').style.width="670px"; document.getElementById('submitCell').getElementsByTagName("a")[0].innerHTML = ''; } } return false; } function updateSectionsSelected(event, needAppendEvent) { if (!document.editForm.newCategory) { return; } var sections = ''; lists = document.getElementsByTagName("div"); for (j = lists.length - 1; j >= 0 ; j--) { if (lists[j].className == "category" && lists[j].childNodes[1].checked == true) sections += "; " + lists[j].childNodes[3].innerHTML; } if (document.editForm.newCategory.value != '') { sections += '; ' + document.editForm.newCategory.value; // if (needAppendEvent) { // var ch = window.event ? window.event.keyCode : event.which; // sections += String.fromCharCode(ch); // } } window.status = sections.substring(2); if (sections == '') { document.getElementById('categoriesList').value = ''; } else { document.getElementById('categoriesList').value = sections.substring(2); } } function hideOrShow(divThing) { var name = divThing.id.toLowerCase(); var value = document.editForm.__forFindAsYouType.value.toLowerCase(); var spanThing = divThing.childNodes[1].childNodes[2]; if (!spanThing) { spanThing = divThing.childNodes[3]; } if (value.length == 0) { divThing.style.display = "block"; spanThing.style.backgroundColor = "transparent"; return; } if (name.indexOf(value) != -1) { divThing.style.display = "block"; spanThing.style.backgroundColor = "#EEEEEE"; var parent = divThing.parentNode; while (parent.id.substring(0, 6) == "__ss__") { parent.style.display = "block"; parent = parent.parentNode; } } else { divThing.style.display = "none"; spanThing.style.backgroundColor = "transparent"; } } function selectOnlyThatTyped() { var lists = document.getElementsByTagName("div"); for (j = 0; j < lists.length; j++) { if (lists[j].name == "sectionRow" || lists[j].className == "category") hideOrShow(lists[j]); } } function addCategoryConfirmed(urlFirstPart) { if (document.editForm.newCategory.value == "") { return false; } document.getElementById('addCategorySection').src = urlFirstPart + '/?addsection§ions=' + document.editForm.newCategory.value; document.editForm.newCategory.value = ""; updateSectionsSelected(null, false); return false; } function addCategory(event, urlFirstPart) { if ((window.event && window.event.keyCode == 13) || (event && event.which == 13)) { return addCategoryConfirmed(urlFirstPart); } else { updateSectionsSelected(event, true); return true; } } function disableGoButton() { if (window.checkData) { checkData(); } if (document.getElementById("translationsSelect")) { saveTranslation(document.getElementById("translationsSelect").value); } document.getElementById('submitButton').value = ""; document.getElementById('submitButton').disabled = true; document.editForm.submit(); return true; } function setTypedCategory(option) { if (option.value == "~~~#new#~~~") { document.editForm.attribute_string_category.value=""; } else { document.editForm.attribute_string_category.value = option.value; } } function checkCommentData() { if (document.editForm.userLogin && document.editForm.userEmail && document.editForm.openid_url) { if (document.editForm.userLogin.value == "" && document.editForm.openid_url.value == "") { alert(""); return false; } } if (document.editForm.text) { if (document.editForm.text.value == "") { alert(""); return false; } } return true; } function openidSuccess() { document.editForm.submit(); } function openidFail() { alert(''); } function submitComment() { if (!checkCommentData()) { return; } if (document.getElementById("openid_url") && !document.getElementById("openid_url").value.match(/\s*/).length == 0) { document.getElementById("openidAJAX").src = '' + escape(document.getElementById("openid_url").value); } else { document.getElementById('submitButton').value = ''; document.getElementById('submitButton').disabled = true; document.editForm.submit(); } } function setFileNameIfEmpty(name) { if (document.editForm.title.value != "" && document.editForm.text.value != "") return; var parts = name.split(/[\/\\]/); var filename = parts[parts.length - 1]; var dotIndex = filename.indexOf("."); if (dotIndex == -1) dotIndex = filename.length(); if (document.editForm.title.value == "") document.editForm.title.value = filename.substring(0, dotIndex); if (document.editForm.text.value == "") document.editForm.text.value = filename.substring(0, dotIndex); } function getCurrentTranslation() { return "ru"; } function getAllPresentTranslations() { return ""; } /* Первый параметр - это строка "Новый язык", которая является подсказкой для окошка ввода языка. Второй - запрос "сохранить текущий текст как создаваемый перевод?" */ function possiblyNewTranslation(queryString, confirmString) { var saveThisAsNew = false; var editForm = document.editForm; if (document.getElementById("translationsSelect").value != "") { saveTranslation(document.getElementById("translationsSelect").value); } else if (editForm.text.value != "" || editForm.title.value != "") { saveThisAsNew = window.confirm(confirmString); } var language = window.prompt(queryString, ""); if (language == null || language == "") { return; } var translationsSelect = document.getElementById("translationsSelect"); var text = ""; var title = "" if (saveThisAsNew) { text = editForm.text.value; title = editForm.title.value; } if (!language.indexOf(' ') != -1) { translationsSelect.innerHTML += ''; editForm.innerHTML += ''; editForm.innerHTML += ''; } setTranslationLanguage(language); document.getElementById("translationsSelect").value = language; document.editForm.title.focus(); } var oldLanguage = null; function setTranslation() { var language = document.getElementById("translationsSelect").value; saveTranslation(language); setTranslationLanguage(language); } function saveTranslation(language) { if (oldLanguage != null) { var editForm = document.editForm; var text = editForm.text.value; var title = editForm.title.value; eval("editForm.attribute_string_translation_text_" + oldLanguage).value = text.replace(/\|/g, "####palka####").replace(/"/g, "####quote####"); eval("editForm.attribute_string_translation_title_" + oldLanguage).value = title.replace(/\|/g, "####palka####").replace(/"/g, "####quote####"); } } function setTranslationLanguage(language) { var editForm = document.editForm; if (eval("editForm.attribute_string_translation_text_" + language.replace(/\s/g, "_"))) { var text = eval("editForm.attribute_string_translation_text_" + language).value; var title = eval("editForm.attribute_string_translation_title_" + language).value; document.editForm.text.value = text.replace(/####quote####/g, "\"").replace(/####palka####/g, "|"); document.editForm.title.value = title.replace(/####quote####/g, "\"").replace(/####palka####/g, "|"); } oldLanguage = language; } function fillTranslations(translationsString, newTranslationString) { var defaultLanguage = ""; var defaultText = ""; var defaultTitle = ""; if (translationsString == "") { return; } var editForm = document.editForm; var translationsSelect = document.getElementById("translationsSelect"); var saveFunc = translationsSelect.onChange; translationsSelect.onChange = null; var translations = translationsString.split(/\|\|/g); for (var i = 0; i < translations.length; i++) { var translation = translations[i].split(/\|/g); var language = translation[0]; var title = translation[1]; var text = translation[2]; var optionText = '