From 82863cd86156d48b9f18dc10a560bedb82641862 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 14 Aug 2017 19:55:04 -0700 Subject: renaming files --- ext/bg/context.html | 43 +++++++++++++ ext/bg/js/context.js | 31 ++++++++++ ext/bg/js/display-window.js | 54 ---------------- ext/bg/js/popup.js | 31 ---------- ext/bg/js/search.js | 56 +++++++++++++++++ ext/bg/popup.html | 43 ------------- ext/bg/search.html | 4 +- ext/fg/css/client.css | 2 +- ext/fg/float.html | 43 +++++++++++++ ext/fg/frame.html | 43 ------------- ext/fg/js/display-frame.js | 86 -------------------------- ext/fg/js/float.js | 88 ++++++++++++++++++++++++++ ext/fg/js/popup.js | 4 +- ext/manifest.json | 5 +- ext/mixed/css/display.css | 146 ++++++++++++++++++++++++++++++++++++++++++++ ext/mixed/css/frame.css | 146 -------------------------------------------- 16 files changed, 414 insertions(+), 411 deletions(-) create mode 100644 ext/bg/context.html create mode 100644 ext/bg/js/context.js delete mode 100644 ext/bg/js/display-window.js delete mode 100644 ext/bg/js/popup.js create mode 100644 ext/bg/js/search.js delete mode 100644 ext/bg/popup.html create mode 100644 ext/fg/float.html delete mode 100644 ext/fg/frame.html delete mode 100644 ext/fg/js/display-frame.js create mode 100644 ext/fg/js/float.js create mode 100644 ext/mixed/css/display.css delete mode 100644 ext/mixed/css/frame.css diff --git a/ext/bg/context.html b/ext/bg/context.html new file mode 100644 index 00000000..3828c9fe --- /dev/null +++ b/ext/bg/context.html @@ -0,0 +1,43 @@ + + + + + + + + + + +

+ +

+

+

+ + + +
+

+ + + + + + + + + + + + + + diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js new file mode 100644 index 00000000..77cb5166 --- /dev/null +++ b/ext/bg/js/context.js @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2017 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +$(document).ready(() => { + $('#open-search').click(() => apiCommandExec('search')); + $('#open-options').click(() => apiCommandExec('options')); + $('#open-help').click(() => apiCommandExec('help')); + + optionsLoad().then(options => { + const toggle = $('#enable-search'); + toggle.prop('checked', options.general.enable).change(); + toggle.bootstrapToggle(); + toggle.change(() => apiCommandExec('toggle')); + }); +}); diff --git a/ext/bg/js/display-window.js b/ext/bg/js/display-window.js deleted file mode 100644 index cbb96681..00000000 --- a/ext/bg/js/display-window.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2016 Alex Yatskov - * Author: Alex Yatskov - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -window.yomichan_window = new class extends Display { - constructor() { - super($('#spinner'), $('#content')); - - this.search = $('#search').click(this.onSearch.bind(this)); - this.query = $('#query').on('input', this.onSearchInput.bind(this)); - this.intro = $('#intro'); - - window.wanakana.bind(this.query.get(0)); - } - - onError(error) { - window.alert(`Error: ${error}`); - } - - onSearchClear() { - this.query.focus().select(); - } - - onSearchInput() { - this.search.prop('disabled', this.query.val().length === 0); - } - - async onSearch(e) { - e.preventDefault(); - - try { - this.intro.slideUp(); - const {length, definitions} = await apiTermsFind(this.query.val()); - super.termsShow(definitions, await apiOptionsGet()); - } catch (e) { - this.onError(e); - } - } -}; diff --git a/ext/bg/js/popup.js b/ext/bg/js/popup.js deleted file mode 100644 index 77cb5166..00000000 --- a/ext/bg/js/popup.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2017 Alex Yatskov - * Author: Alex Yatskov - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -$(document).ready(() => { - $('#open-search').click(() => apiCommandExec('search')); - $('#open-options').click(() => apiCommandExec('options')); - $('#open-help').click(() => apiCommandExec('help')); - - optionsLoad().then(options => { - const toggle = $('#enable-search'); - toggle.prop('checked', options.general.enable).change(); - toggle.bootstrapToggle(); - toggle.change(() => apiCommandExec('toggle')); - }); -}); diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js new file mode 100644 index 00000000..87f50c32 --- /dev/null +++ b/ext/bg/js/search.js @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2016 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +class DisplaySearch extends Display { + constructor() { + super($('#spinner'), $('#content')); + + this.search = $('#search').click(this.onSearch.bind(this)); + this.query = $('#query').on('input', this.onSearchInput.bind(this)); + this.intro = $('#intro'); + + window.wanakana.bind(this.query.get(0)); + } + + onError(error) { + window.alert(`Error: ${error}`); + } + + onSearchClear() { + this.query.focus().select(); + } + + onSearchInput() { + this.search.prop('disabled', this.query.val().length === 0); + } + + async onSearch(e) { + e.preventDefault(); + + try { + this.intro.slideUp(); + const {length, definitions} = await apiTermsFind(this.query.val()); + super.termsShow(definitions, await apiOptionsGet()); + } catch (e) { + this.onError(e); + } + } +} + +window.yomichan_search = new DisplaySearch(); diff --git a/ext/bg/popup.html b/ext/bg/popup.html deleted file mode 100644 index 60253d6f..00000000 --- a/ext/bg/popup.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - -

- -

-

-

- - - -
-

- - - - - - - - - - - - - - diff --git a/ext/bg/search.html b/ext/bg/search.html index fe44d74e..d10530f9 100644 --- a/ext/bg/search.html +++ b/ext/bg/search.html @@ -5,7 +5,7 @@ Yomichan Search - +
@@ -45,6 +45,6 @@ - + diff --git a/ext/fg/css/client.css b/ext/fg/css/client.css index 9f566480..b5b1f6bd 100644 --- a/ext/fg/css/client.css +++ b/ext/fg/css/client.css @@ -17,7 +17,7 @@ */ -iframe#yomichan-popup { +iframe#yomichan-float { all: initial; background-color: #fff; border: 1px solid #999; diff --git a/ext/fg/float.html b/ext/fg/float.html new file mode 100644 index 00000000..a3b66c92 --- /dev/null +++ b/ext/fg/float.html @@ -0,0 +1,43 @@ + + + + + + + + + + + +
+ +
+ +
+ +
+
+

Yomichan Updated!

+

+ The Yomichan extension has been updated to a new version! In order to continue + viewing definitions on this page you must reload this tab or restart your browser. +

+
+
+ + + + + + + + + + + + diff --git a/ext/fg/frame.html b/ext/fg/frame.html deleted file mode 100644 index dda3ef06..00000000 --- a/ext/fg/frame.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - -
- -
- -
- -
-
-

Yomichan Updated!

-

- The Yomichan extension has been updated to a new version! In order to continue - viewing definitions on this page you must reload this tab or restart your browser. -

-
-
- - - - - - - - - - - - diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js deleted file mode 100644 index e3f3e692..00000000 --- a/ext/fg/js/display-frame.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2016 Alex Yatskov - * Author: Alex Yatskov - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -window.yomichan_frame = new class extends Display { - constructor() { - super($('#spinner'), $('#definitions')); - $(window).on('message', this.onMessage.bind(this)); - } - - onError(error) { - if (window.yomichan_orphaned) { - this.onOrphaned(); - } else { - window.alert(`Error: ${error}`); - } - } - - onOrphaned() { - $('#definitions').hide(); - $('#error-orphaned').show(); - } - - onSearchClear() { - window.parent.postMessage('popupClose', '*'); - } - - onSelectionCopy() { - window.parent.postMessage('selectionCopy', '*'); - } - - onMessage(e) { - const handlers = { - termsShow: ({definitions, options, context}) => { - this.termsShow(definitions, options, context); - }, - - kanjiShow: ({definitions, options, context}) => { - this.kanjiShow(definitions, options, context); - }, - - orphaned: () => { - this.onOrphaned(); - } - }; - - const {action, params} = e.originalEvent.data; - const handler = handlers[action]; - if (handler) { - handler(params); - } - } - - onKeyDown(e) { - const handlers = { - 67: /* c */ () => { - if (e.ctrlKey && !window.getSelection().toString()) { - this.onSelectionCopy(); - return true; - } - } - }; - - const handler = handlers[e.keyCode]; - if (handler && handler()) { - e.preventDefault(); - } else { - super.onKeyDown(e); - } - } -}; diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js new file mode 100644 index 00000000..59293239 --- /dev/null +++ b/ext/fg/js/float.js @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2016 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +class DisplayFloat extends Display { + constructor() { + super($('#spinner'), $('#definitions')); + $(window).on('message', e => this.onMessage(e)); + } + + onError(error) { + if (window.yomichan_orphaned) { + this.onOrphaned(); + } else { + window.alert(`Error: ${error}`); + } + } + + onOrphaned() { + $('#definitions').hide(); + $('#error-orphaned').show(); + } + + onSearchClear() { + window.parent.postMessage('popupClose', '*'); + } + + onSelectionCopy() { + window.parent.postMessage('selectionCopy', '*'); + } + + onMessage(e) { + const handlers = { + termsShow: ({definitions, options, context}) => { + this.termsShow(definitions, options, context); + }, + + kanjiShow: ({definitions, options, context}) => { + this.kanjiShow(definitions, options, context); + }, + + orphaned: () => { + this.onOrphaned(); + } + }; + + const {action, params} = e.originalEvent.data; + const handler = handlers[action]; + if (handler) { + handler(params); + } + } + + onKeyDown(e) { + const handlers = { + 67: /* c */ () => { + if (e.ctrlKey && !window.getSelection().toString()) { + this.onSelectionCopy(); + return true; + } + } + }; + + const handler = handlers[e.keyCode]; + if (handler && handler()) { + e.preventDefault(); + } else { + super.onKeyDown(e); + } + } +} + +window.yomichan_display = new DisplayFloat(); diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index ba3289d4..8e61169a 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -20,10 +20,10 @@ class Popup { constructor() { this.container = document.createElement('iframe'); - this.container.id = 'yomichan-popup'; + this.container.id = 'yomichan-float'; this.container.addEventListener('mousedown', e => e.stopPropagation()); this.container.addEventListener('scroll', e => e.stopPropagation()); - this.container.setAttribute('src', chrome.extension.getURL('/fg/frame.html')); + this.container.setAttribute('src', chrome.extension.getURL('/fg/float.html')); this.container.style.width = '0px'; this.container.style.height = '0px'; this.injected = null; diff --git a/ext/manifest.json b/ext/manifest.json index ee3bd2ac..a8b68bfb 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -7,7 +7,7 @@ "icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"}, "browser_action": { "default_icon": {"19": "mixed/img/icon19.png", "38": "mixed/img/icon38.png"}, - "default_popup": "bg/popup.html" + "default_popup": "bg/context.html" }, "author": "Alex Yatskov", @@ -20,7 +20,6 @@ "fg/js/popup.js", "fg/js/source.js", "fg/js/util.js", - "fg/js/frontend.js" ], "css": ["fg/css/client.css"] @@ -48,7 +47,7 @@ "description": "Open search window" } }, - "web_accessible_resources": ["fg/frame.html"], + "web_accessible_resources": ["fg/float.html"], "applications": { "gecko": { "id": "yomichan-live@foosoft.net", diff --git a/ext/mixed/css/display.css b/ext/mixed/css/display.css new file mode 100644 index 00000000..8b1819bd --- /dev/null +++ b/ext/mixed/css/display.css @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2016 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the entrys of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +/* + * Fonts + */ + +@font-face { + font-family: kanji-stroke-orders; + src: url('/mixed/ttf/kanji-stroke-orders.ttf'); +} + +/* + * General + */ + +hr { + padding: 0px; + margin: 0px; +} + +#spinner { + bottom: 5px; + display: none; + position: fixed; + right: 5px; +} + +#error-orphaned { + display: none; +} + + +/* + * Entries + */ + +.entry, .note { + padding-top: 10px; + padding-bottom: 10px; +} + +.tag-default { + background-color: #8a8a91; +} + +.tag-name { + background-color: #5cb85c; +} + +.tag-expression { + background-color: #f0ad4e; +} + +.tag-popular { + background-color: #0275d8; +} + +.tag-frequent { + background-color: #5bc0de; +} + +.tag-archaism { + background-color: #d9534f; +} + +.tag-dictionary { + background-color: #aa66cc; +} + +.actions .disabled { + pointer-events: none; + cursor: default; +} + +.actions .disabled img { + -webkit-filter: grayscale(100%); + opacity: 0.25; +} + +.actions .pending { + visibility: hidden; +} + +.actions { + display: inline-block; + float: right; +} + +.actions:after { + clear: both; + content: ''; + display: block; +} + +.expression { + display: inline-block; + font-size: 24px; +} + +.expression a { + border-bottom: 1px #777 dashed; + color: #333; + text-decoration: none; +} + +.reasons { + color: #777; + display: inline-block; +} + +.glossary ol, .glossary ul { + padding-left: 1.4em; +} + +.glossary li { + color: #777; +} + +.glossary-item { + color: #000; +} + +.glyph { + font-family: kanji-stroke-orders; + font-size: 120px; + line-height: 120px; + padding: 0.01em; + vertical-align: top; +} diff --git a/ext/mixed/css/frame.css b/ext/mixed/css/frame.css deleted file mode 100644 index 8b1819bd..00000000 --- a/ext/mixed/css/frame.css +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2016 Alex Yatskov - * Author: Alex Yatskov - * - * This program is free software: you can redistribute it and/or modify - * it under the entrys of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -/* - * Fonts - */ - -@font-face { - font-family: kanji-stroke-orders; - src: url('/mixed/ttf/kanji-stroke-orders.ttf'); -} - -/* - * General - */ - -hr { - padding: 0px; - margin: 0px; -} - -#spinner { - bottom: 5px; - display: none; - position: fixed; - right: 5px; -} - -#error-orphaned { - display: none; -} - - -/* - * Entries - */ - -.entry, .note { - padding-top: 10px; - padding-bottom: 10px; -} - -.tag-default { - background-color: #8a8a91; -} - -.tag-name { - background-color: #5cb85c; -} - -.tag-expression { - background-color: #f0ad4e; -} - -.tag-popular { - background-color: #0275d8; -} - -.tag-frequent { - background-color: #5bc0de; -} - -.tag-archaism { - background-color: #d9534f; -} - -.tag-dictionary { - background-color: #aa66cc; -} - -.actions .disabled { - pointer-events: none; - cursor: default; -} - -.actions .disabled img { - -webkit-filter: grayscale(100%); - opacity: 0.25; -} - -.actions .pending { - visibility: hidden; -} - -.actions { - display: inline-block; - float: right; -} - -.actions:after { - clear: both; - content: ''; - display: block; -} - -.expression { - display: inline-block; - font-size: 24px; -} - -.expression a { - border-bottom: 1px #777 dashed; - color: #333; - text-decoration: none; -} - -.reasons { - color: #777; - display: inline-block; -} - -.glossary ol, .glossary ul { - padding-left: 1.4em; -} - -.glossary li { - color: #777; -} - -.glossary-item { - color: #000; -} - -.glyph { - font-family: kanji-stroke-orders; - font-size: 120px; - line-height: 120px; - padding: 0.01em; - vertical-align: top; -} -- cgit v1.2.3