Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const selectedMetadata = (
state = {},
action
) => {
switch (action.type) {
case "url changed": {
const {url} = action;
const parsed = uri.parseQuery(window.location.search);
// console.log("onURLchange sees: ", state, parsed)
return state;
}
case "categorical metadata filter selected success": {
if (!state[action.metadataField]) { /* we don't have the field, which means this is a simple insertion */
/* {} becomes {Location: ["Tumor"]} */
return Object.assign({}, state, {[action.metadataField]: [action.value]});
} else { /* we do have the field, so we need to push to a copy of the array */
const updatedField = state[action.metadataField].slice()
updatedField.push(action.value)
return Object.assign({}, state, {
/* {Location: ["Tumor"]} becomes {Location: ["Tumor", "Periphery"]} */
[action.metadataField]: updatedField
})
}
}
import URI from 'urijs';
import configureStore from './configureStore';
const urlParsed = URI.parseQuery(document.location.search);
const initialState = {
urlVideoId: urlParsed['v'] || '814eR5K7KD8',
};
// The instance of the current store shared in the application.
const currentStore = configureStore(initialState);
currentStore.subscribe(() => {
const currentVideo = currentStore.getState().currentVideo;
if (currentVideo) {
const newUrl = URI(document.location.href).query({v: currentVideo.id }).toString();
history.pushState(null, '', newUrl);
}
});
export default currentStore;
private parseAuthFromUrl(url: string, merge: boolean): IUserAuth {
const query = URI.parseQuery(URI.parse(url).query) as Dictionary;
const requiredFields = ['platform', 'platform_username', 'platform_token', 'platform_id'];
if (!merge) requiredFields.push('token', 'oauth_token');
if (requiredFields.every(field => !!query[field])) {
return {
widgetToken: merge ? this.widgetToken : query.token,
apiToken: merge ? this.apiToken : query.oauth_token,
primaryPlatform: query.platform as TPlatform,
platforms: {
[query.platform]: {
type: query.platform,
username: query.platform_username,
token: query.platform_token,
id: query.platform_id,
},
$(document).ready(() => {
const currentUrl = URI(window.location.href)
queryParams = URI.parseQuery(currentUrl.query())
if(queryParams.hasOwnProperty('q'))
searchInput.val(queryParams.q)
if(queryParams.hasOwnProperty('type')) {
typeDropdown.dropdown('set selected', queryParams.type)
}
$('.version-chart').each((index, element) => {
const chartElement = $(element)
new Chart(
document.getElementById($(element).attr('id')).getContext('2d'),
{
type: 'horizontalBar',
data: {
labels: ["Versions"],
static getUrlParams(url: string) {
return URI.parseQuery(URI.parse(url).query) as Dictionary;
}
constructor(props) {
super(props);
let project_filter = 'all', release_filter = 'all', vendor_filter = 'all';
if(window.location.hash) {
let hash = URI.parseQuery(window.location.hash.substr(1));
if (('project' in hash) && hash['project']) {
project_filter = hash['project'];
}
if (('vendor' in hash) && hash['vendor']) {
vendor_filter = hash['vendor'];
}
if (('release' in hash) && hash['release']) {
release_filter = hash['release'];
}
}
this.state = {
sort_direction : SortDirectionAsc,
sort_field : 'Project',
project : project_filter,
release : release_filter,
private parseTwitterResultFromUrl(url: string) {
const query = URI.parseQuery(URI.parse(url).query) as Dictionary;
if (query.twitter) {
return { success: !!query.success };
}
return false;
}
}
useEffect(() => {
const queries = URI.parseQuery(window.location.search);
const { from, to, date, highSpeed } = queries;
dispatch(setFrom(from));
dispatch(setTo(to));
dispatch(setDepartDate(h0(dayjs(date).valueOf())));
dispatch(setHighSpeed(highSpeed === 'true'));
dispatch(setSearchParsed(true));
}, [dispatch]);