From a26d8a8a1bed48a77e062914c120a23ace7bb8cf Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 24 Feb 2019 20:54:35 +0900 Subject: Capitalize background scripts --- src/background/domains/CommandDocs.js | 12 +++++++ src/background/domains/CompletionGroup.js | 14 ++++++++ src/background/domains/CompletionItem.js | 24 ++++++++++++++ src/background/domains/Completions.js | 27 ++++++++++++++++ src/background/domains/GlobalMark.js | 24 ++++++++++++++ src/background/domains/Setting.js | 51 ++++++++++++++++++++++++++++++ src/background/domains/command-docs.js | 12 ------- src/background/domains/completion-group.js | 14 -------- src/background/domains/completion-item.js | 24 -------------- src/background/domains/completions.js | 27 ---------------- src/background/domains/global-mark.js | 24 -------------- src/background/domains/setting.js | 51 ------------------------------ 12 files changed, 152 insertions(+), 152 deletions(-) create mode 100644 src/background/domains/CommandDocs.js create mode 100644 src/background/domains/CompletionGroup.js create mode 100644 src/background/domains/CompletionItem.js create mode 100644 src/background/domains/Completions.js create mode 100644 src/background/domains/GlobalMark.js create mode 100644 src/background/domains/Setting.js delete mode 100644 src/background/domains/command-docs.js delete mode 100644 src/background/domains/completion-group.js delete mode 100644 src/background/domains/completion-item.js delete mode 100644 src/background/domains/completions.js delete mode 100644 src/background/domains/global-mark.js delete mode 100644 src/background/domains/setting.js (limited to 'src/background/domains') diff --git a/src/background/domains/CommandDocs.js b/src/background/domains/CommandDocs.js new file mode 100644 index 0000000..734c68e --- /dev/null +++ b/src/background/domains/CommandDocs.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: 'Select 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/CompletionGroup.js b/src/background/domains/CompletionGroup.js new file mode 100644 index 0000000..1749d72 --- /dev/null +++ b/src/background/domains/CompletionGroup.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/CompletionItem.js b/src/background/domains/CompletionItem.js new file mode 100644 index 0000000..c7ad8a1 --- /dev/null +++ b/src/background/domains/CompletionItem.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/GlobalMark.js b/src/background/domains/GlobalMark.js new file mode 100644 index 0000000..f0586f1 --- /dev/null +++ b/src/background/domains/GlobalMark.js @@ -0,0 +1,24 @@ +export default class GlobalMark { + constructor(tabId, url, x, y) { + this.tabId0 = tabId; + this.url0 = url; + this.x0 = x; + this.y0 = y; + } + + get tabId() { + return this.tabId0; + } + + get url() { + return this.url0; + } + + get x() { + return this.x0; + } + + get y() { + return this.y0; + } +} 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: {}, + }); + } +} diff --git a/src/background/domains/command-docs.js b/src/background/domains/command-docs.js deleted file mode 100644 index 734c68e..0000000 --- a/src/background/domains/command-docs.js +++ /dev/null @@ -1,12 +0,0 @@ -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: 'Select 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 deleted file mode 100644 index 1749d72..0000000 --- a/src/background/domains/completion-group.js +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index c7ad8a1..0000000 --- a/src/background/domains/completion-item.js +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index 4e4219f..0000000 --- a/src/background/domains/completions.js +++ /dev/null @@ -1,27 +0,0 @@ -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/global-mark.js b/src/background/domains/global-mark.js deleted file mode 100644 index f0586f1..0000000 --- a/src/background/domains/global-mark.js +++ /dev/null @@ -1,24 +0,0 @@ -export default class GlobalMark { - constructor(tabId, url, x, y) { - this.tabId0 = tabId; - this.url0 = url; - this.x0 = x; - this.y0 = y; - } - - get tabId() { - return this.tabId0; - } - - get url() { - return this.url0; - } - - get x() { - return this.x0; - } - - get y() { - return this.y0; - } -} diff --git a/src/background/domains/setting.js b/src/background/domains/setting.js deleted file mode 100644 index 106ec0f..0000000 --- a/src/background/domains/setting.js +++ /dev/null @@ -1,51 +0,0 @@ -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: {}, - }); - } -} -- cgit v1.2.3