-comments search, arrow keys on tips

This commit is contained in:
mrilyew 2024-10-22 15:18:57 +03:00
parent d165307993
commit 3d2036345b
9 changed files with 65 additions and 24 deletions

View file

@ -41,6 +41,21 @@ class Playlist extends MediaCollection
{ {
return $this->getRecord()->length; return $this->getRecord()->length;
} }
function fetchClassic(int $offset = 0, ?int $limit = NULL): \Traversable
{
$related = $this->getRecord()->related("$this->relTableName.collection")
->limit($limit ?? OPENVK_DEFAULT_PER_PAGE, $offset)
->order("index ASC");
foreach($related as $rel) {
$media = $rel->ref($this->entityTableName, "media");
if(!$media)
continue;
yield new $this->entityClassName($media);
}
}
function getAudios(int $offset = 0, ?int $limit = NULL, ?int $shuffleSeed = NULL): \Traversable function getAudios(int $offset = 0, ?int $limit = NULL, ?int $shuffleSeed = NULL): \Traversable
{ {

View file

@ -1,7 +1,7 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace openvk\Web\Presenters; namespace openvk\Web\Presenters;
use openvk\Web\Models\Entities\{User, Club}; use openvk\Web\Models\Entities\{User, Club};
use openvk\Web\Models\Repositories\{Users, Clubs, Posts, Comments, Videos, Applications, Audios}; use openvk\Web\Models\Repositories\{Users, Clubs, Posts, Videos, Applications, Audios};
use Chandler\Database\DatabaseConnection; use Chandler\Database\DatabaseConnection;
final class SearchPresenter extends OpenVKPresenter final class SearchPresenter extends OpenVKPresenter
@ -9,10 +9,8 @@ final class SearchPresenter extends OpenVKPresenter
private $users; private $users;
private $clubs; private $clubs;
private $posts; private $posts;
private $comments;
private $videos; private $videos;
private $apps; private $apps;
private $notes;
private $audios; private $audios;
function __construct() function __construct()
@ -20,7 +18,6 @@ final class SearchPresenter extends OpenVKPresenter
$this->users = new Users; $this->users = new Users;
$this->clubs = new Clubs; $this->clubs = new Clubs;
$this->posts = new Posts; $this->posts = new Posts;
$this->comments = new Comments;
$this->videos = new Videos; $this->videos = new Videos;
$this->apps = new Applications; $this->apps = new Applications;
$this->audios = new Audios; $this->audios = new Audios;
@ -45,7 +42,6 @@ final class SearchPresenter extends OpenVKPresenter
"groups" => "clubs", "groups" => "clubs",
"users" => "users", "users" => "users",
"posts" => "posts", "posts" => "posts",
"comments" => "comments",
"videos" => "videos", "videos" => "videos",
"audios" => "audios", "audios" => "audios",
"apps" => "apps", "apps" => "apps",

View file

@ -123,7 +123,6 @@
<option n:attr="selected => $_REQUEST['section'] == 'users'" value="users">{_s_by_people}</option> <option n:attr="selected => $_REQUEST['section'] == 'users'" value="users">{_s_by_people}</option>
<option n:attr="selected => $_REQUEST['section'] == 'groups'" value="groups">{_s_by_groups}</option> <option n:attr="selected => $_REQUEST['section'] == 'groups'" value="groups">{_s_by_groups}</option>
<option n:attr="selected => $_REQUEST['section'] == 'posts'" value="posts">{_s_by_posts}</option> <option n:attr="selected => $_REQUEST['section'] == 'posts'" value="posts">{_s_by_posts}</option>
<option n:attr="selected => $_REQUEST['section'] == 'comments'" value="comments">{_s_by_comments}</option>
<option n:attr="selected => $_REQUEST['section'] == 'videos'" value="videos">{_s_by_videos}</option> <option n:attr="selected => $_REQUEST['section'] == 'videos'" value="videos">{_s_by_videos}</option>
<option n:attr="selected => $_REQUEST['section'] == 'apps'" value="apps">{_s_by_apps}</option> <option n:attr="selected => $_REQUEST['section'] == 'apps'" value="apps">{_s_by_apps}</option>
<option n:attr="selected => $_REQUEST['section'] == 'audios'" value="audios">{_s_by_audios}</option> <option n:attr="selected => $_REQUEST['section'] == 'audios'" value="audios">{_s_by_audios}</option>

View file

@ -224,14 +224,6 @@
<script n:if='$count > 0 && !empty($query)'> <script n:if='$count > 0 && !empty($query)'>
highlightText({$query}, '.page_wrap_content_main', [".post:not(.comment) > tbody > tr > td > .post-content > .text .really_text"]) highlightText({$query}, '.page_wrap_content_main', [".post:not(.comment) > tbody > tr > td > .post-content > .text .really_text"])
</script> </script>
{elseif $section === 'comments'}
<div class='search_content' n:foreach="$data as $dat">
{include "../components/comment.xml", no_reply_button => true, comment => $dat, correctLink => true}
</div>
<script n:if='$count > 0 && !empty($query)'>
highlightText({$query}, '.page_wrap_content_main', [".text .really_text"])
</script>
{elseif $section === 'videos'} {elseif $section === 'videos'}
<div class='search_content' n:foreach="$data as $dat"> <div class='search_content' n:foreach="$data as $dat">
{include "../components/video.xml", video => $dat} {include "../components/video.xml", video => $dat}
@ -266,7 +258,6 @@
<a n:attr="id => $section === 'users' ? 'used'" href="/search?section=users&q={urlencode($query)}"> {_s_people}</a> <a n:attr="id => $section === 'users' ? 'used'" href="/search?section=users&q={urlencode($query)}"> {_s_people}</a>
<a n:attr="id => $section === 'groups' ? 'used'" href="/search?section=groups&q={urlencode($query)}"> {_s_groups}</a> <a n:attr="id => $section === 'groups' ? 'used'" href="/search?section=groups&q={urlencode($query)}"> {_s_groups}</a>
<a n:attr="id => $section === 'posts' ? 'used'" href="/search?section=posts&q={urlencode($query)}"> {_s_posts}</a> <a n:attr="id => $section === 'posts' ? 'used'" href="/search?section=posts&q={urlencode($query)}"> {_s_posts}</a>
<a n:attr="id => $section === 'comments' ? 'used'" href="/search?section=comments&q={urlencode($query)}"> {_s_comments}</a>
<a n:attr="id => $section === 'videos' ? 'used'" href="/search?section=videos&q={urlencode($query)}"> {_s_videos}</a> <a n:attr="id => $section === 'videos' ? 'used'" href="/search?section=videos&q={urlencode($query)}"> {_s_videos}</a>
<a n:attr="id => $section === 'apps' ? 'used'" href="/search?section=apps&q={urlencode($query)}"> {_s_apps}</a> <a n:attr="id => $section === 'apps' ? 'used'" href="/search?section=apps&q={urlencode($query)}"> {_s_apps}</a>
<a n:attr="id => $section === 'audios' ? 'used'" href="/search?section=audios&q={urlencode($query)}"> {_s_audios}</a> <a n:attr="id => $section === 'audios' ? 'used'" href="/search?section=audios&q={urlencode($query)}"> {_s_audios}</a>
@ -400,7 +391,7 @@
</label> </label>
<label> <label>
{_genre} {_genre}
<select name='genre' form="search_form"> <select name='genre' form="search_form" data-default='any'>
<option n:attr="selected: empty($_REQUEST['genre'])" value="any">{_s_any_single}</option> <option n:attr="selected: empty($_REQUEST['genre'])" value="any">{_s_any_single}</option>
<option n:foreach='\openvk\Web\Models\Entities\Audio::genres as $genre' n:attr="selected: $_REQUEST['genre'] == $genre" value="{$genre}"> <option n:foreach='\openvk\Web\Models\Entities\Audio::genres as $genre' n:attr="selected: $_REQUEST['genre'] == $genre" value="{$genre}">
{$genre} {$genre}

View file

@ -2564,7 +2564,7 @@ a.poll-retract-vote {
line-height: 12px; line-height: 12px;
} }
.header_navigation #search_box #searchBoxFastTips a:hover { .header_navigation #search_box #searchBoxFastTips a:hover, .header_navigation #search_box #searchBoxFastTips a:focus {
background: #f3f3f3; background: #f3f3f3;
} }

View file

@ -75,7 +75,7 @@ u(`#search_box input[type='search']`).on('input', async (e) => {
results = await fetch(`/method/video.search?auth_mechanism=roaming&q=${query}&count=10&sort=4&extended=1`) results = await fetch(`/method/video.search?auth_mechanism=roaming&q=${query}&count=10&sort=4&extended=1`)
break break
case 'audios_playlists': case 'audios_playlists':
results = await fetch(`/method/audio.searchAlbums?auth_mechanism=roaming&query=${query}&count=10`) results = await fetch(`/method/audio.searchAlbums?auth_mechanism=roaming&query=${query}&limit=10`)
break break
} }
@ -148,3 +148,43 @@ u(`#search_box input[type='search']`).on('input', async (e) => {
`) `)
}) })
}) })
u(document).on('keydown', `#search_box input[type='search'], #searchBoxFastTips a`, (e) => {
const u_tips = u('#searchBoxFastTips a')
if(u_tips.length < 1) {
return
}
const focused = u('#searchBoxFastTips a:focus').nodes[0]
// up
switch(e.keyCode) {
case 38:
e.preventDefault()
if(!focused) {
u_tips.nodes[0].focus()
return
}
if(focused.previousSibling) {
focused.previousSibling.focus()
}
break
// down
case 40:
e.preventDefault()
if(!focused) {
u_tips.nodes[0].focus()
return
}
if(focused.nextSibling) {
focused.nextSibling.focus()
} else {
u_tips.nodes[0].focus()
}
break
}
})

View file

@ -279,7 +279,7 @@ function OpenMiniature(e, photo, post, photo_id, type = "post") {
tempDetailsSection[index] = element.innerHTML; tempDetailsSection[index] = element.innerHTML;
if(index == imagesIndex) { if(index == imagesIndex) {
u(".ovk-photo-details").last().innerHTML = element.innerHTML; u(".ovk-photo-details").last().innerHTML = element.innerHTML ?? '';
} }
document.querySelectorAll(".ovk-photo-details .bsdn").forEach(bsdnInitElement) document.querySelectorAll(".ovk-photo-details .bsdn").forEach(bsdnInitElement)

View file

@ -641,7 +641,7 @@
"apply_style_for_this_device" = "Apply style only for this device"; "apply_style_for_this_device" = "Apply style only for this device";
"search_for_groups" = "Search for groups"; "search_for_groups" = "Search for groups";
"search_for_users" = "Search for people"; "search_for_users" = "Search for users";
"search_for_posts" = "Search for posts"; "search_for_posts" = "Search for posts";
"search_for_comments" = "Search for comments"; "search_for_comments" = "Search for comments";
"search_for_videos" = "Search for videos"; "search_for_videos" = "Search for videos";
@ -1993,7 +1993,7 @@
/* Search */ /* Search */
"s_people" = "People"; "s_people" = "Users";
"s_groups" = "Clubs"; "s_groups" = "Clubs";
"s_apps" = "Applications"; "s_apps" = "Applications";
"s_posts" = "Posts"; "s_posts" = "Posts";
@ -2002,7 +2002,7 @@
"s_audios" = "Music"; "s_audios" = "Music";
"s_audios_playlists" = "Playlists"; "s_audios_playlists" = "Playlists";
"s_by_people" = "for people"; "s_by_people" = "for users";
"s_by_groups" = "for groups"; "s_by_groups" = "for groups";
"s_by_posts" = "for posts"; "s_by_posts" = "for posts";
"s_by_comments" = "for comments"; "s_by_comments" = "for comments";

View file

@ -1883,7 +1883,7 @@
/* Search */ /* Search */
"s_people" = "Люди"; "s_people" = "Пользователи";
"s_groups" = "Группы"; "s_groups" = "Группы";
"s_apps" = "Приложения"; "s_apps" = "Приложения";
"s_posts" = "Записи"; "s_posts" = "Записи";
@ -1892,7 +1892,7 @@
"s_audios" = "Аудио"; "s_audios" = "Аудио";
"s_audios_playlists" = "Плейлисты"; "s_audios_playlists" = "Плейлисты";
"s_by_people" = "по людям"; "s_by_people" = "по пользователям";
"s_by_groups" = "по группам"; "s_by_groups" = "по группам";
"s_by_posts" = "по записям"; "s_by_posts" = "по записям";
"s_by_comments" = "по комментариям"; "s_by_comments" = "по комментариям";