diff options
Diffstat (limited to 'src/background/domains')
| -rw-r--r-- | src/background/domains/command-docs.js | 12 | ||||
| -rw-r--r-- | src/background/domains/completion-group.js | 14 | ||||
| -rw-r--r-- | src/background/domains/completion-item.js | 24 | ||||
| -rw-r--r-- | src/background/domains/completions.js | 27 | ||||
| -rw-r--r-- | src/background/domains/setting.js | 51 | 
5 files changed, 128 insertions, 0 deletions
| diff --git a/src/background/domains/command-docs.js b/src/background/domains/command-docs.js new file mode 100644 index 0000000..0b8ede7 --- /dev/null +++ b/src/background/domains/command-docs.js @@ -0,0 +1,12 @@ +export default { +  set: 'Set a value of the property', +  open: 'Open a URL or search by keywords in current tab', +  tabopen: 'Open a URL or search by keywords in new tab', +  winopen: 'Open a URL or search by keywords in new window', +  buffer: 'Sekect tabs by matched keywords', +  bdelete: 'Close a certain tab matched by keywords', +  bdeletes: 'Close all tabs matched by keywords', +  quit: 'Close the current tab', +  quitall: 'Close all tabs', +}; + diff --git a/src/background/domains/completion-group.js b/src/background/domains/completion-group.js new file mode 100644 index 0000000..1749d72 --- /dev/null +++ b/src/background/domains/completion-group.js @@ -0,0 +1,14 @@ +export default class CompletionGroup { +  constructor(name, items) { +    this.name0 = name; +    this.items0 = items; +  } + +  get name() { +    return this.name0; +  } + +  get items() { +    return this.items0; +  } +} diff --git a/src/background/domains/completion-item.js b/src/background/domains/completion-item.js new file mode 100644 index 0000000..c7ad8a1 --- /dev/null +++ b/src/background/domains/completion-item.js @@ -0,0 +1,24 @@ +export default class CompletionItem { +  constructor({ caption, content, url, icon }) { +    this.caption0 = caption; +    this.content0 = content; +    this.url0 = url; +    this.icon0 = icon; +  } + +  get caption() { +    return this.caption0; +  } + +  get content() { +    return this.content0; +  } + +  get url() { +    return this.url0; +  } + +  get icon() { +    return this.icon0; +  } +} diff --git a/src/background/domains/completions.js b/src/background/domains/completions.js new file mode 100644 index 0000000..4e4219f --- /dev/null +++ b/src/background/domains/completions.js @@ -0,0 +1,27 @@ +export default class Completions { +  constructor(groups) { +    this.g = groups; +  } + +  get groups() { +    return this.g; +  } + +  serialize() { +    return this.groups.map(group => ({ +      name: group.name, +      items: group.items.map(item => ({ +        caption: item.caption, +        content: item.content, +        url: item.url, +        icon: item.icon, +      })), +    })); +  } + +  static EMPTY_COMPLETIONS = new Completions([]); + +  static empty() { +    return Completions.EMPTY_COMPLETIONS; +  } +} diff --git a/src/background/domains/setting.js b/src/background/domains/setting.js new file mode 100644 index 0000000..106ec0f --- /dev/null +++ b/src/background/domains/setting.js @@ -0,0 +1,51 @@ +import DefaultSettings from '../../shared/settings/default'; +import * as settingsValues from '../../shared/settings/values'; + +export default class Setting { +  constructor({ source, json, form }) { +    this.obj = { +      source, json, form +    }; +  } + +  get source() { +    return this.obj.source; +  } + +  get json() { +    return this.obj.json; +  } + +  get form() { +    return this.obj.form; +  } + +  value() { +    let value = JSON.parse(DefaultSettings.json); +    if (this.obj.source === 'json') { +      value = settingsValues.valueFromJson(this.obj.json); +    } else if (this.obj.source === 'form') { +      value = settingsValues.valueFromForm(this.obj.form); +    } +    if (!value.properties) { +      value.properties = {}; +    } +    return { ...settingsValues.valueFromJson(DefaultSettings.json), ...value }; +  } + +  serialize() { +    return this.obj; +  } + +  static deserialize(obj) { +    return new Setting({ source: obj.source, json: obj.json, form: obj.form }); +  } + +  static defaultSettings() { +    return new Setting({ +      source: DefaultSettings.source, +      json: DefaultSettings.json, +      form: {}, +    }); +  } +} | 
