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