mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
rewrite a lot
This commit is contained in:
parent
492008d617
commit
bc78cc1875
15 changed files with 319 additions and 272 deletions
|
@ -206,6 +206,9 @@ final class Wall extends VKAPIRequestHandler
|
||||||
if($post->isDeactivationMessage())
|
if($post->isDeactivationMessage())
|
||||||
$post_temp_obj->final_post = 1;
|
$post_temp_obj->final_post = 1;
|
||||||
|
|
||||||
|
if($post->getGeo())
|
||||||
|
$post_temp_obj->geo = $post->getVkApiGeo();
|
||||||
|
|
||||||
$items[] = $post_temp_obj;
|
$items[] = $post_temp_obj;
|
||||||
|
|
||||||
if ($from_id > 0)
|
if ($from_id > 0)
|
||||||
|
@ -321,14 +324,10 @@ final class Wall extends VKAPIRequestHandler
|
||||||
} else if ($attachment instanceof \openvk\Web\Models\Entities\Video) {
|
} else if ($attachment instanceof \openvk\Web\Models\Entities\Video) {
|
||||||
$attachments[] = $attachment->getApiStructure($this->getUser());
|
$attachments[] = $attachment->getApiStructure($this->getUser());
|
||||||
} else if ($attachment instanceof \openvk\Web\Models\Entities\Note) {
|
} else if ($attachment instanceof \openvk\Web\Models\Entities\Note) {
|
||||||
if(VKAPI_DECL_VER === '4.100') {
|
$attachments[] = [
|
||||||
$attachments[] = $attachment->toVkApiStruct();
|
'type' => 'note',
|
||||||
} else {
|
'note' => $attachment->toVkApiStruct()
|
||||||
$attachments[] = [
|
];
|
||||||
'type' => 'note',
|
|
||||||
'note' => $attachment->toVkApiStruct()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
} else if ($attachment instanceof \openvk\Web\Models\Entities\Audio) {
|
} else if ($attachment instanceof \openvk\Web\Models\Entities\Audio) {
|
||||||
$attachments[] = [
|
$attachments[] = [
|
||||||
"type" => "audio",
|
"type" => "audio",
|
||||||
|
@ -419,6 +418,9 @@ final class Wall extends VKAPIRequestHandler
|
||||||
if($post->isDeactivationMessage())
|
if($post->isDeactivationMessage())
|
||||||
$post_temp_obj->final_post = 1;
|
$post_temp_obj->final_post = 1;
|
||||||
|
|
||||||
|
if($post->getGeo())
|
||||||
|
$post_temp_obj->geo = $post->getVkApiGeo();
|
||||||
|
|
||||||
$items[] = $post_temp_obj;
|
$items[] = $post_temp_obj;
|
||||||
|
|
||||||
if ($from_id > 0)
|
if ($from_id > 0)
|
||||||
|
@ -493,7 +495,11 @@ final class Wall extends VKAPIRequestHandler
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function post(string $owner_id, string $message = "", string $copyright = "", int $from_group = 0, int $signed = 0, string $attachments = "", int $post_id = 0): object
|
function post(string $owner_id, string $message = "", string $copyright = "", int $from_group = 0, int $signed = 0, string $attachments = "", int $post_id = 0,
|
||||||
|
float $lat = NULL,
|
||||||
|
float $long = NULL,
|
||||||
|
string $place_name = ''
|
||||||
|
): object
|
||||||
{
|
{
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
$this->willExecuteWriteAction();
|
$this->willExecuteWriteAction();
|
||||||
|
@ -584,44 +590,6 @@ final class Wall extends VKAPIRequestHandler
|
||||||
if((empty($message) && (empty($attachments) || sizeof($final_attachments) < 1)))
|
if((empty($message) && (empty($attachments) || sizeof($final_attachments) < 1)))
|
||||||
$this->fail(100, "Required parameter 'message' missing.");
|
$this->fail(100, "Required parameter 'message' missing.");
|
||||||
|
|
||||||
$geo = NULL;
|
|
||||||
|
|
||||||
if ($latitude && $longitude) {
|
|
||||||
$latitude = number_format($latitude, 8, ".", '');
|
|
||||||
$longitude = number_format($longitude, 8, ".", '');
|
|
||||||
|
|
||||||
if ((!$latitude || !$longitude) || ($latitude > 90 || $latitude < -90 || $longitude > 180 || $longitude < -180)) {
|
|
||||||
$this->fail(100, "Invalid latitude or longitude");
|
|
||||||
}
|
|
||||||
|
|
||||||
$geo = array(
|
|
||||||
"name" => null,
|
|
||||||
"lat" => $latitude,
|
|
||||||
"lng" => $longitude,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (strlen(trim($geo_name))) {
|
|
||||||
$geo["name"] = $geo_name;
|
|
||||||
} else {
|
|
||||||
$info = file_get_contents("https://nominatim.openstreetmap.org/reverse?lat=${latitude}&lon=${longitude}&format=jsonv2", false, stream_context_create([
|
|
||||||
'http' => [
|
|
||||||
'method' => 'GET',
|
|
||||||
'header' => implode("\r\n", [
|
|
||||||
'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2',
|
|
||||||
"Referer: https://$_SERVER[SERVER_NAME]/"
|
|
||||||
])
|
|
||||||
]
|
|
||||||
]));
|
|
||||||
|
|
||||||
if ($info) {
|
|
||||||
$info = json_decode($info, true, JSON_UNESCAPED_UNICODE);
|
|
||||||
if (key_exists("place_id", $info)) {
|
|
||||||
$geo["name"] = $info["name"] ?? $info["display_name"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$post = new Post;
|
$post = new Post;
|
||||||
$post->setOwner($this->getUser()->getId());
|
$post->setOwner($this->getUser()->getId());
|
||||||
|
@ -637,6 +605,45 @@ final class Wall extends VKAPIRequestHandler
|
||||||
} catch(\Throwable) {}
|
} catch(\Throwable) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*$info = file_get_contents("https://nominatim.openstreetmap.org/reverse?lat=${latitude}&lon=${longitude}&format=jsonv2", false, stream_context_create([
|
||||||
|
'http' => [
|
||||||
|
'method' => 'GET',
|
||||||
|
'header' => implode("\r\n", [
|
||||||
|
'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2',
|
||||||
|
"Referer: https://$_SERVER[SERVER_NAME]/"
|
||||||
|
])
|
||||||
|
]
|
||||||
|
]));
|
||||||
|
|
||||||
|
if ($info) {
|
||||||
|
$info = json_decode($info, true, JSON_UNESCAPED_UNICODE);
|
||||||
|
if (key_exists("place_id", $info)) {
|
||||||
|
$geo["name"] = $info["name"] ?? $info["display_name"];
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
if($lat && $long) {
|
||||||
|
if(($lat > 90 || $lat < -90) || ($long > 180 || $long < -180)) {
|
||||||
|
$this->fail(-785, 'Invalid geo info');
|
||||||
|
}
|
||||||
|
|
||||||
|
$latitude = number_format((float) $lat, 8, ".", '');
|
||||||
|
$longitude = number_format((float) $long, 8, ".", '');
|
||||||
|
|
||||||
|
$res = [
|
||||||
|
'lat' => $latitude,
|
||||||
|
'lng' => $longitude
|
||||||
|
];
|
||||||
|
if($place_name && mb_strlen($place_name) > 0) {
|
||||||
|
$res['name'] = $place_name;
|
||||||
|
} else {
|
||||||
|
$res['name'] = 'Geopoint';
|
||||||
|
}
|
||||||
|
|
||||||
|
$post->setGeo(json_encode($res));
|
||||||
|
$post->setGeo_Lat($latitude);
|
||||||
|
$post->setGeo_Lon($longitude);
|
||||||
|
}
|
||||||
|
|
||||||
if($should_be_suggested)
|
if($should_be_suggested)
|
||||||
$post->setSuggested(1);
|
$post->setSuggested(1);
|
||||||
|
|
||||||
|
@ -1167,6 +1174,52 @@ final class Wall extends VKAPIRequestHandler
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNearby(int $owner_id, int $post_id)
|
||||||
|
{
|
||||||
|
$this->requireUser();
|
||||||
|
|
||||||
|
$post = (new PostsRepo)->getPostById($owner_id, $post_id);
|
||||||
|
if(!$post || $post->isDeleted())
|
||||||
|
$this->fail(100, "One of the parameters specified was missing or invalid: post_id is undefined");
|
||||||
|
|
||||||
|
if(!$post->canBeViewedBy($this->getUser()))
|
||||||
|
$this->fail(15, "Access denied");
|
||||||
|
|
||||||
|
$lat = $post->getLat();
|
||||||
|
$lon = $post->getLon();
|
||||||
|
|
||||||
|
if(!$lat || !$lon)
|
||||||
|
$this->fail(-97, "Post doesn't contains geo");
|
||||||
|
|
||||||
|
$query = file_get_contents(__DIR__ . "/../../Web/Models/sql/get-nearest-posts.tsql");
|
||||||
|
$_posts = \Chandler\Database\DatabaseConnection::i()->getContext()->query($query, $lat, $lon, $post->getId())->fetchAll();
|
||||||
|
$posts = [];
|
||||||
|
|
||||||
|
foreach($_posts as $post) {
|
||||||
|
$distance = $post["distance"];
|
||||||
|
$post = (new PostsRepo)->get($post["id"]);
|
||||||
|
if (!$post || $post->isDeleted() || !$post->canBeViewedBy($this->getUser())) continue;
|
||||||
|
|
||||||
|
$owner = $post->getOwner();
|
||||||
|
$preview = mb_substr($post->getText(), 0, 50) . (strlen($post->getText()) > 50 ? "..." : "");
|
||||||
|
$posts[] = [
|
||||||
|
"message" => strlen($preview) > 0 ? $preview : "(нет текста)",
|
||||||
|
"url" => "/wall" . $post->getPrettyId(),
|
||||||
|
"created" => $post->getPublicationTime()->html(),
|
||||||
|
"owner" => [
|
||||||
|
"domain" => $owner->getURL(),
|
||||||
|
"photo_50" => $owner->getAvatarURL(),
|
||||||
|
"name" => $owner->getCanonicalName(),
|
||||||
|
"verified" => $owner->isVerified(),
|
||||||
|
],
|
||||||
|
"geo" => $post->getGeo(),
|
||||||
|
"distance" => $distance
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
private function getApiPhoto($attachment) {
|
private function getApiPhoto($attachment) {
|
||||||
return [
|
return [
|
||||||
"type" => "photo",
|
"type" => "photo",
|
||||||
|
|
|
@ -473,5 +473,13 @@ class Post extends Postable
|
||||||
return (float) $this->getRecord()->geo_lon ?? NULL;
|
return (float) $this->getRecord()->geo_lon ?? NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getVkApiGeo(): object
|
||||||
|
{
|
||||||
|
return (object) [
|
||||||
|
'type' => 'point',
|
||||||
|
'coordinates' => $this->getLat() . ',' . $this->getLon(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
use Traits\TRichText;
|
use Traits\TRichText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,37 +309,20 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$this->flashFail("err", tr("failed_to_publish_post"), "Poll format invalid");
|
$this->flashFail("err", tr("failed_to_publish_post"), "Poll format invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($this->postParam("text")) && sizeof($horizontal_attachments) < 1 && sizeof($vertical_attachments) < 1 && !$poll)
|
|
||||||
$note = NULL;
|
|
||||||
|
|
||||||
if(!is_null($this->postParam("note")) && $this->postParam("note") != "none") {
|
|
||||||
$note = (new Notes)->get((int)$this->postParam("note"));
|
|
||||||
|
|
||||||
if(!$note || $note->isDeleted() || $note->getOwner()->getId() != $this->user->id) {
|
|
||||||
$this->flashFail("err", tr("error"), tr("error_attaching_note"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if($note->getOwner()->getPrivacySetting("notes.read") < 1) {
|
|
||||||
$this->flashFail("err", " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$geo = NULL;
|
$geo = NULL;
|
||||||
|
|
||||||
if (!is_null($this->postParam("geo")) && $this->postParam("geo") != "none") {
|
if (!is_null($this->postParam("geo")) && $this->postParam("geo") != "") {
|
||||||
$geo = json_decode($this->postParam("geo"), true, JSON_UNESCAPED_UNICODE);
|
$geo = json_decode($this->postParam("geo"), true, JSON_UNESCAPED_UNICODE);
|
||||||
if (!$geo["lat"] || !$geo["lng"] || !$geo["name"]) {
|
if($geo["lat"] && $geo["lng"] && $geo["name"]) {
|
||||||
$this->flashFail("err", tr("error"), tr("error_geolocation"));
|
$latitude = number_format((float) $geo["lat"], 8, ".", '');
|
||||||
}
|
$longitude = number_format((float) $geo["lng"], 8, ".", '');
|
||||||
|
if($latitude > 90 || $latitude < -90 || $longitude > 180 || $longitude < -180) {
|
||||||
$latitude = number_format((float) $geo["lat"], 8, ".", '');
|
$this->flashFail("err", tr("error"), "Invalid latitude or longitude");
|
||||||
$longitude = number_format((float) $geo["lng"], 8, ".", '');
|
}
|
||||||
if ($latitude > 90 || $latitude < -90 || $longitude > 180 || $longitude < -180) {
|
|
||||||
$this->flashFail("err", tr("error"), "Invalid latitude or longitude");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($this->postParam("text")) && !$photo && !$video && !$poll && !$note && !$geo)
|
if(empty($this->postParam("text")) && sizeof($horizontal_attachments) < 1 && sizeof($vertical_attachments) < 1 && !$poll)
|
||||||
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_empty_or_too_big"));
|
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_empty_or_too_big"));
|
||||||
|
|
||||||
$should_be_suggested = $wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2;
|
$should_be_suggested = $wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2;
|
||||||
|
@ -712,49 +695,4 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$this->template->page = $page;
|
$this->template->page = $page;
|
||||||
$this->template->perPage = OPENVK_DEFAULT_PER_PAGE;
|
$this->template->perPage = OPENVK_DEFAULT_PER_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderNearest(int $wall, int $post_id): void
|
|
||||||
{
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] !== "POST") $this->notFound();
|
|
||||||
$this->assertUserLoggedIn();
|
|
||||||
|
|
||||||
$post = $this->posts->getPostById($wall, $post_id);
|
|
||||||
if(!$post)
|
|
||||||
$this->notFound();
|
|
||||||
|
|
||||||
$lat = $post->getLat();
|
|
||||||
$lon = $post->getLon();
|
|
||||||
|
|
||||||
if (!$lat || !$lon)
|
|
||||||
$this->returnJson(["success" => false, "error" => tr("error_no_geotag")]);
|
|
||||||
|
|
||||||
$query = file_get_contents(__DIR__ . "/../Models/sql/get-nearest-posts.tsql");
|
|
||||||
$_posts = DatabaseConnection::i()->getContext()->query($query, $lat, $lon, $post->getId())->fetchAll();
|
|
||||||
$posts = [];
|
|
||||||
foreach ($_posts as $post) {
|
|
||||||
$distance = $post["distance"];
|
|
||||||
$post = (new Posts)->get($post["id"]);
|
|
||||||
if (!$post || $post->isDeleted()) continue;
|
|
||||||
|
|
||||||
$owner = $post->getOwner();
|
|
||||||
|
|
||||||
$preview = mb_substr($post->getText(), 0, 50) . (strlen($post->getText()) > 50 ? "..." : "");
|
|
||||||
$posts[] = [
|
|
||||||
"preview" => strlen($preview) > 0 ? $preview : "(нет текста)",
|
|
||||||
"url" => "/wall" . $post->getPrettyId(),
|
|
||||||
"time" => $post->getPublicationTime()->html(),
|
|
||||||
"owner" => [
|
|
||||||
"url" => $owner->getURL(),
|
|
||||||
"avatar_url" => $owner->getAvatarURL(),
|
|
||||||
"name" => $owner->getCanonicalName(),
|
|
||||||
"verified" => $owner->isVerified(),
|
|
||||||
"writes" => ($owner instanceof User) ? ($owner->isFemale() ? tr("post_writes_f") : tr("post_writes_m")) : tr("post_writes_m")
|
|
||||||
],
|
|
||||||
"geo" => $post->getGeo(),
|
|
||||||
"distance" => $distance
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->returnJson(["success" => true, "posts" => $posts, "need_count" => count($posts) === 25]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,6 +404,11 @@
|
||||||
{script "js/al_feed.js"}
|
{script "js/al_feed.js"}
|
||||||
{/ifset}
|
{/ifset}
|
||||||
|
|
||||||
|
{script "js/node_modules/leaflet/dist/leaflet.js"}
|
||||||
|
{script "js/node_modules/leaflet-control-geocoder/dist/Control.Geocoder.js"}
|
||||||
|
{css "js/node_modules/leaflet/dist/leaflet.css"}
|
||||||
|
{css "js/node_modules/leaflet-control-geocoder/dist/Control.Geocoder.css"}
|
||||||
|
|
||||||
<script>bsdnHydrate();</script>
|
<script>bsdnHydrate();</script>
|
||||||
|
|
||||||
<script n:if="OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['enable']" async defer data-domain="{php echo OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['domain']}" src="{php echo OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['server']}js/plausible.js"></script>
|
<script n:if="OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['enable']" async defer data-domain="{php echo OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['domain']}" src="{php echo OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['server']}js/plausible.js"></script>
|
||||||
|
|
|
@ -92,10 +92,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div n:if="$post->getGeo()" class="post-signature">
|
<div n:if="$post->getGeo()" class="post-geo">
|
||||||
<a onclick="javascript:openGeo({$post->getGeo()}, {$post->getOwner()->getId()}, {$post->getVirtualId()})">
|
<a onclick="javascript:openGeo({$post->getGeo()}, {$post->getTargetWall()}, {$post->getVirtualId()})">
|
||||||
<img src="/assets/packages/static/openvk/img/geo.svg">
|
<svg class="map_svg_icon" width="13" height="12" viewBox="0 0 3.4395833 3.175">
|
||||||
<b>{_geotag}</b>: {$post->getGeo()->name ?? tr("admin_open")}
|
<g><path d="M 1.7197917 0.0025838216 C 1.1850116 0.0049444593 0.72280427 0.4971031 0.71520182 1.0190592 C 0.70756921 1.5430869 1.7223755 3.1739665 1.7223755 3.1739665 C 1.7223755 3.1739665 2.7249195 1.5439189 2.7243815 0.99632161 C 2.7238745 0.48024825 2.2492929 0.00024648357 1.7197917 0.0025838216 z M 1.7197917 0.52606608 A 0.48526123 0.48526123 0 0 1 2.2050334 1.0113078 A 0.48526123 0.48526123 0 0 1 1.7197917 1.4965495 A 0.48526123 0.48526123 0 0 1 1.23455 1.0113078 A 0.48526123 0.48526123 0 0 1 1.7197917 0.52606608 z " /></g>
|
||||||
|
</svg>
|
||||||
|
{$post->getGeo()->name ?? tr("admin_open")}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div n:if="$post->isAd()" style="color:grey;">
|
<div n:if="$post->isAd()" style="color:grey;">
|
||||||
|
|
|
@ -90,10 +90,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div n:if="$post->getGeo()" style="padding: 4px;">
|
<div n:if="$post->getGeo()" class="post-geo">
|
||||||
<div style="border-bottom: #ECECEC solid 1px;" />
|
<div onclick="javascript:openGeo({$post->getGeo()}, {$post->getTargetWall()}, {$post->getVirtualId()})">
|
||||||
<div style="cursor: pointer; padding: 4px;" onclick="javascript:openGeo({$post->getGeo()}, {$post->getOwner()->getId()}, {$post->getVirtualId()})">
|
<svg class="map_svg_icon" width="13" height="12" viewBox="0 0 3.4395833 3.175">
|
||||||
<b>{_geotag}</b>: <a>{$post->getGeo()->name ?? tr("admin_open")}</a>
|
<g><path d="M 1.7197917 0.0025838216 C 1.1850116 0.0049444593 0.72280427 0.4971031 0.71520182 1.0190592 C 0.70756921 1.5430869 1.7223755 3.1739665 1.7223755 3.1739665 C 1.7223755 3.1739665 2.7249195 1.5439189 2.7243815 0.99632161 C 2.7238745 0.48024825 2.2492929 0.00024648357 1.7197917 0.0025838216 z M 1.7197917 0.52606608 A 0.48526123 0.48526123 0 0 1 2.2050334 1.0113078 A 0.48526123 0.48526123 0 0 1 1.7197917 1.4965495 A 0.48526123 0.48526123 0 0 1 1.23455 1.0113078 A 0.48526123 0.48526123 0 0 1 1.7197917 0.52606608 z " /></g>
|
||||||
|
</svg>
|
||||||
|
<a>{$post->getGeo()->name ?? tr("admin_open")}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div n:if="$suggestion && $canBePinned" class="suggestionControls" style="margin-bottom: 7px;">
|
<div n:if="$suggestion && $canBePinned" class="suggestionControls" style="margin-bottom: 7px;">
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<input type="hidden" name="vertical_attachments" value="" autocomplete="off" />
|
<input type="hidden" name="vertical_attachments" value="" autocomplete="off" />
|
||||||
<input type="hidden" name="poll" value="none" autocomplete="off" />
|
<input type="hidden" name="poll" value="none" autocomplete="off" />
|
||||||
<input type="hidden" id="source" name="source" value="none" autocomplete="off" />
|
<input type="hidden" id="source" name="source" value="none" autocomplete="off" />
|
||||||
<input type="hidden" id="geo" name="geo" value="none" />
|
<input type="hidden" name="geo" value="" autocomplete="off" />
|
||||||
<input type="hidden" name="type" value="1" autocomplete="off" />
|
<input type="hidden" name="type" value="1" autocomplete="off" />
|
||||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -98,9 +98,9 @@
|
||||||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/actions/office-chart-bar-stacked.png" />
|
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/actions/office-chart-bar-stacked.png" />
|
||||||
{_poll}
|
{_poll}
|
||||||
</a>
|
</a>
|
||||||
<a n:if="$geo ?? false" href="javascript:initGeo({$textAreaId})">
|
<a n:if="$geo ?? false" id="__geoAttacher">
|
||||||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/apps/amarok.png" />
|
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/apps/amarok.png" />
|
||||||
Гео-метка
|
{_geo_place}
|
||||||
</a>
|
</a>
|
||||||
<a n:if="$hasSource ?? false" id='__sourceAttacher'>
|
<a n:if="$hasSource ?? false" id='__sourceAttacher'>
|
||||||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/actions/insert-link.png" />
|
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/actions/insert-link.png" />
|
||||||
|
|
|
@ -145,8 +145,6 @@ routes:
|
||||||
handler: "Wall->decline"
|
handler: "Wall->decline"
|
||||||
- url: "/{text}/{num}_{num}/likes"
|
- url: "/{text}/{num}_{num}/likes"
|
||||||
handler: "Wall->likers"
|
handler: "Wall->likers"
|
||||||
- url: "/wall{num}_{num}/nearest"
|
|
||||||
handler: "Wall->nearest"
|
|
||||||
- url: "/blob_{text}/{?path}.{text}"
|
- url: "/blob_{text}/{?path}.{text}"
|
||||||
handler: "Blob->file"
|
handler: "Blob->file"
|
||||||
placeholders:
|
placeholders:
|
||||||
|
|
|
@ -851,6 +851,11 @@ h4 {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-geo {
|
||||||
|
margin: 1px 0px;
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.post-signature span {
|
.post-signature span {
|
||||||
color: grey;
|
color: grey;
|
||||||
}
|
}
|
||||||
|
@ -3911,3 +3916,9 @@ hr {
|
||||||
top: 3px;
|
top: 3px;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.map_svg_icon {
|
||||||
|
display: inline-block;
|
||||||
|
margin-bottom: -2px;
|
||||||
|
fill: #7d7d7d;
|
||||||
|
}
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="13"
|
|
||||||
height="12"
|
|
||||||
viewBox="0 0 3.4395833 3.175"
|
|
||||||
version="1.1"
|
|
||||||
id="svg5"
|
|
||||||
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
|
|
||||||
sodipodi:docname="geo.svg"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="namedview7"
|
|
||||||
pagecolor="#505050"
|
|
||||||
bordercolor="#eeeeee"
|
|
||||||
borderopacity="1"
|
|
||||||
inkscape:showpageshadow="0"
|
|
||||||
inkscape:pageopacity="0"
|
|
||||||
inkscape:pagecheckerboard="0"
|
|
||||||
inkscape:deskcolor="#505050"
|
|
||||||
inkscape:document-units="mm"
|
|
||||||
showgrid="false"
|
|
||||||
inkscape:zoom="45.254834"
|
|
||||||
inkscape:cx="5.2922523"
|
|
||||||
inkscape:cy="5.2149125"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1009"
|
|
||||||
inkscape:window-x="-8"
|
|
||||||
inkscape:window-y="-8"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:current-layer="layer1" />
|
|
||||||
<defs
|
|
||||||
id="defs2" />
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1">
|
|
||||||
<path
|
|
||||||
id="path4213"
|
|
||||||
style="fill:#b1bfcd;fill-opacity:1;stroke-width:0.264583"
|
|
||||||
d="M 1.7197917 0.0025838216 C 1.1850116 0.0049444593 0.72280427 0.4971031 0.71520182 1.0190592 C 0.70756921 1.5430869 1.7223755 3.1739665 1.7223755 3.1739665 C 1.7223755 3.1739665 2.7249195 1.5439189 2.7243815 0.99632161 C 2.7238745 0.48024825 2.2492929 0.00024648357 1.7197917 0.0025838216 z M 1.7197917 0.52606608 A 0.48526123 0.48526123 0 0 1 2.2050334 1.0113078 A 0.48526123 0.48526123 0 0 1 1.7197917 1.4965495 A 0.48526123 0.48526123 0 0 1 1.23455 1.0113078 A 0.48526123 0.48526123 0 0 1 1.7197917 0.52606608 z " />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 1.8 KiB |
|
@ -2588,153 +2588,183 @@ async function changeStatus() {
|
||||||
document.status_popup_form.submit.disabled = false;
|
document.status_popup_form.submit.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initGeo(tid) {
|
const tplMapIcon = `<svg class="map_svg_icon" width="13" height="12" viewBox="0 0 3.4395833 3.175">
|
||||||
MessageBox(tr("attach_geotag"), "<div id=\"osm-map\"></div>", ["Прикрепить", tr("cancel")], [(function () {
|
<g><path d="M 1.7197917 0.0025838216 C 1.1850116 0.0049444593 0.72280427 0.4971031 0.71520182 1.0190592 C 0.70756921 1.5430869 1.7223755 3.1739665 1.7223755 3.1739665 C 1.7223755 3.1739665 2.7249195 1.5439189 2.7243815 0.99632161 C 2.7238745 0.48024825 2.2492929 0.00024648357 1.7197917 0.0025838216 z M 1.7197917 0.52606608 A 0.48526123 0.48526123 0 0 1 2.2050334 1.0113078 A 0.48526123 0.48526123 0 0 1 1.7197917 1.4965495 A 0.48526123 0.48526123 0 0 1 1.23455 1.0113078 A 0.48526123 0.48526123 0 0 1 1.7197917 0.52606608 z " /></g>
|
||||||
let marker = {
|
</svg>`
|
||||||
lat: currentMarker._latlng.lat,
|
|
||||||
lng: currentMarker._latlng.lng,
|
|
||||||
name: $(`#geo-name-input-${tid}`).val() ? $(`#geo-name-input-${tid}`).val() : $(`#geo-name-${tid}`).text()
|
|
||||||
};
|
|
||||||
$(`#post-buttons${tid} #geo`).val(JSON.stringify(marker));
|
|
||||||
$(`#post-buttons${tid} .post-has-geo`).text(`${tr("geotag")}: ${marker.name}`);
|
|
||||||
$(`#post-buttons${tid} .post-has-geo`).show();
|
|
||||||
}), Function.noop]);
|
|
||||||
|
|
||||||
const element = document.getElementById('osm-map');
|
u(document).on('click', "#__geoAttacher", async (e) => {
|
||||||
element.style = 'height: 600px;';
|
const form = u(e.target).closest('#write')
|
||||||
|
const buttons = form.find('.post-buttons')
|
||||||
|
|
||||||
let markerLayers = L.layerGroup();
|
let current_coords = [54.51331, 36.2732]
|
||||||
|
let currentMarker = null
|
||||||
|
const getCoords = async () => {
|
||||||
|
const pos = await new Promise((resolve, reject) => {
|
||||||
|
navigator.geolocation.getCurrentPosition((position) => {
|
||||||
|
resolve([position.coords.latitude, position.coords.longitude])
|
||||||
|
}, () => {
|
||||||
|
resolve([54.51331, 36.2732])
|
||||||
|
},
|
||||||
|
{
|
||||||
|
enableHighAccuracy: true,
|
||||||
|
timeout: 5000,
|
||||||
|
maximumAge: 0,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
let map = L.map(element, {
|
return pos
|
||||||
center: [55.322978, 38.673362],
|
}
|
||||||
|
|
||||||
|
current_coords = await getCoords()
|
||||||
|
|
||||||
|
const geo_msg = new CMessageBox({
|
||||||
|
title: tr('attach_geotag'),
|
||||||
|
body: `<div id=\"osm-map\" style='height:75vh;'></div>`,
|
||||||
|
buttons: [tr('attach'), tr('cancel')],
|
||||||
|
callbacks: [() => {
|
||||||
|
if(!currentMarker) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const geo_name = $(`#geo-name`).html()
|
||||||
|
if(geo_name == '') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const marker = {
|
||||||
|
lat: currentMarker._latlng.lat,
|
||||||
|
lng: currentMarker._latlng.lng,
|
||||||
|
name: escapeHtml(geo_name)
|
||||||
|
}
|
||||||
|
buttons.find(`input[name='geo']`).nodes[0].value = JSON.stringify(marker)
|
||||||
|
buttons.find(`.post-has-geo`).html(`
|
||||||
|
${tplMapIcon}
|
||||||
|
<span>${escapeHtml(geo_name)}</span>
|
||||||
|
<div id="small_remove_button"></div>
|
||||||
|
`)
|
||||||
|
}, () => {}]
|
||||||
|
})
|
||||||
|
|
||||||
|
// by n1rwana
|
||||||
|
const markerLayers = L.layerGroup()
|
||||||
|
const map = L.map(u('#osm-map').nodes[0], {
|
||||||
|
center: current_coords,
|
||||||
zoom: 10,
|
zoom: 10,
|
||||||
attributionControl: false,
|
attributionControl: false,
|
||||||
width: 800
|
width: 800
|
||||||
});
|
})
|
||||||
let currentMarker = null;
|
markerLayers.addTo(map)
|
||||||
markerLayers.addTo(map);
|
|
||||||
|
|
||||||
map.on('click', (e) => {
|
map.on('click', async (e) => {
|
||||||
let lat = e.latlng.lat;
|
const lat = e.latlng.lat
|
||||||
let lng = e.latlng.lng;
|
const lng = e.latlng.lng
|
||||||
|
|
||||||
if (currentMarker) map.removeLayer(currentMarker);
|
if(currentMarker) map.removeLayer(currentMarker);
|
||||||
|
|
||||||
$.get({
|
const marker_fetch_req = await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lng}&format=jsonv2`)
|
||||||
url: `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lng}&format=jsonv2`,
|
const marker_fetch = await marker_fetch_req.json()
|
||||||
success: (response) => {
|
|
||||||
markerLayers.clearLayers();
|
|
||||||
|
|
||||||
currentMarker = L.marker([lat, lng]).addTo(map);
|
markerLayers.clearLayers()
|
||||||
|
currentMarker = L.marker([lat, lng]).addTo(map)
|
||||||
|
|
||||||
let name = response?.name ?? response?.display_name ?? tr("geotag");
|
let marker_name = marker_fetch && marker_fetch.display_name ? short_geo_name(marker_fetch.address) : tr('geotag')
|
||||||
let content = `<span onclick="let name = prompt('Введите название геоточки'); $('#geo-name-input-${tid}').val(name); $(this).text(name);" id="geo-name-${tid}">${name}</span>`;
|
const content = `<span id="geo-name">${marker_name}</span>`;
|
||||||
content += `<input type="hidden" id="geo-name-input-${tid}" value="" />`;
|
|
||||||
|
|
||||||
currentMarker.bindPopup(content).openPopup();
|
currentMarker.bindPopup(content).openPopup()
|
||||||
markerLayers.addLayer(currentMarker);
|
markerLayers.addLayer(currentMarker)
|
||||||
}
|
})
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
const geocoderControl = L.Control.geocoder({
|
const geocoderControl = L.Control.geocoder({
|
||||||
defaultMarkGeocode: false,
|
defaultMarkGeocode: false,
|
||||||
}).addTo(map);
|
}).addTo(map)
|
||||||
|
|
||||||
geocoderControl.on('markgeocode', function (e) {
|
geocoderControl.on('markgeocode', function (e) {
|
||||||
console.log(e);
|
console.log(e.geocode.properties)
|
||||||
let lat = e.geocode.properties.lat;
|
const lat = e.geocode.properties.lat
|
||||||
let lng = e.geocode.properties.lon;
|
const lng = e.geocode.properties.lon
|
||||||
let name = (e.geocode.properties?.name ?? e.geocode.properties.display_name);
|
const name = e.geocode.properties?.display_name ? short_geo_name(e.geocode.properties?.address) : tr('geotag')
|
||||||
|
|
||||||
if (currentMarker) map.removeLayer(currentMarker);
|
if(currentMarker) map.removeLayer(currentMarker)
|
||||||
|
|
||||||
currentMarker = L.marker([lat, lng]).addTo(map);
|
currentMarker = L.marker([lat, lng]).addTo(map)
|
||||||
currentMarker.bindPopup(name).openPopup();
|
currentMarker.bindPopup(`<span id="geo-name">${escapeHtml(name)}</span>`).openPopup()
|
||||||
|
|
||||||
console.log(`${tr("latitude")}: ${lat}, ${tr("longitude")}: ${lng}`);
|
marker = {
|
||||||
console.log(`${tr("name_of_the_place")}: ${name}`);
|
|
||||||
|
|
||||||
let marker = {
|
|
||||||
lat: lat,
|
lat: lat,
|
||||||
lng: lng,
|
lng: lng,
|
||||||
name: name
|
name: name
|
||||||
};
|
};
|
||||||
map.setView([lat, lng], 15);
|
map.setView([lat, lng], 15);
|
||||||
});
|
})
|
||||||
|
|
||||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
||||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}).addTo(map)
|
||||||
|
|
||||||
$(".ovk-diag-cont").width('50%');
|
geo_msg.getNode().nodes[0].style = 'width:90%'
|
||||||
setTimeout(function(){ map.invalidateSize()}, 100);
|
setTimeout(function(){ map.invalidateSize()}, 100)
|
||||||
}
|
})
|
||||||
|
|
||||||
|
u(document).on('click', '.post-has-geo #small_remove_button', (e) => {
|
||||||
|
const form = u(e.target).closest('#write')
|
||||||
|
const geo = form.find('.post-has-geo')
|
||||||
|
geo.remove()
|
||||||
|
form.find(`input[name='geo']`).nodes[0].value = ''
|
||||||
|
})
|
||||||
|
|
||||||
function openGeo(data, owner_id, virtual_id) {
|
function openGeo(data, owner_id, virtual_id) {
|
||||||
MessageBox(tr("geotag"), "<div id=\"osm-map\"></div>", [tr("nearest_posts"), "OK"], [(function () {
|
MessageBox(tr("geotag"), "<div id=\"osm-map\"></div>", [tr("nearest_posts"), tr("close")], [async () => {
|
||||||
getNearPosts(owner_id, virtual_id);
|
const posts = await OVKAPI.call('wall.getNearby', {owner_id: owner_id, post_id: virtual_id})
|
||||||
}), Function.noop]);
|
openNearPosts(posts)
|
||||||
|
}, Function.noop]);
|
||||||
|
|
||||||
let element = document.getElementById('osm-map');
|
let element = document.getElementById('osm-map');
|
||||||
element.style = 'height: 600px;';
|
element.style = 'height: 80vh;';
|
||||||
|
|
||||||
let map = L.map(element, {attributionControl: false});
|
let map = L.map(element, {attributionControl: false});
|
||||||
let target = L.latLng(data.lat, data.lng);
|
let target = L.latLng(data.lat, data.lng);
|
||||||
map.setView(target, 15);
|
map.setView(target, 15);
|
||||||
|
|
||||||
let marker = L.marker(target).addTo(map);
|
let marker = L.marker(target).addTo(map);
|
||||||
marker.bindPopup(data.name ?? tr("geotag")).openPopup();
|
marker.bindPopup(escapeHtml(data.name ?? tr("geotag"))).openPopup();
|
||||||
|
|
||||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
||||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
$(".ovk-diag-cont").width('50%');
|
$(".ovk-diag-cont").width('80%');
|
||||||
setTimeout(function(){ map.invalidateSize()}, 100);
|
setTimeout(function(){ map.invalidateSize()}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNearPosts(owner_id, virtual_id) {
|
function tplPost(post) {
|
||||||
$.ajax({
|
return `<a style="color: inherit; display: block; margin-bottom: 8px;" href="${post.url}">
|
||||||
type: "POST",
|
|
||||||
url: `/wall${owner_id}_${virtual_id}/nearest`,
|
|
||||||
success: (response) => {
|
|
||||||
if (response.success) {
|
|
||||||
openNearPosts(response);
|
|
||||||
} else {
|
|
||||||
MessageBox(tr("error"), `${tr("error_segmentation")}: ${(response?.error ?? "Unknown error")}`, ["OK"], [Function.noop]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPostPopup(post) {
|
|
||||||
return `<a style="color: inherit; display: block; margin-bottom: 8px;" href="${post.url}" target="_blank">
|
|
||||||
<table border="0" style="font-size: 11px;" class="post">
|
<table border="0" style="font-size: 11px;" class="post">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="54" valign="top">
|
<td width="54" valign="top">
|
||||||
<a href="${post.owner.url}">
|
<a href="${post.owner.domain}">
|
||||||
<img src="${post.owner.avatar_url}" width="50">
|
<img src="${post.owner.photo_50}" width="50">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td width="100%" valign="top">
|
<td width="100%" valign="top">
|
||||||
<div class="post-author">
|
<div class="post-author">
|
||||||
<a href="${post.owner.url}"><b>${post.owner.name}</b></a>
|
<a href="${post.owner.domain}"><b>${escapeHtml(post.owner.name)}</b></a>
|
||||||
${post.owner.verified ? `<img class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png">` : ""}
|
${post.owner.verified ? `<img class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png">` : ""}
|
||||||
${post.owner.writes}
|
|
||||||
<br>
|
<br>
|
||||||
<a href="${post.url}" class="date">
|
<a href="${post.url}" class="date">
|
||||||
${post.time}
|
${post.created}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="post-content" id="2_28">
|
<div class="post-content">
|
||||||
<div class="text" id="text2_28">
|
<div class="text">
|
||||||
${post.preview}
|
${escapeHtml(post.message)}
|
||||||
</div>
|
</div>
|
||||||
<div style="padding: 4px;">
|
<div style="padding: 4px;">
|
||||||
<div style="border-bottom: #ECECEC solid 1px;"></div>
|
<div style="border-bottom: #ECECEC solid 1px;"></div>
|
||||||
<div style="cursor: pointer; padding: 4px;"><b>${tr("geotag")}</b>: ${post.geo.name ?? tr("admin_open")}</div>
|
<div style="cursor: pointer; padding: 4px;">
|
||||||
|
${tplMapIcon}
|
||||||
|
${escapeHtml(post.geo.name)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -2745,14 +2775,14 @@ function getPostPopup(post) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function openNearPosts(posts) {
|
function openNearPosts(posts) {
|
||||||
if (posts.posts.length > 0) {
|
if (posts.length > 0) {
|
||||||
let MsgTxt = "<div id=\"osm-map\"></div>";
|
let MsgTxt = "<div id=\"osm-map\"></div>";
|
||||||
MsgTxt += "<br /><br /><center style='color: grey;'>Показаны последние 25 постов за месяц</center>";
|
MsgTxt += `<br /><br /><center style='color: grey;'>${tr('shown_last_nearest_posts', 25)}</center>`;
|
||||||
|
|
||||||
MessageBox("Ближайшие посты", MsgTxt, ["OK"], [Function.noop]);
|
MessageBox(tr('nearest_posts'), MsgTxt, ["OK"], [Function.noop]);
|
||||||
|
|
||||||
let element = document.getElementById('osm-map');
|
let element = document.getElementById('osm-map');
|
||||||
element.style = 'height: 600px;';
|
element.style = 'height: 80vh;';
|
||||||
|
|
||||||
let markerLayers = L.layerGroup();
|
let markerLayers = L.layerGroup();
|
||||||
let map = L.map(element, {attributionControl: false});
|
let map = L.map(element, {attributionControl: false});
|
||||||
|
@ -2762,11 +2792,11 @@ function openNearPosts(posts) {
|
||||||
let markersBounds = [];
|
let markersBounds = [];
|
||||||
let coords = [];
|
let coords = [];
|
||||||
|
|
||||||
posts.posts.forEach((post) => {
|
posts.forEach((post) => {
|
||||||
if (coords.includes(`${post.geo.lat} ${post.geo.lng}`)) {
|
if (coords.includes(`${post.geo.lat} ${post.geo.lng}`)) {
|
||||||
markerLayers.getLayers().forEach((marker) => {
|
markerLayers.getLayers().forEach((marker) => {
|
||||||
if (marker.getLatLng().lat === post.geo.lat && marker.getLatLng().lng === post.geo.lng) {
|
if (marker.getLatLng().lat === post.geo.lat && marker.getLatLng().lng === post.geo.lng) {
|
||||||
let content = marker.getPopup()._content += getPostPopup(post);
|
let content = marker.getPopup()._content += tplPost(post);
|
||||||
if (!content.startsWith(`<div style="max-height: 300px; overflow-y: auto;">`))
|
if (!content.startsWith(`<div style="max-height: 300px; overflow-y: auto;">`))
|
||||||
content = `<div style="max-height: 300px; overflow-y: auto;">${content}`;
|
content = `<div style="max-height: 300px; overflow-y: auto;">${content}`;
|
||||||
|
|
||||||
|
@ -2775,7 +2805,7 @@ function openNearPosts(posts) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let marker = L.marker(L.latLng(post.geo.lat, post.geo.lng)).addTo(map);
|
let marker = L.marker(L.latLng(post.geo.lat, post.geo.lng)).addTo(map);
|
||||||
marker.bindPopup(getPostPopup(post));
|
marker.bindPopup(tplPost(post));
|
||||||
markerLayers.addLayer(marker);
|
markerLayers.addLayer(marker);
|
||||||
markersBounds.push(marker.getLatLng());
|
markersBounds.push(marker.getLatLng());
|
||||||
}
|
}
|
||||||
|
@ -2790,11 +2820,11 @@ function openNearPosts(posts) {
|
||||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
$(".ovk-diag-cont").width('50%');
|
$(".ovk-diag-cont").width('80%');
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
map.invalidateSize()
|
map.invalidateSize()
|
||||||
}, 100);
|
}, 100);
|
||||||
} else {
|
} else {
|
||||||
MessageBox("Ближайшие посты", "<center style='color: grey;'>Нет ближайших постов :(</center>", ["OK"], [Function.noop]);
|
MessageBox(tr('nearest_posts'), `<center style='color: grey;'>${tr('no_nearest_posts')}</center>`, ["OK"], [Function.noop]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,10 @@ window.router = new class {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(url.indexOf('#close') != -1) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +238,11 @@ window.router = new class {
|
||||||
}
|
}
|
||||||
|
|
||||||
u(document).on('click', 'a', async (e) => {
|
u(document).on('click', 'a', async (e) => {
|
||||||
|
if(e.defaultPrevented) {
|
||||||
|
console.log('AJAX | Skipping because default is prevented')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const target = u(e.target).closest('a')
|
const target = u(e.target).closest('a')
|
||||||
const dom_url = target.attr('href')
|
const dom_url = target.attr('href')
|
||||||
const id = target.attr('id')
|
const id = target.attr('id')
|
||||||
|
@ -289,6 +298,10 @@ u(document).on('click', 'a', async (e) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
u(document).on('submit', 'form', async (e) => {
|
u(document).on('submit', 'form', async (e) => {
|
||||||
|
if(e.defaultPrevented) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if(u('#ajloader').hasClass('shown')) {
|
if(u('#ajloader').hasClass('shown')) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
return
|
return
|
||||||
|
|
|
@ -284,3 +284,30 @@ function collect_attachments_node(target)
|
||||||
})
|
})
|
||||||
vertical_input.nodes[0].value = vertical_array.join(',')
|
vertical_input.nodes[0].value = vertical_array.join(',')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function short_geo_name(address_osm)
|
||||||
|
{
|
||||||
|
let final_arr = []
|
||||||
|
if(address_osm.country) {
|
||||||
|
final_arr.push(address_osm.country)
|
||||||
|
}
|
||||||
|
if(address_osm.state) {
|
||||||
|
final_arr.push(address_osm.state)
|
||||||
|
}
|
||||||
|
if(address_osm.state_district) {
|
||||||
|
final_arr.push(address_osm.state_district)
|
||||||
|
}
|
||||||
|
if(address_osm.city) {
|
||||||
|
final_arr.push(address_osm.city)
|
||||||
|
} else if(address_osm.town) {
|
||||||
|
final_arr.push(address_osm.town)
|
||||||
|
}
|
||||||
|
if(address_osm.city_district) {
|
||||||
|
final_arr.push(address_osm.city_district)
|
||||||
|
}
|
||||||
|
if(address_osm.road) {
|
||||||
|
final_arr.push(address_osm.road)
|
||||||
|
}
|
||||||
|
|
||||||
|
return escapeHtml(final_arr.join(', '))
|
||||||
|
}
|
||||||
|
|
|
@ -282,11 +282,14 @@
|
||||||
"liked_by_x_people_other" = "Liked by $1 users";
|
"liked_by_x_people_other" = "Liked by $1 users";
|
||||||
"liked_by_x_people_zero" = "Nobody liked";
|
"liked_by_x_people_zero" = "Nobody liked";
|
||||||
|
|
||||||
|
"geo_place" = "Place";
|
||||||
"geotag" = "Geotag";
|
"geotag" = "Geotag";
|
||||||
"nearest_posts" = "Nearest posts";
|
"nearest_posts" = "Nearest posts";
|
||||||
"Latitude" = "Latitude";
|
"Latitude" = "Latitude";
|
||||||
"longitude" = "Longitude";
|
"longitude" = "Longitude";
|
||||||
"name_of_the_place" = "Name of the place";
|
"name_of_the_place" = "Place's name";
|
||||||
|
"no_nearest_posts" = "No nearby posts";
|
||||||
|
"shown_last_nearest_posts" = "Showing last $1 posts per month";
|
||||||
|
|
||||||
/* Friends */
|
/* Friends */
|
||||||
|
|
||||||
|
|
|
@ -260,11 +260,15 @@
|
||||||
"liked_by_x_people_many" = "Понравилось $1 людям";
|
"liked_by_x_people_many" = "Понравилось $1 людям";
|
||||||
"liked_by_x_people_other" = "Понравилось $1 людям";
|
"liked_by_x_people_other" = "Понравилось $1 людям";
|
||||||
"liked_by_x_people_zero" = "Никому не понравилось";
|
"liked_by_x_people_zero" = "Никому не понравилось";
|
||||||
"geotag" = "Геоточка";
|
|
||||||
|
"geo_place" = "Место";
|
||||||
|
"geotag" = "Геолокация";
|
||||||
"nearest_posts" = "Ближайшие посты";
|
"nearest_posts" = "Ближайшие посты";
|
||||||
"Latitude" = "Широта";
|
"Latitude" = "Широта";
|
||||||
"longitude" = "Долгота";
|
"longitude" = "Долгота";
|
||||||
"name_of_the_place" = "Название места";
|
"name_of_the_place" = "Название места";
|
||||||
|
"no_nearest_posts" = "Нет ближайших постов";
|
||||||
|
"shown_last_nearest_posts" = "Показаны последние $1 постов за месяц";
|
||||||
|
|
||||||
/* Friends */
|
/* Friends */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue