add search of images
Similar to texts
This commit is contained in:
parent
ca15164def
commit
0df989512c
2 changed files with 41 additions and 0 deletions
18
media/config.icons.json
Normal file
18
media/config.icons.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"default": {
|
||||
"512": "media/icons/logo_tiny.png",
|
||||
"1024": "media/icons/logo.png"
|
||||
},
|
||||
"disabled": {
|
||||
"512": "media/icons/logo_no_tiny.png",
|
||||
"1024": "media/icons/logo_no.png"
|
||||
},
|
||||
"good": {
|
||||
"512": "media/icons/good_tiny.png",
|
||||
"1024": "media/icons/good.png"
|
||||
},
|
||||
"bad": {
|
||||
"512": "media/icons/bad_tiny.png",
|
||||
"1024": "media/icons/bad.png"
|
||||
}
|
||||
}
|
23
scripts/strings/image.js
Normal file
23
scripts/strings/image.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
const CONFIG = chrome.runtime.getURL("media/config.icons.json");
|
||||
|
||||
class Image {
|
||||
/* Get the appropriate image path from the configuration.
|
||||
|
||||
@param {string} name The name of the image.
|
||||
*/
|
||||
static get(name, size) {
|
||||
return (fetch(CONFIG)
|
||||
.then((response) => response.json())
|
||||
.then((jsonData) => {
|
||||
let image = {'raw': jsonData[name]};
|
||||
image[`filtered`] = (image[`raw`] && size) ? image[`raw`][String(size)] : image[`raw`];
|
||||
return image[`filtered`];
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
export {Image as default};
|
Loading…
Add table
Add a link
Reference in a new issue