PageSourceSearch

https://www.havencityhall.org/1723204579/pos-app/js/lib.js

js havencityhall.org collected 2026-09-25 10:58:10 UTC 4,012 bytes, 169 lines download raw bytes

1var fnToJason = function() {
2    var tmp = {};
3    for(var key in this) {
4        if(typeof this[key] !== 'function') {
5            tmp[key] = this[key];
6    	}
7    }
8    return tmp;
9};
10
11var arrayDiff = function(a1, a2) {
12  var a=[], diff=[];
13  for(var i=0;i<a1.length;i++)
14    a[a1[i]]=true;
15  for(var i=0;i<a2.length;i++)
16    if(a[a2[i]]) delete a[a2[i]];
17    else a[a2[i]]=true;
18  for(var k in a)
19    diff.push(k);
20  return diff;
21}
22
23function checkAndFixNumber(number) {
24	"use strict";
25	var return_value = number;
26	if(typeof number === 'undefined' || number === null || number === '') {
27		return_value = 0.00;
28	}
29	if(typeof number === 'number' && isNaN(number)) {
30		return_value = 0.00;
31	}
32	if (return_value !== 0) {
33		return_value = parseFloat(number);
34	}
35
36	return return_value;
37}
38
39function fractionalMultiplication(firstNumber, secondNumber) {
40	if (isNaN(firstNumber) || isNaN(secondNumber)) {
41		return 0;
42	}
43
44	return Number(new Big(Number(firstNumber)).times(Number(secondNumber)));
45}
46
47function roundAndReturnNumber(number, precision) {
48	"use strict";
49	var checked_number = checkAndFixNumber(number);
50	if((typeof precision === 'undefined') || (isNaN(precision)) || (null === precision)) {
51		precision = 2;
52	}
53
54	var isNegative = false;
55	if (checked_number < 0) {
56	    isNegative = true;
57        checked_number = -checked_number;
58    }
59
60	var value = Number(Math.round(checked_number + 'e+' + precision)  + ('e-' + precision));
61	if (isNegative) {
62	    value = -value;
63    }
64
65	return value;
66}
67
68function fixFloat(input_number, min) {
69    "use strict";
70	var number = checkAndFixNumber(input_number);
71
72	if((typeof min === 'undefined') || (isNaN(min))) {
73		min = 2;
74	}
75	var tmp = parseFloat(number);
76	if (isNaN(tmp)) {
77		tmp = parseInt(tmp);    // this stupid step should remove the formatting from the string...
78		if (isNaN(tmp)) {
79			return 0;
80		} else {
81			tmp = tmp + parseFloat('0.00000000');
82		}
83	}
84
85	var rounding_power = Math.pow(10,min);
86	number = parseFloat(number);
87	number = Math.round(number * rounding_power) / rounding_power; // should round to 2 decimal places...
88	//number = parseFloat(number).toPrecision(min);
89	return parseFloat(number);
90}
91
92function subFloats(input_number1, input_number2, min) {
93    "use strict";
94
95	if((typeof min === 'undefined') || (isNaN(min))) {
96		min = 2;
97	}
98	var number1 = fixFloat(input_number1, min);
99	var number2 = fixFloat(input_number2, min);
100
101	var rounding_power = Math.pow(10,min);
102	var result = (Math.round(number1 * rounding_power) - Math.round(number2 * rounding_power)) / rounding_power;
103
104	return parseFloat(result);
105}
106
107// function used to clearly delineate what type of object something is...
108// returns a string
109Object.toType = (function toType(global) {
110    "use strict";
111    return function(obj) {
112        if (obj === global) {
113            return "global";
114        }
115        return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
116    };
117})(this);
118
119Object.jsonifyStringifiedJsonAttributes = (function(Obj) {
120    "use strict";
121
122    for (var attribute in Obj) {
123        if (Obj.hasOwnProperty(attribute)) {
124            if (typeof Obj[attribute] === 'string') {
125                try {
126                   if ( /^[\[|\{].*[\]|\}]$/.test(Obj[attribute])) {
127                       Obj[attribute] = JSON.parse(Obj[attribute]);
128                   }
129                } catch (error) {
130                }
131            }
132        }
133    }
134});
135
136var typingTimeout;
137var t0 = 0;
138var t1 = 0;
139var typeSpeedCounter = 0;
140var barcodeInput = false;
141function typeSpeed(time) {
142	if (t0 === 0) {
143		t0 = time;
144	} else {
145		t1 = time;
146	}
147	typeSpeedCounter++;
148}
149
150function isBarcode() {
151	barcodeScan = false;
152	if (t0 > 0 && t1 > 0 && typeSpeedCounter >= 4) {
153		var tDiff = t1-t0;
154		//console.log('Diff = ' + tDiff);
155		var tAvg = tDiff / typeSpeedCounter;
156		//console.log('Avg = ' + tAvg);
157		if (tAvg < 50) {		
158			barcodeScan = true;
159		}
160	}
161	t0 = 0;
162	t1 = 0;
163	typeSpeedCounter = 0;	
164	barcodeInput = barcodeScan;
165	//console.log("Return " + barcodeScan);
166	return barcodeScan;
167}
168
169

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.