summaryrefslogtreecommitdiff
path: root/content/activity_info_server.js
AgeCommit message (Expand)Author
2021-07-06show some settings of the current page in the popupWojtek Kosior
a id='n18' href='#n18'>18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
/**
 * Hachette querying page settings with regard to wildcard records
 *
 * Copyright (C) 2021 Wojtek Kosior
 * Redistribution terms are gathered in the `copyright' file.
 */

/*
 * IMPORTS_START
 * IMPORT TYPE_PREFIX
 * IMPORT each_url_pattern
 * IMPORTS_END
 */

function query(storage, url, multiple)
{
    const matched = [];
    const cb = p => check_pattern(storage, p, multiple, matched);
    for (const pattern of each_url_pattern(url)) {
	const result = [pattern, storage.get(TYPE_PREFIX.PAGE, pattern)];
	if (result[1] === undefined)
	    continue;

	if (!multiple)
	    return result;
	matched.push(result);
    }

    return multiple ? matched : [undefined, undefined];
}

function query_best(storage, url)
{
    return query(storage, url, false);
}

function query_all(storage, url)
{
    return query(storage, url, true);
}

/*
 * EXPORTS_START
 * EXPORT query_best
 * EXPORT query_all
 * EXPORTS_END
 */