PageSourceSearch

https://asce7tsunami.online/app/js/utils/Utilities.js?0.1.40

js asce7tsunami.online collected 2026-10-04 13:25:34 UTC 4,473 bytes, 130 lines download raw bytes

1define(['exports', 'lodash'], function (exports, _lodash) {
2  'use strict';
3
4  Object.defineProperty(exports, '__esModule', {
5    value: true
6  });
7
8  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9
10  var _2 = _interopRequireDefault(_lodash);
11
12  var Utilities = {
13
14    romanize: function romanize(num) {
15      if (typeof num !== 'number') {
16        return NaN;
17      }
18
19      var digits = String(+num).split(''),
20          key = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'],
21          roman = '',
22          i = 3;
23      while (i--) {
24        roman = (key[+digits.pop() + i * 10] || '') + roman;
25      }
26      return Array(+digits.join('') + 1).join('M') + roman;
27    },
28
29    //Only converts feet to meters and vice versa
30    standardsConversionFeetMeters: function standardsConversionFeetMeters(inputValue, inputType, outputType) {
31      if (inputType === outputType) {
32        return Number(inputValue).toFixed(2);
33      }
34      if (outputType === 'si') {
35        return (Number(inputValue) * 0.3048).toFixed(2);
36      }
37      if (outputType === 'imperial') {
38        return (Number(inputValue) / 0.3048).toFixed(2);
39      }
40    },
41
42    generateUUID: function generateUUID() {
43      return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
44        var r = Math.random() * 16 | 0,
45            v = c == 'x' ? r : r & 0x3 | 0x8;
46        return v.toString(16);
47      });
48    },
49
50    downloadCSV: function downloadCSV(data, measurementUnits) {
51      var filename = '';
52      var csv = '';
53      var mimeType = 'text/csv;encoding:utf-8';
54
55      if (data.hasOwnProperty('amplitudeRange')) {
56        filename = 'offshore-tsunami-amplitudes.csv';
57        csv = measurementUnits === 'imperial' ? 'Latitude,Longitude,Amplitude(ft.),Period(min.)\n' : 'Latitude,Longitude,Amplitude(m),Period(min.)\n';
58
59        _2['default'].forEach(data.amplitudeRange, function (amplitude) {
60          var line = amplitude.latitude + ',' + amplitude.longitude + ',' + amplitude.amplitude + ',' + amplitude.period + '\n';
61          csv += line;
62        });
63      } else {
64        filename = data.name + '_transect.csv';
65        csv = measurementUnits === 'imperial' ? 'Transect,Latitude,Longitude,Transect Distance(ft.),Elevation MHW (ft.)\n' : 'Transect,Latitude,Longitude,Transect Distance(m),Elevation MHW (m)\n';
66        _2['default'].forEach(data.elevationData.elevations, function (elevation, index) {
67          var _data$elevationData = data.elevationData;
68          var latitudes = _data$elevationData.latitudes;
69          var longitudes = _data$elevationData.longitudes;
70          var intervals = _data$elevationData.intervals;
71
72          var line = data.name + ' Transect,' + latitudes[index] + ',' + longitudes[index] + ',' + intervals[index] + ',' + elevation + '\n';
73          csv += line;
74        });
75      }
76
77      var element = document.getElementById('csv-download');
78      if (navigator.msSaveBlob) {
79        navigator.msSaveBlob(new Blob([csv], {
80          type: mimeType
81        }), filename);
82      } else {
83        element.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
84        element.target = '_blank';
85        element.download = filename;
86        element.click();
87      }
88    },
89
90    rotateLabel: function rotateLabel(x1, y1, x2, y2) {
91      var x = x2 - x1;
92      var y = y2 - y1;
93      var theta = Math.atan2(-y, x);
94
95      if (theta < 0) {
96        theta += 2 * Math.PI;
97      };
98
99      var degrees = theta * (180 / Math.PI);
100
101      if (degrees > 90 && degrees < 270) {
102        degrees += 180;
103      }
104
105      return degrees;
106    },
107
108    midpoint: function midpoint(x1, y1, x2, y2) {
109      var x = (x1 + x2) / 2;
110      var y = (y1 + y1) / 2;
111
112      return { x: x, y: y };
113    }
114
115  };
116
117  var generateUUID = Utilities.generateUUID;
118  exports.generateUUID = generateUUID;
119  var romanize = Utilities.romanize;
120  exports.romanize = romanize;
121  var standardsConversionFeetMeters = Utilities.standardsConversionFeetMeters;
122  exports.standardsConversionFeetMeters = standardsConversionFeetMeters;
123  var downloadCSV = Utilities.downloadCSV;
124  exports.downloadCSV = downloadCSV;
125  var rotateLabel = Utilities.rotateLabel;
126  exports.rotateLabel = rotateLabel;
127  var midpoint = Utilities.midpoint;
128  exports.midpoint = midpoint;
129});
130//# sourceMappingURL=Utilities.js.map

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.