function expand_wall_textarea(id) { var el = document.getElementById('post-buttons'+id); var wi = document.getElementById('wall-post-input'+id); el.style.display = "block"; wi.className = "expanded-textarea"; } function expand_comment_textarea(id) { var el = document.getElementById('commentTextArea'+id); var wi = document.getElementById('wall-post-input'+id); el.style.display = "block"; wi.focus(); } function edit_post(id, wid) { var el = document.getElementById(`text${id}_${wid}`); var ed = document.getElementById(`text_edit${id}_${wid}`); if (el.style.display == "none") { el.style.display = "block"; ed.style.display = "none"; } else { el.style.display = "none"; ed.style.display = "block"; } } function hidePanel(panel, count = 0) { $(panel).toggleClass("content_title_expanded content_title_unexpanded"); $(panel).next('div').slideToggle(300); if(count != 0){ if($(panel).hasClass("content_title_expanded")) $(panel).html($(panel).html().replaceAll(" ("+count+")", "")); else $(panel).html($(panel).html() + " ("+count+")"); } } function parseAjaxResponse(responseString) { try { const response = JSON.parse(responseString); if(response.flash) NewNotification(response.flash.title, response.flash.message || "", null); return response.success || false; } catch(error) { if(responseString === "Хакеры? Интересно...") { location.reload(); return false; } else { throw error; } } } function toggleMenu(id) { if($(`#post-buttons${id} #wallAttachmentMenu`).is('.hidden')) { $(`#post-buttons${id} #wallAttachmentMenu`).css({ opacity: 0 }); $(`#post-buttons${id} #wallAttachmentMenu`).toggleClass('hidden').fadeTo(250, 1); } else { $(`#post-buttons${id} #wallAttachmentMenu`).fadeTo(250, 0, function () { $(this).toggleClass('hidden'); }); } } document.addEventListener("DOMContentLoaded", function() { //BEGIN u("#_photoDelete").on("click", function(e) { var formHtml = "
"; u("body").append(formHtml); MessageBox(tr('warning'), tr('question_confirm'), [ tr('yes'), tr('no') ], [ (function() { u("#tmpPhDelF").nodes[0].submit(); }), (function() { u("#tmpPhDelF").remove(); }), ]); return e.preventDefault(); }); /* @rem-pai why this func wasn't named as "#_deleteDialog"? It looks universal IMO */ u("#_noteDelete").on("click", function(e) { var formHtml = ""; u("body").append(formHtml); MessageBox(tr('warning'), tr('question_confirm'), [ tr('yes'), tr('no') ], [ (function() { u("#tmpPhDelF").nodes[0].submit(); }), (function() { u("#tmpPhDelF").remove(); }), ]); return e.preventDefault(); }); u("#_pinGroup").on("click", async function(e) { e.preventDefault(); let link = u(this).attr("href"); let thisButton = u(this); let groupName = u(this).attr("data-group-name"); let groupUrl = u(this).attr("data-group-url"); let list = u('#_groupListPinnedGroups'); thisButton.nodes[0].classList.add('loading'); thisButton.nodes[0].classList.add('disable'); let req = await ky(link); if(req.ok == false) { NewNotification(tr('error'), tr('error_1'), null); thisButton.nodes[0].classList.remove('loading'); thisButton.nodes[0].classList.remove('disable'); return; } if(!parseAjaxResponse(await req.text())) { thisButton.nodes[0].classList.remove('loading'); thisButton.nodes[0].classList.remove('disable'); return; } // Adding a divider if not already there if(list.nodes[0].children.length == 0) { list.nodes[0].append(u('').first()); } // Changing the button name if(thisButton.html().trim() == tr('remove_from_left_menu')) { thisButton.html(tr('add_to_left_menu')); for(let i = 0; i < list.nodes[0].children.length; i++) { let element = list.nodes[0].children[i]; if(element.pathname == groupUrl) { element.remove(); } } }else{ thisButton.html(tr('remove_from_left_menu')); list.nodes[0].append(u('' + groupName + '').first()); } // Adding the group to the left group list if(list.nodes[0].children[0].className != "menu_divider" || list.nodes[0].children.length == 1) { list.nodes[0].children[0].remove(); } thisButton.nodes[0].classList.remove('loading'); thisButton.nodes[0].classList.remove('disable'); return false; }); }); //END ONREADY DECLS async function repostPost(id, hash) { uRepostMsgTxt = ` ${tr('auditory')}:${groupStrings == true ? tr('groups_avatar') : tr('friends_avatar')}
${tr('formats_avatar')}
${tr('troubles_avatar')}
${tr("deleting_avatar_sure")}
` let msg = MessageBox(tr('deleting_avatar'), body, [ tr('yes'), tr('cancel') ], [ (function() { let xhr = new XMLHttpRequest(); xhr.open("POST", "/photo"+avatar+"/delete") xhr.onload = () => { //не люблю формы NewNotification(tr("deleted_avatar_notification"), ""); location.reload() } xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.send("hash="+u("meta[name=csrf]").attr("value")) }), (function() { u("#tmpPhDelF").remove(); }), ]); } function expandSearch() { // console.log("search expanded") let els = document.querySelectorAll("div.dec") for(const element of els) { element.style.display = "none" } document.querySelector(".whatFind").style.display = "block"; document.querySelector(".whatFind").style.marginRight = "-80px"; document.getElementById("searchInput").style.width = "627px"; document.getElementById("searchInput").style.background = "none"; document.getElementById("searchInput").style.backgroundColor = "#fff"; document.getElementById("searchInput").style.paddingLeft = "6px"; srch.classList.add("nodivider") } async function decreaseSearch() { // чтобы люди успели выбрать что искать и поиск не скрывался сразу await new Promise(r => setTimeout(r, 4000)); // console.log("search decreased") if(document.activeElement !== searchInput && document.activeElement !== typer) { srcht.setAttribute("hidden", "hidden") document.getElementById("searchInput").style.background = "url('/assets/packages/static/openvk/img/search_icon.png') no-repeat 3px 4px"; document.getElementById("searchInput").style.backgroundColor = "#fff"; document.getElementById("searchInput").style.paddingLeft = "18px"; document.getElementById("searchInput").style.width = "120px"; document.querySelector(".whatFind").style.display = "none"; await new Promise(r => setTimeout(r, 300)); srch.classList.remove("nodivider") let els = document.querySelectorAll("div.dec") for(const element of els) { element.style.display = "inline-block" } } } function hideParams(name) { $("#s_"+name).slideToggle(250, "swing"); if($(`#n_${name} img`).attr("src") == "/assets/packages/static/openvk/img/hide.png") { $("#n_"+name+" img").attr("src", "/assets/packages/static/openvk/img/show.png"); } else { $("#n_"+name+" img").attr("src", "/assets/packages/static/openvk/img/hide.png"); } } function resetSearch() { let inputs = document.querySelectorAll("input") let selects = document.querySelectorAll("select") for(const input of inputs) { if(input != dnt && input != gend && input != gend1 && input != gend2) { input.value = "" } } for(const select of selects) { if(select != sortyor && select != document.querySelector(".whatFind")) { select.value = 0 } } } async function checkSearchTips() { let query = searchInput.value; await new Promise(r => setTimeout(r, 1000)); let type = typer.value; let smt = type == "users" || type == "groups" || type == "videos"; if(query.length > 3 && query == searchInput.value && smt) { srcht.removeAttribute("hidden") let etype = type try { let results = await API.Search.fastSearch(escapeHtml(query), etype) srchrr.innerHTML = "" for(const el of results["items"]) { srchrr.insertAdjacentHTML("beforeend", `${escapeHtml(el.name)}
${escapeHtml(el.description)}