Campaign url filter
Этот коммит содержится в:
родитель
8c946abad9
Коммит
d1a73c8ccc
@ -7,6 +7,7 @@
|
||||
sourceFilter,
|
||||
sourceCategoryFilter,
|
||||
methodFilter,
|
||||
campaignFilter,
|
||||
timeRangeFilter
|
||||
} from '../../stores/filters';
|
||||
import { searchParamsFromFilters } from '../utils/share';
|
||||
@ -35,7 +36,7 @@
|
||||
$sourceFilter,
|
||||
$sourceCategoryFilter,
|
||||
$methodFilter
|
||||
)*/
|
||||
)
|
||||
$: params = searchParamsFromFilters(
|
||||
$textSearchFilter,
|
||||
$attributionScoreFilter,
|
||||
@ -44,7 +45,7 @@
|
||||
$sourceFilter,
|
||||
$sourceCategoryFilter,
|
||||
$methodFilter
|
||||
);
|
||||
);*/
|
||||
|
||||
function handleClick() {
|
||||
let params = searchParamsFromFilters(
|
||||
@ -54,10 +55,11 @@
|
||||
$platformFilter,
|
||||
$sourceFilter,
|
||||
$sourceCategoryFilter,
|
||||
$methodFilter
|
||||
$methodFilter,
|
||||
$campaignFilter
|
||||
);
|
||||
$page.url.searchParams.set('filters', params);
|
||||
goto(`?${$page.url.searchParams.toString()}`);
|
||||
//goto(`?${$page.url.searchParams.toString()}`);
|
||||
copyToClipBoard()
|
||||
|
||||
};
|
||||
|
||||
@ -1,29 +1,25 @@
|
||||
//import { base } from '$app/paths';
|
||||
|
||||
//export const baseUrl = 'https://interference2024.org';
|
||||
export const baseUrl = 'http://localhost:5137';
|
||||
|
||||
export const searchParamsFromFilters = (textSearch,
|
||||
attributionScores,
|
||||
actorNations,
|
||||
platforms,
|
||||
sources,
|
||||
sourceCategories,
|
||||
methods
|
||||
methods,
|
||||
campaigns
|
||||
) => {
|
||||
const params = {
|
||||
ts: encodeURIComponent(textSearch),
|
||||
as: [attributionScores[0], attributionScores[1]].join(';'),
|
||||
f: filtersToHex([actorNations, platforms, methods, sources, sourceCategories]),
|
||||
f: filtersToHex([actorNations, platforms, methods, sources, sourceCategories, campaigns]),
|
||||
//id: caseId,
|
||||
};
|
||||
|
||||
//return `${baseUrl}/?filters=${params.f}&${params.id}&${params.ts}&${params.as}}`;
|
||||
//return `${base}?filters=${params.f}&${params.ts}&${params.as}`;
|
||||
return `${params.f}&${params.ts}&${params.as}`;
|
||||
};
|
||||
|
||||
export const filtersToHex = (arr) => {
|
||||
console.log(arr.map((d) => d.map((d) => +d.selected).join('')))
|
||||
console.log(arr.map((d) => binaryToHex(d.map((d) => +d.selected).join(''))).join('&'))
|
||||
const hex = arr.map((d) => binaryToHex(d.map((d) => +d.selected).join(''))).join('&');
|
||||
return hex;
|
||||
};
|
||||
@ -33,7 +29,7 @@ export const filtersToBin = (arr) => {
|
||||
return bin;
|
||||
};
|
||||
|
||||
export const binaryToHex = (binary) => parseInt(binary , 2).toString(16).toLowerCase();
|
||||
export const binaryToHex = (binary) => parseInt(binary, 2).toString(16).toLowerCase();
|
||||
|
||||
export const hexToBinary = (hex) => parseInt(hex, 16).toString(2);
|
||||
|
||||
@ -41,7 +37,7 @@ export const binaryToBool = (binary) => binary.split('').map((d) => d === '0' ?
|
||||
|
||||
export const parseUrl = (hash) => {
|
||||
const s = hash.substring(1);
|
||||
const [ actorNations, platforms, methods, sources, sourceCategories, textSearch, attributionScores] = s.split('&');
|
||||
const [ actorNations, platforms, methods, sources, sourceCategories, campaigns, textSearch, attributionScores] = s.split('&');
|
||||
|
||||
return {
|
||||
actorNations: binaryToBool(hexToBinary(actorNations)),
|
||||
@ -49,6 +45,7 @@ export const parseUrl = (hash) => {
|
||||
methods: binaryToBool(hexToBinary(methods)),
|
||||
sources: binaryToBool(hexToBinary(sources)),
|
||||
sourceCategories: binaryToBool(hexToBinary(sourceCategories)),
|
||||
campaigns: binaryToBool(hexToBinary(campaigns)),
|
||||
textSearch: decodeURIComponent(textSearch),
|
||||
attributionScores: attributionScores.split(';').map((d) => +d)
|
||||
};
|
||||
|
||||
@ -117,6 +117,7 @@
|
||||
methodFilter.applyBoolArray(urlFilters.methods);
|
||||
sourceFilter.applyBoolArray(urlFilters.sources);
|
||||
sourceCategoryFilter.applyBoolArray(urlFilters.sourceCategories);
|
||||
campaignFilter.applyBoolArray(urlFilters.campaigns);
|
||||
$attributionScoreFilter = urlFilters.attributionScores;
|
||||
$textSearchFilter = urlFilters.textSearch;
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ function createInclusiveFilter() {
|
||||
|
||||
const applyBoolArray = (arr) => {
|
||||
const tmpArr = [...arr].reverse();
|
||||
console.log(tmpArr)
|
||||
update((f) => f.reverse().map((d, i) => ({...d, selected: tmpArr[i] !== undefined ? tmpArr[i] : false})).reverse());
|
||||
};
|
||||
|
||||
|
||||
Загрузка…
x
Ссылка в новой задаче
Block a user