У меня есть скрипт как работает меня устраивает, но не могу сообразить как сделать что бы он постоянно обновлялся.
То есть я загрузил страницу там все данные которые мне нужны, но проходит минута должно бы все изменится но не меняется
<div id="work_schedule">
<p id="current_time" class="line"></p>
<p id="hours" class="line"></p>
<p id="dot" class="line">:</p>
<p id="minutes" class="line"></p>
<p id="statys"></p>
<p id="remains"></p>
</div>
// JavaScript Document
let localTime = new Date;
let hours = localTime.getHours();
let minutes = localTime.getMinutes();
let dot = document.getElementById("dot");
dot.style.color = "black";
let currentTime = document.getElementById("current_time");
let hoursInput = document.getElementById("hours");
let minutesInput = document.getElementById("minutes");
let statys = document.getElementById("statys");
let remains = document.getElementById("remains");
let hoursOpen = 8;
let hoursClose = 20;
let oneMinuts = 60;
let rezult_1 = "";
let rezult_2 = "";
let endingHour = "";
let endingHour_2 = ["с","са","сов"];
let endingMinut = "";
let endingMinut_2 = ["a","ы"];
let open = "До отрытие ";
let close = "До закрытие ";
let openClose = "";
function sec() {
if(dot.style.color == "black") {
dot.style.color = "white";
}
else {
dot.style.color = "black";
}
}
setInterval(sec, 1000);
function openCloseStatys(){
if(hours <= 8){
statys.innerHTML = `Закрыто`;
statys.style.backgroundImage = "url('close.png')";
}
else if(hours >= 20){
statys.innerHTML = `Закрыто`;
statys.style.backgroundImage = "url('close.png')";
}
else if(hours >= 8){
statys.innerHTML = `Открыто`;
statys.style.backgroundImage = "url('open.png')";
}
}
openCloseStatys();
function remainsFun(){
if(hours>=20){
openClose = open;
}
else if(hours>=0&&hours<=8){
openClose = open;
}
else if(hours>=8&&hours<=20){
openClose = close;
}
}
remainsFun();
function timeHours(){
if(hours>=20&&hours<=23){
rezult_1 = hoursOpen - hours + 24;
}
else if(hours>=0&&hours<=8){
rezult_1 = hoursOpen - hours;
}
else if(hours>=8&&hours<=20){
rezult_1 = hoursClose - hours;
}
}
timeHours();
function timeMinuts(){
rezult_2 = oneMinuts - minutes;
if(rezult_2>=0&&rezult_2<=9){
rezult_2 = "0" + rezult_2;
}
}
timeMinuts();
function timeZero(){
if(minutes<=9){
minutes = "0" + minutes;
}
if(hours<=9){
hours = "0" + hours;
}
}
timeZero();
function endingHourFun(){
if(rezult_1==1){
endingHour = endingHour_2[0];
}
else if(rezult_1>=2&&rezult_1<=4){
endingHour = endingHour_2[1];
}
else if(rezult_1>=5&&rezult_1<=23){
endingHour = endingHour_2[2];
}
}
endingHourFun();
function endingMinutFun(){
if(rezult_2==1){
endingMinut = endingMinut_2[0];
}
else if(rezult_2>=2&&rezult_2<=4){
endingMinut = endingMinut_2[1];
}
else if(rezult_2>=5&&rezult_2<=20){
endingMinut = endingMinut;
}
else if(rezult_2==21){
endingMinut = endingMinut_2[0];
}
else if(rezult_2>=22&&rezult_2<=24){
endingMinut = endingMinut_2[1];
}
else if(rezult_2>=25&&rezult_2<=30){
endingMinut = endingMinut;
}
else if(rezult_2==31){
endingMinut = endingMinut_2[0];
}
else if(rezult_2>=32&&rezult_2<=34){
endingMinut = endingMinut_2[1];
}
else if(rezult_2>=35&&rezult_2<=40){
endingMinut = endingMinut;
}
else if(rezult_2==41){
endingMinut = endingMinut_2[0];
}
else if(rezult_2>=42&&rezult_2<=44){
endingMinut = endingMinut_2[1];
}
else if(rezult_2>=45&&rezult_2<=50){
endingMinut = endingMinut;
}
else if(rezult_2==51){
endingMinut = endingMinut_2[0];
}
else if(rezult_2>=52&&rezult_2<=54){
endingMinut = endingMinut_2[1];
}
else if(rezult_2>=55&&rezult_2<=60){
endingMinut = endingMinut;
}
}
endingMinutFun();
currentTime.innerHTML = `Текущие время`;
hoursInput.innerHTML = `${hours}`;
minutesInput.innerHTML = `${minutes}`;
remains.innerHTML = `${openClose}${rezult_1} ча${endingHour} ${rezult_2} минут${endingMinut}`;