aboutsummaryrefslogtreecommitdiff
path: root/html/dialog.js
AgeCommit message (Expand)Author
2022-01-13facilitate managing repository URLs in a list; minor other changesWojtek Kosior
2022-01-11add missing payload_create test and stylingWojtek Kosior
2022-01-10improve item list styling; add payload creation form; exend dialog mechanismWojtek Kosior
2022-01-08work on UI components...Wojtek Kosior
40'>40 41 42 43 44 45 46 47 48 49
/**
 * This file is part of Haketilo.
 *
 * Function: Querying page settings.
 *
 * 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
 */