使用txt文件重复开放时间



这是一个公认的定时关闭。是否有可能从例如。txt文件中获得var onlineweekdays ={}之间的值?也就是说,打开时间不会在这个脚本中设置,而是在另一个文件中设置。这是必要的,这样我的员工就不必摆弄代码了。但它也可以作为从Outlook (M365)日历中获取数据的解决方案。这有可能吗,这些变体能被解决吗?

<script>
var a = document.getElementById("online");
var d = new Date();
var n = d.getDay();
var now = d.getHours() + "." + d.getMinutes();
var onlineweekdays = {
0: null, //Vasárnap
1: [6.30, 16.30], //hétfő
2: [6.30, 16.30], //kedd
3: [6.30, 16.30], //szerda
4: [6.30, 16.30], //csütörtök
5: [6.30, 15.30], //péntek
6: null //Szombat
};
var onlinedayWorkingHours = onlineweekdays[n]; //Today working hours. if null we are close
if (onlinedayWorkingHours && (now > onlinedayWorkingHours[0] && now < onlinedayWorkingHours[1])) {
// check if current time is during or beyond 15 minutes before closing time
if (isFifteenMinBeforeOut2(now, onlinedayWorkingHours[1])) {
a.innerHTML = "rövidesen zárunk."; 
a.style.backgroundColor = '#fee599'; 
a.style.color = '#7f6000';
a.style.textTransform = 'uppercase';
a.style.fontWeight = 'bold';
a.style.padding = '0 4px';
a.style.borderRadius = '3px';
a.style.marginLeft ='5px';
} 
else {
a.innerHTML = "most elérhető."; 
a.style.backgroundColor = '#e2efd9'; 
a.style.color = '#538135';
a.style.textTransform = 'uppercase';
a.style.fontWeight = 'bold';
a.style.padding = '0 4px';
a.style.borderRadius = '3px';
a.style.marginLeft ='5px';
} 
} else {
a.innerHTML = "most nem érhető el.";
a.style.backgroundColor = '#efd9df'; 
a.style.color = '#c91f41';
a.style.textTransform = 'uppercase';
a.style.fontWeight = 'bold';
a.style.padding = '0 4px';
a.style.borderRadius = '3px';
a.style.marginLeft ='5px';
}
function isFifteenMinBeforeOut2(current, clockout) {
return current >= clockout - 0.10;
}
</script>

不能从客户端的文件中访问数据,因为浏览器限制了对文件系统的访问。

要获得动态的值列表,您必须执行

  • 配置自己的后端来托管数据(或从outlook获取)。
  • 将配置放在Pastebin之类的地方,并通过网络请求获取

如果数据不包含敏感细节,并且您不想设置后端,您可以选择第二种方法。

最新更新