StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
4 years ago
|
/* @flow */
|
||
|
|
||
|
import { inBrowser } from './dom'
|
||
|
import { saveScrollPosition } from './scroll'
|
||
|
import { genStateKey, setStateKey, getStateKey } from './state-key'
|
||
|
import { extend } from './misc'
|
||
|
|
||
|
export const supportsPushState =
|
||
|
inBrowser &&
|
||
|
(function () {
|
||
|
const ua = window.navigator.userAgent
|
||
|
|
||
|
if (
|
||
|
(ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
|
||
|
ua.indexOf('Mobile Safari') !== -1 &&
|
||
|
ua.indexOf('Chrome') === -1 &&
|
||
|
ua.indexOf('Windows Phone') === -1
|
||
|
) {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
return window.history && 'pushState' in window.history
|
||
|
})()
|
||
|
|
||
|
export function pushState (url?: string, replace?: boolean) {
|
||
|
saveScrollPosition()
|
||
|
// try...catch the pushState call to get around Safari
|
||
|
// DOM Exception 18 where it limits to 100 pushState calls
|
||
|
const history = window.history
|
||
|
try {
|
||
|
if (replace) {
|
||
|
// preserve existing history state as it could be overriden by the user
|
||
|
const stateCopy = extend({}, history.state)
|
||
|
stateCopy.key = getStateKey()
|
||
|
history.replaceState(stateCopy, '', url)
|
||
|
} else {
|
||
|
history.pushState({ key: setStateKey(genStateKey()) }, '', url)
|
||
|
}
|
||
|
} catch (e) {
|
||
|
window.location[replace ? 'replace' : 'assign'](url)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export function replaceState (url?: string) {
|
||
|
pushState(url, true)
|
||
|
}
|