<div id="block"><? echo time(); ?></div>
<script>
(async function() {
var selector = '#block'; // Селектор блока, который надо обновлять
while (true) {
await new Promise(function(s) { setTimeout(s, 30*1000); }); // Каждые 30 сек.
try {
var html = await (await fetch(location.href)).text();
var newdoc = new DOMParser().parseFromString(html, 'text/html');
document.querySelector(selector).outerHTML = newdoc.querySelector(selector).outerHTML;
console.log('Элемент '+selector+' был успешно обновлен');
} catch(err) {
console.error('При обновлении элемента '+selector+' произошла ошибка:', err);
}
}
})();
</script>
Понятия не имею как с этим работать.Поскольку это даже не JSON, а сериализация средствами PHP, то единственный адекватный способ - получать все записи из БД, десериализовывать и в коде считать что нужно.
=ARRAYFORMULA(let(
author; "@ProgrammerForever";
dates; hook!A2:A;
type; hook!B2:B;
duration; hook!G2:G;
lookupdates;A2:A;
timestampTodate;lambda(unixTimestamp;(unixTimestamp/86400000)+ДАТА(1970;1;1));
toSqldate;lambda(d;ТЕКСТ(d;"yyyy-mm-dd"));
remove_header;lambda(data;query({data};"SELECT * OFFSET 1";0));
data;remove_header(query({toSqldate(timestampTodate(dates))\duration};"SELECT Col1, Sum(Col2) GROUP BY Col1"));
out;ЕСЛИОШИБКА(ВПР(toSqldate(lookupdates);data;2;0));
ЕСЛИ(lookupdates="";;out)
))
Можно ли сделать при этом перезагрузку на определённую ссылку
// window.location.reload();
window.location= 'http://example.com/next';
$(".buttonClass").on("click", function() {
$("#myDiv").load(location.href + " #myDiv");
})
async function elementUpdate(selector) {
try {
var html = await (await fetch(location.href)).text();
var newdoc = new DOMParser().parseFromString(html, 'text/html');
document.querySelector(selector).outerHTML = newdoc.querySelector(selector).outerHTML;
console.log('Элемент '+selector+' был успешно обновлен');
return true;
} catch(err) {
console.log('При обновлении элемента '+selector+' произошла ошибка:');
console.dir(err);
return false;
}
}
elementUpdate('table#test');
<button onclick="elementUpdate('table#test');">Нажми меня, чтобы обновить таблицу</button>
SELECT t1.sum_za_zakazy AS sum_za_zakazy, t2 .......
FROM ( SELECT COALESCE (sum(v2.meta_value),0) AS sum_za_zakazy
FROM wp_posts
JOIN wp_postmeta v1 ON (wp_posts.ID = v1.post_id)
JOIN wp_postmeta v3 ON (wp_posts.ID = v3.post_id)
JOIN wp_postmeta v2 ON (wp_posts.ID = v2.post_id)
WHERE wp_posts.post_type='zakazy'
AND wp_posts.post_status='publish'
AND v1.meta_value = '%current_field|id_uchastnika%'
AND v3.meta_value
BETWEEN '%current_field|data_1%' AND '%current_field|data_2%'
AND (
(v1.meta_key = 'id_shvei_1' AND v2.meta_key = 'summa_shvei_1' AND v3.meta_key = 'shveia-1-data')
OR (v1.meta_key = 'id_shvei_2' AND v2.meta_key = 'summa_shvei_2' AND v3.meta_key = 'shveia-2-data')
OR (v1.meta_key = 'id_shvei_3' AND v2.meta_key = 'summa_shvei_3' AND v3.meta_key = 'shveia-3-data')
OR (v1.meta_key = 'id_razborshhika_1' AND v2.meta_key = 'summa_razborshhika_1' AND v3.meta_key = 'razborshchik-1-data')
OR (v1.meta_key = 'id_razborshhika_2' AND v2.meta_key = 'summa_razborshhika_2' AND v3.meta_key = 'razborshchik-2-data')
OR (v1.meta_key = 'id_sborshhika_1' AND v2.meta_key = 'summa_sborshhika_1' AND v3.meta_key = 'sborshchik-1-data')
OR (v1.meta_key = 'id_sborshhika_2' AND v2.meta_key = 'summa_sborshhika_2' AND v3.meta_key = 'sborshchik-2-data')
OR (v1.meta_key = 'id_sborshhika_3' AND v2.meta_key = 'summa_sborshhika_3' AND v3.meta_key = 'sborshchik-3-data')
OR (v1.meta_key = 'id_dostavki_v_czeh' AND v2.meta_key = 'czena_dostavki_v_czeh' AND v3.meta_key = 'data-zabora')
OR (v1.meta_key = 'id_dostavki_iz_czeha' AND v2.meta_key = 'czena_dostavki_iz_czeha' AND v3.meta_key = 'data-dostavki')
OR (v1.meta_key = 'id_menedzhera' AND v2.meta_key = 'summa_menedzhera' AND v3.meta_key = 'data-zakaza')
)) t1
CROSS JOIN( SELECT COALESCE (sum(v2.meta_value),0) AS ....... t2
SELECT (
SELECT sum(wp_postmeta.meta_value) AS result
FROM wp_posts
JOIN wp_postmeta ON wp_postmeta.post_id = wp_posts.ID
WHERE wp_posts.post_status='publish' and wp_posts.post_type='zakazy-tsekha'
AND wp_postmeta.meta_key='summa_zakaza'
) - (
SELECT sum(wp_jet_cct_raskhody.tsena_raskhoda)
FROM wp_jet_cct_raskhody
) AS result
-- Query 1: All records
SELECT
wp_posts.post_title,
CASE
WHEN v1.meta_key = 'id_sotrudnika' AND v2.meta_key = 'summa_poluchennoj_zarplaty'
THEN -v2.meta_value
ELSE v2.meta_value
END AS netto
FROM wp_posts
JOIN wp_postmeta v1 ON (wp_posts.ID = v1.post_id)
JOIN wp_postmeta v2 ON (wp_posts.ID = v2.post_id)
WHERE
v1.meta_key IN ('id_rab_1', 'id_sotrudnika') AND v1.meta_value = '981' AND
v2.meta_key IN ('summa_rab_1', 'summa_rab_2', 'summa_poluchennoj_zarplaty');
-- Query 2: Summarized records
SELECT
wp_posts.post_title,
SUM(CASE
WHEN v1.meta_key = 'id_sotrudnika' AND v2.meta_key = 'summa_poluchennoj_zarplaty'
THEN -v2.meta_value
ELSE v2.meta_value
END) AS netto
FROM wp_posts
JOIN wp_postmeta v1 ON (wp_posts.ID = v1.post_id)
JOIN wp_postmeta v2 ON (wp_posts.ID = v2.post_id)
WHERE
v1.meta_key IN ('id_rab_1', 'id_sotrudnika') AND v1.meta_value = '981' AND
v2.meta_key IN ('summa_rab_1', 'summa_rab_2', 'summa_poluchennoj_zarplaty');
VLOOKUP
=INDEX(IFERROR(VLOOKUP(A:A;'Данные'!A:B;2;)))
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Моя навигация')
.addItem('Ячейка A555', 'menuItem1')
.addSeparator()
.addSubMenu(ui.createMenu('Важно')
.addItem('Ячейка H555', 'menuItem2'))
.addToUi();
}
function menuItem1() {
SpreadsheetApp.getUi()
SpreadsheetApp.getActiveSheet().getRange('A555').activate();
}
function menuItem2() {
SpreadsheetApp.getUi()
SpreadsheetApp.getActiveSheet().getRange('h555').activate();
}
const goToWrapper_ = (address) => {
const range = getRangeByRefString_(SpreadsheetApp.getActiveSheet(), address);
range.getSheet().getRange('A1').activate();
range.activate();
}
function getRangeByRefString_(sheet, refString) {
return refString.indexOf('!') === -1 ?
sheet.getRange(refString) :
sheet.getParent().getRange(refString);
}
function goTo555() {
goToWrapper_('A555');
}
function goToSheet5A555() {
goToWrapper_('Sheet5!A555');
}