PageSourceSearch

https://www.stadtwerk-am-see.de/de/static/js/HRSysLib/Hilfsfunktionen/File.js?nc=1790923960777

js stadtwerk-am-see.de collected 2026-10-04 00:25:37 UTC 1,955 bytes, 59 lines download raw bytes

1/***************************************************************************
2// Firma:      Hehner Reus Systems GmbH
3// Projekt:    com.cerno.basis
4// Datei:      File.js
5// Erstellung: 22.12.2025
6// Verwendung: Hilfsfunktionen für den Umgang mit Files.
7/***************************************************************************/
8
9'use strict';
10
11class HRFiles
12{
13   /**
14    * Rechnet die Dateigröße in Bytes in die höchstmögliche Speichereinheit um (TB, GB, MB, KB, B)
15    * und gibt die Größe mit der angegebenen Anzahl an Dezimalstellen zurück.
16    *
17    * @param {number} filesizeInByte - Die Größe der Datei in Bytes.
18    * @param {number} decimalPlaces - Die Anzahl der Dezimalstellen, auf die die Größe gerundet werden soll.
19    * @returns {string} - Die umgerechnete Dateigröße als String mit der entsprechenden Einheit (z. B. "1.23GB").
20    */
21   static printFileSize(filesizeInByte, decimalPlaces = 1)
22   {
23      let result = "";
24      try
25      {
26         let selectedSize = 0;
27         let selectedUnit = "B";
28         if (filesizeInByte > 0)
29         {
30            const units = ["TB", "GB", "MB", "KB", "B"];
31            
32            for (let i = 0; i < units.length; i++)
33            {
34               const unit = units[i];
35               const cutoff = Math.pow(1000, 4 - i) / 10;
36               
37               if (filesizeInByte >= cutoff)
38               {
39                  selectedSize = filesizeInByte / Math.pow(1000, 4 - i);
40                  selectedUnit = unit;
41                  break;
42               }
43            }
44            
45            // Rundung auf die gewünschte Anzahl an Dezimalstellen.
46            selectedSize = Math.round(selectedSize * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces);
47         }
48         
49         result = selectedSize + selectedUnit;
50      }
51      catch (e)
52      {
53         if (typeof(HRLogError) === 'function')
54            HRLogError(e);
55      }
56      
57      return result;
58   }
59}

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.