Commit Graph

2403 Commits

Author SHA1 Message Date
toasted-nutbread
64ddb4d901
Display fixes and refactoring (#685)
* Fix scroll target override sometimes using undefined value

* Clear event listeners in clearContent()

* Remove unused arguments

* Remove unused disableScroll

* Destructure definitions and context

* Merge _setContentTerms and _setContentKanji

* Move history tracking

* Destructure context

* Rename context to noteContext for clarity

* Destructure before passing args

* Move window focus

* Update scroll defaults
2020-07-24 21:12:13 -04:00
toasted-nutbread
e493cbc998
Simplify Popup.showContent API to use only two details arguments (#684) 2020-07-24 17:34:53 -04:00
toasted-nutbread
3754c92041
Query parser refactor (#683)
* Rename files to better match class name

* Don't pass setContent to QueryParser; use a generic event instead
2020-07-24 16:03:11 -04:00
toasted-nutbread
99f5655e53
Update DisplaySearch.setContent/clearContent to close popups (#682) 2020-07-24 14:54:54 -04:00
toasted-nutbread
d7aaab685e
Dev dependencies updates (#679)
* Update eslint to 7.5.0

* Update eslint-plugin-no-unsanitized to 3.1.2

* Update fake-indexeddb to 3.1.1

* Rename DictionaryImporter.import to .importDictionary

Conflicts with o-unsanitized/method
2020-07-19 22:05:37 -04:00
toasted-nutbread
e12f59f87d
Force targetTabId to be null if not a number (#678) 2020-07-19 12:26:57 -04:00
toasted-nutbread
71b97c2019
Display refactoring (#674)
* Move setupNestedPopups to Display

* Move auto-play timer and delay into Display

* Move some message handler definitions into Display

* Move default optionsContext definition
2020-07-18 23:47:02 -04:00
toasted-nutbread
27e05f8001
Reusable backend popup window (#673)
* Update _updateSearchQuery to return the promise

* Update how the clipboard search popup is opened

* Create an API function to open the search popup

* Skip animation on popup creation

* Add API function
2020-07-18 20:30:10 -04:00
toasted-nutbread
d7f78c23b5
Script ready state change (#672)
* Update how backend/frontend ready states are awaited and signaled

* Log errors on the search page

* Update action name
2020-07-18 17:11:38 -04:00
toasted-nutbread
e696dc84a8
Refactor context-main.js (#671) 2020-07-18 16:45:57 -04:00
toasted-nutbread
c6c0126394
Content script ready checks (#670)
* Move ready checkout of Display

* Add function to wait until if a tab's content script is ready
2020-07-18 14:18:10 -04:00
toasted-nutbread
ffc0b6588e
Fix incorrect URL being used (#669) 2020-07-18 14:17:30 -04:00
toasted-nutbread
a13a68990e
Port name details (#667)
* Use a stringified JSON details object for extension port names

* Fix incorrect frame ID check

* Add support for connecting to different tabs

* Add function for invoking on a different tab
2020-07-18 14:16:35 -04:00
toasted-nutbread
dac33e6961
Extension unload indication fix (#662)
* Remove unused function

* Rename field

* Change extensionUnloaded trigger function

* Update how extension unloaded content is shown

* Ignore certain errors caused by extension unload

* Add _showExtensionUnloaded function

* Wrap internals of updateOptions

* Suppress errors caued by extension unload

* Make the frontend trigger the popup's extensionUnloaded event
2020-07-18 14:15:36 -04:00
toasted-nutbread
f9c76efea0
Fix Anki CORS requests (#666) 2020-07-17 14:27:57 -04:00
toasted-nutbread
fc31e6fab5
Fix incorrect field name (#665) 2020-07-14 21:58:53 -04:00
toasted-nutbread
161888d9a3
Remove backend options context (#661)
* Add support for getting the current profile

* Explicitly use current options
2020-07-11 15:20:51 -04:00
toasted-nutbread
ec42a7e4d6
Message handler refactor (#660)
* Refactor searchQueryUpdate action

* Use standard message handler style

* Use name "promiseOrResult" for consistency

* Use standard message handler convention for Yomichan message handlers

* Use common message handler invoker
2020-07-11 15:20:00 -04:00
toasted-nutbread
8389cd8ba2
Popup crossFrame communication (#658)
* Add support for dynamic message handlers

* Pass messages using crossFrame.invoke instead of contentWindow.postMessage

* Set up async handlers

* Simplify configure call and response
2020-07-10 22:13:59 -04:00
toasted-nutbread
964f011409
Various updates to FrameOffsetForwarder (#657)
* Remove bindings

* Fast exit if same window

* Simplify selector

* Rename functions, reuse _getFrameOffsetParent

* Update message style

* Send reply message to a specific frame
2020-07-10 22:13:11 -04:00
toasted-nutbread
59c224d99d
Add support for async vs non-async (#656) 2020-07-10 22:12:14 -04:00
toasted-nutbread
f76a6ff1e3
Refactor hotkey definitions to be more generic (#655) 2020-07-08 20:02:20 -04:00
toasted-nutbread
6f49f426b5
Generalized frame connections (#654)
* Create FrameClient and FrameEndpoint

* Use new Frame* classes for Popup=>frame connection

* Update api.sendMessageToFrame and api.broadcastTab to include the sender's frameId

* Update FrameClient to store the frame's frameId
2020-07-08 19:58:06 -04:00
toasted-nutbread
295ffa6e54
Refactor DisplayFloat=>Frontend message passing (#652)
* Change getOrCreatePopup arguments to be an object

* Add ownerFrameId to popup and DisplayFloat

* Refactor DisplayFloat host action invocation

* Use CrossFrameAPI instead of window.postMessage

* Update popup closing functionality on the search page
2020-07-08 19:50:13 -04:00
toasted-nutbread
8f48a23a45
Display class refactoring (#650)
* Organize by public/private

* Don't access super class's private members

* Make _autoPlayAudioTimer private

* Refactor constructors

* Make functions private

* Organize by public/private

* Organize window message handlers

* Make fields private

* Refactor DisplaySearch constructor

* Make functions private

* Organize by public/private
2020-07-03 15:58:29 -04:00
toasted-nutbread
e30bab3324
Refactor text source map (#649)
* Use a null check instead of array check

* Convert statisc to non-private

* Use public source

* Add public function for getting the mapping
2020-07-03 15:57:17 -04:00
toasted-nutbread
a07a8dfff6
Extension unload detection (#647)
* Update how extension unload is detected

* Remove event handlers and use yomichan.isExtensionUnloaded instead

* Update terminology
2020-07-03 12:20:22 -04:00
toasted-nutbread
ce634325ce
Add up arrow icon (#648) 2020-07-03 12:02:59 -04:00
toasted-nutbread
e36bc8771f
Display refactor (#643)
* Remove statics

* Move orphan detection and error handling to Display

* Add clearContent function

* Add/use public get/set functions for optionsContext

* Add public getOptions

* Move interactive assignment

* Mark fields as private

* Mark functions as private

* Change stray getter into a function
2020-07-03 12:02:21 -04:00
toasted-nutbread
6ede83f293
Move private function definitions inside of IIFE (#641) 2020-07-03 12:00:13 -04:00
toasted-nutbread
562cfd7470
Make PopupProxy._frameOffsetExpireTimeout non-static (#640) 2020-07-03 11:58:52 -04:00
toasted-nutbread
d776125ead
Refactor timer privates (#639)
* Make Timer.current public

* Make _indentString non-static
2020-07-03 11:58:12 -04:00
toasted-nutbread
897d85d1ac
Util refactor and fix (#638)
* Remove unused functions

* Fix clone function not being visible on the window object
2020-07-03 11:57:15 -04:00
toasted-nutbread
c13160d784
Page exit prevention refactor (#637)
* Add page exit prevention functionality to SettingsController

* Update dictionary controller to use new page exit prevention system

* Remove page-exit-prevention.js
2020-07-03 11:56:26 -04:00
toasted-nutbread
1d02013642
Make JsonSchemaProxyHandler.unconstrainedSchema public and non-configurable (#636) 2020-07-03 11:55:39 -04:00
toasted-nutbread
0279d00274
Don't use/assign popup private fields without using "this" (#635) 2020-07-03 11:54:51 -04:00
toasted-nutbread
af4dc49074
Fix chrome.runtime.manifest failing when extension is reloaded (#646) 2020-07-01 21:06:25 -04:00
toasted-nutbread
bc6d855f3d
Fix incorrect handlebars execution context in helpers (#645) 2020-06-29 19:02:35 -04:00
toasted-nutbread
a16a8f53e6
Rename GenericDatabase to Database (#634) 2020-06-28 17:29:16 -04:00
toasted-nutbread
441c23bf3b
Rename Database to DictionaryDatabase (#633) 2020-06-28 17:24:06 -04:00
toasted-nutbread
7590055d4e
Merge BackendEventHandler into Backend class (#632)
* Merge BackendEventHandler into Backend class

* Remove unused public functions
2020-06-28 17:22:44 -04:00
toasted-nutbread
5183fb575f
Backend refactor (#631)
* Mark fields as private

* Remove static

* Make functions private

* Create onCommand handler

* Group event handlers

* Move functions

* Merge _onOptionsUpdated and _applyOptions

* Rename event handler

* Move event handlers

* Remove _getOptionsSchema

* Move private functions
2020-06-28 14:59:01 -04:00
toasted-nutbread
f2345b7d1c
Use deferPromise (#630)
* Use deferPromise

* Move definition

* Implement promiseTimeout using deferPromise
2020-06-28 14:39:43 -04:00
toasted-nutbread
7b5dd5c310
Update browser compatibility and Edge detection (#629) 2020-06-28 12:40:02 -04:00
toasted-nutbread
cdf191336a
Clone function (#624)
* Add clone function

* Replace utilIsolate with clone

* Replace JsonSchema.isolate with clone function

* Include core.js for tests which use json-schema.js

* Update visisted set
2020-06-28 12:38:34 -04:00
toasted-nutbread
5bf805755a
Yomichan object separation (#627)
* Move "yomichan" object setup to a separate file

* Update script imports

* Align message handlers

* Rename Yomichan.prepare to Yomichan.ready

* Add new prepare function

* Improve isExtensionUrl
2020-06-28 11:26:43 -04:00
toasted-nutbread
51981f0c4e
Add deferPromise function (#626) 2020-06-28 11:23:51 -04:00
0a6c08d0f5 Version 20.6.27.0 2020-06-27 19:02:52 -07:00
toasted-nutbread
22d70c9e22
Add lock icon (#628) 2020-06-26 17:22:29 -04:00
toasted-nutbread
6ee50b3c95
Make PopupFactory.prepare non-async (#625) 2020-06-25 18:32:29 -04:00
toasted-nutbread
3e68af8666
Shadow DOM container for popup iframes (#623)
* Add support for injecting stylesheets into a custom parent node

* Add api.getStylesheetContent

* Add support for injecting a CSS file's content

* Add usePopupShadowDom option

* Use a per-parentNode cache

* Add support for using a shadow DOM wrapper around popup iframes

* Ignore the popup container instead of the frame
2020-06-24 21:46:13 -04:00
toasted-nutbread
96932119f8
Remove window. from visualViewport, use local variable instead (#621) 2020-06-22 19:27:40 -04:00
toasted-nutbread
65c41975a6
Secure popup frame url changes (#622)
* Throw error if options is not ready

* Remove id

* Change unsecurePopupFrameUrl to useSecurePopupFrameUrl
2020-06-22 19:26:59 -04:00
toasted-nutbread
f2991fb9ee
Frontend initialization refactor (#610)
* Create member functions for ignoreElements and ignorePoint

* Create addFullscreenChangeEventListener utility

* Move popup creation management into Frontend

* Move getUrl implementation

* Remove old setup

* Remove try/catch block

* Error wrap

* Add prepare call to TextScanner

* Update depth when popup changes

* Refactor how Frontend gets PopupFactory and frameId

* Update popup preview to work

* Update popup preview frame to use the frontend's popup

* Update how nested popups are set up

* Error wrap

* Update how popups are set up on the search page

* Error wrap

* Error unwrap

* Add missing prepare

* Remove use of frontendInitializationData

* Catch and log errors
2020-06-21 16:14:05 -04:00
toasted-nutbread
244ab31bb2
Generic database (#600)
* Update test

* Rename db to _db

* Create GenericDatabase class

* Catch prepare error

* Allow database to be purged even if it was not open

* Remove unused functions

* Change static functions to non-static

* Delete and count using the media object store

* Update tests
2020-06-21 16:12:56 -04:00
toasted-nutbread
e23504613f
Use DOMTextScanner (#536)
* Use DOMTextScanner instead of TextSourceRange.seek*

* Move getNodesInRange to dom.js

* Move anyNodeMatchesSelector to dom.js

* Remove unused functions

* Update tests

* Add layoutAwareScan option

* Use layoutAwareScan for source and sentence scanning

* Remove unused IGNORE_TEXT_PATTERN
2020-06-21 16:07:51 -04:00
toasted-nutbread
4ebee3e17c
Context popup update (#594)
* Add link to the help button

* Update context.html to not use bootstrap

Styles moved into a separate file
Update icons

* Update terminology to correspond to new icons
2020-06-21 15:57:18 -04:00
toasted-nutbread
0c69e54fde
Optimize anki note field generation (#611) 2020-06-21 15:54:34 -04:00
toasted-nutbread
3db7b3a925
Add option to use the unsecure frame URL (#618) 2020-06-21 15:52:43 -04:00
toasted-nutbread
9e28db6ef7
Safely handle volume values that are out of range (#617) 2020-06-21 15:51:36 -04:00
toasted-nutbread
713bf29377
Handle stack overflow caused by wanakana.toKana (#615) 2020-06-21 15:50:50 -04:00
toasted-nutbread
6562d0c1e5
Template renderer class (#574)
* Convert handlebars.js to a class

* Move/rename function

* Update helper registration

* Rename helper functions

* Limit cache size

* Make render() async

* Rename and move
2020-06-15 20:11:54 -04:00
toasted-nutbread
b4a617cac3
Ignore getZoom errors (#604) 2020-06-14 15:14:47 -04:00
toasted-nutbread
b612bd8b8d
PopupProxy refactor (#609)
* Remove setDisabled member; replace with an event

* Pass frameOffsetForwarder directly to PopupProxy

* Replace .start with .prepare

* Make onMessage private

* Make message safer and handle unexpected inputs
2020-06-14 14:06:52 -04:00
toasted-nutbread
8d1a276a83
Remove debug log (#603) 2020-06-13 10:42:59 -04:00
toasted-nutbread
8a7ff6a18c
Replace XMLHttpRequest (#562)
* Replace XMLHttpRequest with fetch

* Implement fetch placeholder for tests
2020-06-13 10:23:04 -04:00
toasted-nutbread
5cba421201
Update the badge icon if the backend experiences an error (#602) 2020-06-13 10:20:12 -04:00
toasted-nutbread
8bc15e60b5
Detect language tags starting with "ja_" (#596) 2020-06-13 10:18:44 -04:00
toasted-nutbread
a84f188b73
Handle cases where platform info is not available (#597)
* Handle cases where platform info is not available

* Safely return the correct os property
2020-06-10 20:58:46 -04:00
toasted-nutbread
839e306cac
Immediate backend event handlers (#555)
* Add function to await until prepare is completed

* Create BackendEventHandler to synchronously set up event handling
2020-06-07 21:50:14 -04:00
toasted-nutbread
9767b76553
Use cross frame API (#553)
* Use new CrossFrameAPI for popup proxy communication

* Remove use of old cross-frame communication classes

* Remove use of old cross-frame communication files

* Make the crossFrame object a member of the api object
2020-06-07 21:40:11 -04:00
siikamiika
b614aca3dd
fix css class name (#591)
Broken in 90af55d4c84f545635f238178b30748a0e8093ee
2020-06-07 00:08:46 +03:00
siikamiika
0384e2afef
scale background icon when page is zoomed (#592) 2020-06-07 00:08:20 +03:00
toasted-nutbread
2c58b1c109
Limit action port message size (#587)
* Add onDisconnect handler

* Update how error is posted

* Update action ports to send long messages in fragments

* Remove ack timer

* Move message destructuring into try block
2020-05-31 18:17:12 -04:00
toasted-nutbread
cfd3a1ec3a
Update AudioController to not use mutable options references (#585) 2020-05-30 21:54:38 -04:00
toasted-nutbread
db209c9116
Generic settings controller merge (#584)
* Update how optionsContext is assigned to targets

* Add getSettings and modifySettings

* Merge DOMSettingsBinder into GenericSettingController

* Remove old DOMSettingsBinder
2020-05-30 21:53:36 -04:00
toasted-nutbread
ce7f9dd09a
Update how assignment of general.enableClipboardPopups works (#583) 2020-05-30 16:24:51 -04:00
toasted-nutbread
976a200ffc
Backup update (#582)
* Add function to assign all settings

* Update how settings backups are restored

* Remove page reload

* Update profile index after importing
2020-05-30 16:23:56 -04:00
toasted-nutbread
c8810bc929
Update AnkiController (#581)
* Update how fields are populated

* Update how fields are modified after a model change

* Update how _onFieldsChanged assigns fields

* Update how spinner is hidden

* Remove jQuery usage

* Use non-jQuery events
2020-05-30 16:22:51 -04:00
toasted-nutbread
ad8df26b6b
Update AnkiTemplatesController (#580)
* Use this._defaultFieldTemplates

* Don't use mutable options

* Remove some use of jQuery
2020-05-30 16:22:05 -04:00
toasted-nutbread
395a0f4096
Update GenericSettingController to use DOMSettingsBinder (#578) 2020-05-30 16:20:31 -04:00
toasted-nutbread
f228078613
SettingsController API update (#579)
* Include optionsContext as part of optionsChanged event

* Add get/modify functions
2020-05-30 11:24:34 -04:00
toasted-nutbread
789da0206b
Organize settings/main.js (#577) 2020-05-30 09:50:33 -04:00
toasted-nutbread
63a3e56367
Use SettingsController (#576)
* Use settingsController internally in settings/main.js

* Replace modifyingProfileChange with SettingsController.optionsContextChanged

* Update ClipboardPopupsController to use SettingsController

* Store reference to checkbox

* Use this._settingsController for everything

* Change where current profile is initially assigned from

* Remove some unnecessary async calls

* Move setup calls

* Update AnkiTemplatesController to use SettingsController

* Cache default field templates

* Update AnkiController to use SettingsController

* Update AudioController to use SettingsController

* Update SettingsBackup to use SettingsController

* Update DictionaryController to use SettingsController

* Update GenericSettingController to use SettingsController

* Update ProfileController to use SettingsController

* Remove unused

* Remove unused

* Replace some uses of api.options* functions

* Fix missing awaits

* Fix invalid function
2020-05-30 09:33:13 -04:00
toasted-nutbread
1a5a37c9e4
Fix frontend being null if messages are received early (#575) 2020-05-30 09:31:46 -04:00
toasted-nutbread
18f376358c
Generic settings controller + clipboard popups controller (#573)
* Create GenericSettingController

* Create ClipboardPopupsController
2020-05-29 20:33:40 -04:00
toasted-nutbread
df040b104a
Popup preview frame refactor (#572)
* Use private variables

* Use private methods

* Update overrides

* Make prepare called in the entry point function

* Change format of handlers

* Change where _apiOptionsGetOld is assigned

* Rename class
2020-05-29 20:29:19 -04:00
toasted-nutbread
9624566d2a
Convert popup-preview.js to a class (#571)
* Convert popup-preview.js to a class

* Don't invoke 'prepare'
2020-05-29 20:28:12 -04:00
toasted-nutbread
418e8a57bf
Convert dictionaries.js and storage.js to classes (#570)
* Convert dictionaries.js to a class

* Remove storage spinner

* Convert storage.js to a class

* Move dataset assignments into main.js
2020-05-29 20:25:22 -04:00
toasted-nutbread
c62f980f37
Audio controller (#569)
* Convert audio.js into a class

* Move audio-ui.js classes into audio.js

* Rename fields

* Merge classes

* Remove audio-ui.js
2020-05-29 19:56:38 -04:00
toasted-nutbread
5f9889fd26
Anki settings controllers (#567)
* Convert anki-templates.js to a class

* Convert anki.js to a class
2020-05-29 19:52:51 -04:00
toasted-nutbread
fde0072118
Change profile.js into a class (#566)
* Update how settings profile is stored and accessed

* Convert profiles.js into a class

* Rename members of ProfileController
2020-05-29 19:47:18 -04:00
toasted-nutbread
8537c8f386
Create class to abstract access, mutation, and events for settings (#565) 2020-05-29 19:45:54 -04:00
toasted-nutbread
37f0396f1c
DOM binder fixes (#564)
* Fix incorrect updateValue function

* Add source
2020-05-29 19:44:53 -04:00
toasted-nutbread
9d40955fc8
Update legal.html to include full licenses (#563) 2020-05-24 22:10:50 -04:00
toasted-nutbread
6dd6af05e1
Update background global object usage (#556)
* Omit global window object for scripts used on the background page

* Validate document exists before using

* Remove dom.js from background.html
2020-05-24 14:01:21 -04:00
toasted-nutbread
3c4c82dcfc
Ensure single popup factory (#554)
* Add createPopupFactory

* Ensure only a single PopupFactory is generated
2020-05-24 14:00:32 -04:00
toasted-nutbread
13f57cccba
Settings backup refactor (#551)
* Update backup.js to be a class

* Move utilReadFileArrayBuffer
2020-05-24 13:56:46 -04:00
toasted-nutbread
66e1185686
Settings binder (#542)
* Fix _modifySetting being async

* Return values for modifySettings's set and splice actions

* Add apiGetSettings

* Create a class which can accumulate tasks to run in bulk

* Create a class which binds input elements to customizable sources

* Create class which binds input elements to settings

* Add support for value transforms

* Remove redundant ObjectPropertyAccessor.getPathArray

* Fix not using correct types for input.min/max/step

* Fix wrong condition

* Use api object
2020-05-24 13:50:34 -04:00
toasted-nutbread
c800444a0d
Ensure the return value of promiseTimeout always has .resolve and .reject (#550) 2020-05-24 13:39:50 -04:00