Skip to content
Snippets Groups Projects
Unverified Commit e6d55b89 authored by xgui3783's avatar xgui3783 Committed by GitHub
Browse files

Merge pull request #996 from FZJ-INM1-BDA/pr_removeSOImpl

chore: remove SO impl
parents 8f0e188c b8bd13e1
No related branches found
No related tags found
No related merge requests found
......@@ -47,10 +47,6 @@
return true
}
/**
*
* https://stackoverflow.com/a/16348977/6059235
*/
exports.strToRgb = str => {
if (typeof str !== 'string') throw new Error(`strToRgb input must be typeof string !`)
......
......@@ -144,9 +144,6 @@ for (const key in parsed){
* The constraint is that the cipher needs to be commpatible with URI encoding
* and a URI compatible separator is required.
*
* The implementation below came from
* https://stackoverflow.com/a/6573119/6059235
*
* While a faster solution exist in the same post, this operation is expected to be done:
* - once per 1 sec frequency
* - on < 1000 numbers
......@@ -159,10 +156,9 @@ export const separator = "."
const negString = '~'
const encodeInt = number => {
if (number % 1 !== 0) throw 'cannot encodeInt on a float. Ensure float flag is set'
if (isNaN(Number(number)) || number === null || number === Number.POSITIVE_INFINITY) throw 'The input is not valid'
if (number % 1 !== 0) { throw new Error('cannot encodeInt on a float. Ensure float flag is set') }
if (isNaN(Number(number)) || number === null || number === Number.POSITIVE_INFINITY) { throw new Error('The input is not valid') }
let rixit // like 'digit', only in some non-decimal radix
let residual
let result = ''
......@@ -174,18 +170,13 @@ const encodeInt = number => {
}
while (true) {
rixit = residual % 64
// console.log("rixit : " + rixit)
// console.log("result before : " + result)
result = cipher.charAt(rixit) + result
// console.log("result after : " + result)
// console.log("residual before : " + residual)
result = cipher.charAt(residual % 64) + result
residual = Math.floor(residual / 64)
// console.log("residual after : " + residual)
if (residual == 0)
break;
if (residual === 0) {
break
}
}
return result
}
......
......@@ -8,3 +8,4 @@
- refactor: remove unneeded code
- upgrade to angular v12
- removed SO implementations to comply with licenses
......@@ -81,12 +81,13 @@ describe('> url parsing', () => {
.filter(({ message }) => !/Access-Control-Allow-Origin/.test(message))
// expecting some errors in the console. In catastrophic event, there will most likely be looped errors (on each render cycle)
// capture logs and write to spec https://stackoverflow.com/a/24980483/6059235
// capture logs and write to spec
expect(
filteredLog.length
).withContext(
JSON.stringify(filteredLog)
).toBeLessThan(
50,
JSON.stringify(filteredLog)
)
})
......
......@@ -9,8 +9,9 @@ export class FilterNameBySearch implements PipeTransform {
try {
return searchFields.some(searchField => new RegExp(searchTerm, 'i').test(searchField))
} catch (e) {
/* https://stackoverflow.com/a/9310752/6059235 */
return searchFields.some(searchField => new RegExp(searchTerm.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')).test(searchField))
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
// CC0 or MIT
return searchFields.some(searchField => new RegExp(searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).test(searchField))
}
}
}
......@@ -77,7 +77,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
private newViewer$: Observable<any>
private snackbarRef: MatSnackBarRef<any>
public snackbarMessage$: Observable<string>
public snackbarMessage$: Observable<symbol>
public onhoverLandmark$: Observable<{landmarkName: string, datasets: any} | null>
......@@ -205,8 +205,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
if (!messageSymbol) { return }
// https://stackoverflow.com/a/48191056/6059235
const message = messageSymbol.toString().slice(7, -1)
const message = messageSymbol.description
this.snackbarRef = this.snackbar.open(message, 'Dismiss', {
duration: 5000,
})
......
......@@ -3,9 +3,6 @@
* The constraint is that the cipher needs to be commpatible with URI encoding
* and a URI compatible separator is required.
*
* The implementation below came from
* https://stackoverflow.com/a/6573119/6059235
*
* While a faster solution exist in the same post, this operation is expected to be done:
* - once per 1 sec frequency
* - on < 1000 numbers
......@@ -21,8 +18,7 @@ const encodeInt = (number: number) => {
if (number % 1 !== 0) { throw new Error('cannot encodeInt on a float. Ensure float flag is set') }
if (isNaN(Number(number)) || number === null || number === Number.POSITIVE_INFINITY) { throw new Error('The input is not valid') }
let rixit // like 'digit', only in some non-decimal radix
let residual
let residual: number
let result = ''
if (number < 0) {
......@@ -34,17 +30,11 @@ const encodeInt = (number: number) => {
/* eslint-disable-next-line no-constant-condition */
while (true) {
rixit = residual % 64
// this.log.log("rixit : " + rixit)
// this.log.log("result before : " + result)
result = cipher.charAt(rixit) + result
// this.log.log("result after : " + result)
// this.log.log("residual before : " + residual)
result = cipher.charAt(residual % 64) + result
residual = Math.floor(residual / 64)
// this.log.log("residual after : " + residual)
if (residual === 0) {
break;
break
}
}
return result
......
......@@ -17,7 +17,7 @@ export interface IUiState{
focusedSidePanel: string | null
snackbarMessage: string
snackbarMessage: symbol
agreedCookies: boolean
agreedKgTos: boolean
......
......@@ -43,12 +43,10 @@ const animation = lsAnimationFlag && lsAnimationFlag === 'true'
// get mobile ui setting
// UA sniff only if not useMobileUI not explicitly set
const getIsMobile = () => {
const ua = window && window.navigator && window.navigator.userAgent
? window.navigator.userAgent
: ''
/* https://stackoverflow.com/a/25394023/6059235 */
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(ua)
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/maxTouchPoints
// CC0 or MIT
// msMaxTouchPoints is not needed, since IE is not supported
return 'maxTouchPoints' in navigator && navigator.maxTouchPoints > 0
}
const useMobileUIStroageValue = window && window.localStorage && window.localStorage.getItem(LOCAL_STORAGE_CONST.MOBILE_UI)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment