PageSourceSearch

https://bezdroza.pl/assets/js/time.js

js bezdroza.pl collected 2026-09-25 23:50:28 UTC 1,520 bytes, 47 lines download raw bytes

1/**
2 * Backwards compatible & shortcut access to HMS timer
3 * @param {string} selectorId - DOM element id to replace its html content
4 */
5function calculateHMSleft(selectorId = 'timer') {
6  getIntervalTo(selectorId, null, 'hms');
7}
8
9/**
10 * Remaining period timer calculator
11 * @param {string} selectorId - DOM element id to replace its html content
12 * @param {Date} to - point in time to calculate remaining period
13 * @param {string} format - content format:
14 *  'common': 03g:30m.55s
15 *  'hms': 03 godz 30 min
16 */
17function getIntervalTo(selectorId, to = null, format = 'common') {
18  let now = new Date();
19    // default behavior - today's 23:59:59
20    if (to == null) {
21      to = new Date();
22      to.setHours(23);
23      to.setMinutes(59);
24      to.setSeconds(59);
25    }
26  let diff = Math.abs(to.getTime() - now.getTime());
27
28  let hoursleft = Math.floor(diff / (1000 * 60 * 60));
29  let minutesleft = Math.floor( diff / (1000 * 60) - hoursleft * 60);
30  let secondsleft = Math.floor(diff / 1000 - hoursleft * 60 * 60 - minutesleft * 60);
31
32  if (minutesleft < 10) minutesleft = "0" + minutesleft;
33  if (secondsleft < 10) secondsleft = "0" + secondsleft;
34  if (hoursleft < 10) hoursleft = "0" + hoursleft;
35  
36  let htmlContent = '';
37  switch(format) {
38    case 'hms':
39      htmlContent = hoursleft + " godz " + minutesleft + " min";
40    break;
41    default:
42      htmlContent = hoursleft + "g:" + minutesleft + "m." + secondsleft + "s";
43    break;
44    
45  }
46  document.getElementById(selectorId).innerHTML = htmlContent;
47};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.