HUGE REFACTOR / CLEANUP
if there is a issue it's probably something in here that was changed
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/* Xeslint-disable */
|
||||
|
||||
/////////////////////////////////
|
||||
// General utility library
|
||||
//
|
||||
@@ -206,7 +204,7 @@ export default {
|
||||
if (!number || number == 0 || number == NaN) {
|
||||
return number;
|
||||
}
|
||||
let wasNegative = number < 0;
|
||||
const wasNegative = number < 0;
|
||||
if (wasNegative) {
|
||||
number = Math.abs(number); //make sure it's positive because rounding negative numbers is weird in JS
|
||||
}
|
||||
@@ -223,29 +221,6 @@ export default {
|
||||
// Clean up a tag with same rules as server
|
||||
//
|
||||
normalizeTag: function(tagName) {
|
||||
/*
|
||||
SERVER VERSION
|
||||
public static string NormalizeTag(string inObj)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(inObj)) return null;
|
||||
//Must be lowercase per rules
|
||||
//This may be naive when we get international cust omers but for now supporting utf-8 and it appears it's safe to do this with unicode
|
||||
inObj = inObj.ToLowerInvariant();
|
||||
//No spaces in tags, replace with dashes
|
||||
inObj = inObj.Replace(" ", "-");
|
||||
//Remove multiple dash sequences
|
||||
inObj = System.Text.RegularExpressions.Regex.Replace(inObj, "-+", "-");
|
||||
//Ensure doesn't start or end with a dash
|
||||
inObj = inObj.Trim('-');
|
||||
//No longer than 255 characters
|
||||
inObj = StringUtil.MaxLength(inObj, 255);
|
||||
return inObj;
|
||||
}
|
||||
*/
|
||||
//de-lodash
|
||||
//kebab case takes care of all the things we need for tags in one go
|
||||
// tagName = window.$gz. _.kebabCase(tagName);
|
||||
|
||||
if (!tagName || tagName == "") {
|
||||
return null;
|
||||
}
|
||||
@@ -271,9 +246,9 @@ export default {
|
||||
// https://stackoverflow.com/a/7616484/8939
|
||||
//
|
||||
quickHash: function(theString) {
|
||||
let hash = 0,
|
||||
i,
|
||||
chr;
|
||||
let hash = 0;
|
||||
let i;
|
||||
let chr;
|
||||
if (theString.length === 0) return hash;
|
||||
for (i = 0; i < theString.length; i++) {
|
||||
chr = theString.charCodeAt(i);
|
||||
@@ -289,10 +264,9 @@ export default {
|
||||
// using 32 character (128 bit) as default
|
||||
//
|
||||
getRandomPassword: function() {
|
||||
let length = 32,
|
||||
wishlist = "0123456789abcdefghijkmnopqrstuvwxyz";
|
||||
const wishlist = "0123456789abcdefghijkmnopqrstuvwxyz";
|
||||
|
||||
return Array.from(crypto.getRandomValues(new Uint32Array(length)))
|
||||
return Array.from(crypto.getRandomValues(new Uint32Array(32)))
|
||||
.map(x => wishlist[x % wishlist.length])
|
||||
.join("");
|
||||
},
|
||||
@@ -337,7 +311,7 @@ export default {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let ret = parseFloat(string.replace(/[^\d.-]/g, ""));
|
||||
const ret = parseFloat(string.replace(/[^\d.-]/g, ""));
|
||||
if (ret == NaN) {
|
||||
return 0;
|
||||
}
|
||||
@@ -582,8 +556,8 @@ export default {
|
||||
}
|
||||
mimeType = mimeType.toLowerCase();
|
||||
|
||||
let iconFromExtension = extensions[extension];
|
||||
let iconFromMIME = mimeTypes[mimeType];
|
||||
const iconFromExtension = extensions[extension];
|
||||
const iconFromMIME = mimeTypes[mimeType];
|
||||
|
||||
if (iconFromMIME) {
|
||||
return iconFromMIME;
|
||||
@@ -643,8 +617,8 @@ export default {
|
||||
// https://stackoverflow.com/a/55292366/8939
|
||||
//
|
||||
trimSpecific: function trim(str, ch) {
|
||||
var start = 0,
|
||||
end = str.length;
|
||||
var start = 0;
|
||||
var end = str.length;
|
||||
while (start < end && str[start] === ch) ++start;
|
||||
while (end > start && str[end - 1] === ch) --end;
|
||||
return start > 0 || end < str.length ? str.substring(start, end) : str;
|
||||
@@ -661,23 +635,6 @@ export default {
|
||||
// is string replacement for lodash
|
||||
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_isString
|
||||
//
|
||||
// isString: function(str) {
|
||||
// //modified from above, due to bug (I think)
|
||||
// //posted case here: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/issues/304
|
||||
// if (str == null) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (str == "") {//another bug, if numeric this is true?! Using recommended method below
|
||||
// return true;
|
||||
// }
|
||||
// let temp = str.valueOf();
|
||||
// if (typeof temp === "string") {
|
||||
// return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// },
|
||||
isString: function(str) {
|
||||
return str != null && typeof str.valueOf() === "string";
|
||||
},
|
||||
@@ -790,25 +747,13 @@ export default {
|
||||
//
|
||||
//
|
||||
viewGeoLocation: function(obj) {
|
||||
/*
|
||||
{
|
||||
latitude: m.vm.obj.latitude,
|
||||
longitude: m.vm.obj.longitude,
|
||||
address: m.vm.obj.address || m.vm.obj.postAddress,
|
||||
city: m.vm.obj.city || m.vm.obj.postCity,
|
||||
region: m.vm.obj.region || m.vm.obj.postRegion,
|
||||
country: m.vm.obj.country || m.vm.obj.postCountry,
|
||||
postCode: m.vm.obj.postCode
|
||||
}
|
||||
*/
|
||||
|
||||
let hasGeo =
|
||||
const hasGeo =
|
||||
obj.latitude != null &&
|
||||
obj.latitude != 0 &&
|
||||
obj.longitude != null &&
|
||||
obj.longitude != 0;
|
||||
|
||||
let hasAddress =
|
||||
const hasAddress =
|
||||
!this.stringIsNullOrEmpty(obj.address) &&
|
||||
!this.stringIsNullOrEmpty(obj.city) &&
|
||||
!this.stringIsNullOrEmpty(obj.region) &&
|
||||
@@ -857,7 +802,7 @@ export default {
|
||||
//order street to country seems to be standard
|
||||
//note, if google need plus symbol delimiter, if bing, need comma delimiter
|
||||
//but both might accept one big string space delimited and url encoded so test that on all first
|
||||
let delimiter = " ";
|
||||
const delimiter = " ";
|
||||
let q = "";
|
||||
if (obj.address) {
|
||||
q += obj.address + delimiter;
|
||||
@@ -949,15 +894,6 @@ export default {
|
||||
//
|
||||
//
|
||||
calendarViewToAyaNovaEnum: function(view) {
|
||||
/*
|
||||
public enum ScheduleView : int
|
||||
{
|
||||
Day = 1,
|
||||
Week = 2,
|
||||
Month = 3,
|
||||
Day4 = 4
|
||||
}
|
||||
*/
|
||||
switch (view) {
|
||||
case "day":
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user