Update loaders and add avtopodgruzka postov

This commit is contained in:
lalka2016 2023-08-06 22:36:09 +03:00
parent 9ff4ff4b4b
commit be85edf4c2
5 changed files with 65 additions and 11 deletions

View file

@ -12,15 +12,18 @@
{include "../components/error.xml", title => "", description => $type == "my" ? tr("no_suggested_posts_by_you") : tr("no_suggested_posts_by_people")}
{else}
<h4 id="cound">{if $type == "my"}{tr("suggested_posts_in_group_by_you", $count)}{else}{tr("suggested_posts_in_group", $count)}{/if}</h4>
{foreach $posts as $post}
{include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true}
{/foreach}
<div id="postz">
{foreach $posts as $post}
{include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true}
{/foreach}
{include "../components/paginator.xml", conf => (object) [
"page" => $page,
"count" => $count,
"amount" => sizeof($posts),
"perPage" => OPENVK_DEFAULT_PER_PAGE,
"atBottom" => true,
]}
</div>
{/if}
{include "../components/paginator.xml", conf => (object) [
"page" => $page,
"count" => $count,
"amount" => sizeof($posts),
"perPage" => OPENVK_DEFAULT_PER_PAGE,
"atBottom" => true,
]}
{/block}

View file

@ -2714,3 +2714,8 @@ body.article .floating_sidebar, body.article .page_content {
.suggestionControls {
text-align: center;
}
.button.loaded {
background: #595959 url("/assets/packages/static/openvk/img/loading_mini.gif") no-repeat 50% 50%;
padding: 16px 40px 6px 4px;
}

View file

@ -277,6 +277,9 @@ $(document).on("click", "#publish_post", async (e) => {
let post;
try {
e.currentTarget.classList.add("loaded")
e.currentTarget.setAttribute("value", "")
e.currentTarget.setAttribute("id", "")
post = await API.Wall.acceptPost(id, document.getElementById("signatr").checked, document.getElementById("pooblish").value)
} catch(ex) {
switch(ex.code) {
@ -297,12 +300,19 @@ $(document).on("click", "#publish_post", async (e) => {
break;
}
e.currentTarget.setAttribute("value", tr("publish_suggested"))
e.currentTarget.classList.remove("loaded")
e.currentTarget.setAttribute("id", "publish_post")
return 0;
}
NewNotification(tr("suggestion_succefully_published"), tr("suggestion_press_to_go"), null, () => {window.location.assign("/wall" + post.id)});
document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post.new_count)
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
if(document.querySelectorAll(".post.post-divider").length < 1 && post.new_count > 0) {
loadMoreSuggestedPosts()
}
}), Function.noop]);
document.getElementById("pooblish").innerHTML = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector(".really_text").innerHTML.replace(/(<([^>]+)>)/gi, '')
@ -314,7 +324,9 @@ $(document).on("click", "#decline_post", async (e) => {
let post;
try {
e.currentTarget.parentNode.parentNode.insertAdjacentHTML("afterbegin", `<img id="deleteMe" src="/assets/packages/static/openvk/img/loading_mini.gif">`)
e.currentTarget.classList.add("loaded")
e.currentTarget.setAttribute("value", "")
e.currentTarget.setAttribute("id", "")
post = await API.Wall.declinePost(id)
} catch(ex) {
switch(ex.code) {
@ -335,6 +347,9 @@ $(document).on("click", "#decline_post", async (e) => {
break;
}
e.currentTarget.setAttribute("value", tr("decline_suggested"))
e.currentTarget.setAttribute("id", "decline_post")
e.currentTarget.classList.remove("loaded")
return 0;
} finally {
u("#deleteMe").remove()
@ -343,4 +358,31 @@ $(document).on("click", "#decline_post", async (e) => {
NewNotification(tr("suggestion_succefully_declined"), "", null);
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post)
if(document.querySelectorAll(".post.post-divider").length < 1 && post > 0) {
loadMoreSuggestedPosts()
}
})
function loadMoreSuggestedPosts()
{
let xhr = new XMLHttpRequest
xhr.open("GET", location.href)
xhr.onloadstart = () => {
document.getElementById("postz").innerHTML = `<img src="/assets/packages/static/openvk/img/loading_mini.gif">`
}
xhr.onload = () => {
let parser = new DOMParser()
let body = parser.parseFromString(xhr.responseText, "text/html").getElementById("postz")
document.getElementById("postz").innerHTML = body.innerHTML
}
xhr.onerror = () => {
document.getElementById("postz").innerHTML = tr("error_loading_suggest")
}
xhr.send()
}

View file

@ -326,6 +326,8 @@
"publish_suggested" = "Accept";
"decline_suggested" = "Decline";
"error_loading_suggest" = "Error when loading new posts";
"publishing_suggested_post" = "Publishing suggested post";
"suggested_posts_in_group_zero" = "You've looked at all the suggested posts, congratulations!";
"suggested_posts_in_group_one" = "This group has one suggested post";

View file

@ -310,6 +310,8 @@
"publish_suggested" = "Опубликовать запись";
"decline_suggested" = "Отклонить";
"error_loading_suggest" = "Не удалось подгрузить новые посты";
"publishing_suggested_post" = "Публикация предложенной записи";
"suggested_posts_in_group_zero" = "Вы посмотрели всю предложку, поздравляю!";
"suggested_posts_in_group_one" = "В эту группу предложили одну запись";