rename modules after moving to appropriate folders
This commit is contained in:
parent
0b7be21d03
commit
a226f12645
16 changed files with 17 additions and 17 deletions
23
scripts/mapping/image.js
Normal file
23
scripts/mapping/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};
|
53
scripts/mapping/read.js
Normal file
53
scripts/mapping/read.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* read_universal
|
||||
Read a file stored in the universal strings. */
|
||||
|
||||
let messages = {};
|
||||
let message = "";
|
||||
|
||||
export default class texts {
|
||||
/* This reads the message from its source. This is a fallback for the content scripts, who doesn't appear to read classes.
|
||||
|
||||
@param {string} message the message name
|
||||
@param {boolean} autofill fill in the message with the template name when not found
|
||||
@param {list} params the parameters
|
||||
@return {string} the message
|
||||
*/
|
||||
|
||||
constructor(message_name, autofill = false, params = []) {
|
||||
if (params && (params ? params.length > 0 : false)) {
|
||||
this.localized = chrome.i18n.getMessage(message_name, params);
|
||||
} else {
|
||||
this.localized = chrome.i18n.getMessage(message_name);
|
||||
}
|
||||
|
||||
// When the message is not found, return the temporary text.
|
||||
if (!this.localized && autofill) {
|
||||
this.localized = message_name;
|
||||
} else if (!this.localized && !autofill) {
|
||||
delete this.localized;
|
||||
};
|
||||
}
|
||||
|
||||
static localized(message_name, autofill = false, params = []) {
|
||||
if (params && (params ? params.length > 0 : false)) {
|
||||
message = chrome.i18n.getMessage(message_name, params);
|
||||
} else {
|
||||
message = chrome.i18n.getMessage(message_name);
|
||||
}
|
||||
|
||||
// When the message is not found, return the temporary text.
|
||||
if (!message && autofill) {
|
||||
message = message_name;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
export function read(message_name, autofill, params) {
|
||||
let message;
|
||||
|
||||
message = texts.localized(message_name, autofill, params);
|
||||
|
||||
return message;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue