diff --git a/composer.json b/composer.json index 7e67850..d0d45dc 100644 --- a/composer.json +++ b/composer.json @@ -15,11 +15,12 @@ "platform-check": false }, "require": { + "php": "^7.4 | 8.*", "ext-pdo": "*", "ext-json": "*", "ext-curl": "*", - "psr/log": "^1.1", - "curl/curl": "^2.3.0" + "psr/log": "*", + "curl/curl": "^2" }, "autoload": { "psr-4": { @@ -37,5 +38,8 @@ "target": "admin/longreads.tpl" } ] + }, + "require-dev": { + "rector/rector": "^1.2" } } diff --git a/extra/longreads.js b/extra/longreads.js index cbe49cd..9759f09 100644 --- a/extra/longreads.js +++ b/extra/longreads.js @@ -2,30 +2,38 @@ * jQuery required */ $(function () { + window.longreads = window.longreads || []; + + let URLS = { + IMPORT: '/longreads/import/', + DELETE: '/longreads/delete/', + TOGGLE: '/longreads/page_toggle/', + ADD: '/longreads/page_add/', + GET_PAGES_LIST: '/longreads/get_tilda_pages_list/', + }; // Шаблон строки для новой страницы - let template_pagerow = '\ - \ - %projectid%\ - %date%\ - \ -

%title%

\ -

%descr%

\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - '; - - /* =========== ФУНКЦИИ ============ */ + let template_pagerow = ` + + %projectid% + %date% + +

%title%

+

%descr%

+ + + + + + + + + + + `; /** * Удалить страницу @@ -34,7 +42,7 @@ $(function () { */ function page_delete(id) { disable_buttons(); - $.post('/longreads/delete/', { + $.post(URLS.DELETE, { id: id }, function (response) { if (response === 'ok') { @@ -55,7 +63,7 @@ $(function () { */ function page_toggle(id, toggle) { disable_buttons(); - $.post('/longreads/page_toggle/', { + $.post(URLS.TOGGLE, { id: id, toggle: toggle }, function (response) { @@ -110,7 +118,7 @@ $(function () { function page_import(id, folder, update = false) { message('Идет импорт страницы...'); disable_buttons(); - $.post('/longreads/import/', { + $.post(URLS.IMPORT, { id: id, folder: folder, update: update }).complete(function (response) { @@ -215,7 +223,7 @@ $(function () { message('Идет получение страниц по Tilda API...'); disable_buttons(); - $.post('/longreads/get_tilda_pages_list/', { }, function (data) { + $.post(URLS.GET_PAGES_LIST, { }, function (data) { // Если ответ от Tilda не получен if (data.status !== 'FOUND' || !data.result) { @@ -253,7 +261,7 @@ $(function () { // добавляем запись о лонгриде в базу complete = false; - $.post('/longreads/page_add/', { + $.post(URLS.ADD, { page: page }, function (response) { if (response === 'ok') { diff --git a/extra/longreads.tpl b/extra/longreads.tpl index 83c44f7..a3b04f1 100644 --- a/extra/longreads.tpl +++ b/extra/longreads.tpl @@ -71,11 +71,11 @@ {$longread.id}: '{$longread.date}', {/foreach} }; - let showhidden = false; + window.showhidden = false; let tildapages; -