Commit Graph

2451 Commits

Author SHA1 Message Date
toasted-nutbread
bdb4c21a78
Make Popup extend EventDispatcher for parity with PopupProxy (#746) 2020-08-22 14:35:29 -04:00
toasted-nutbread
1dc35dd6f1
Popup factory proxy creation (#745)
* Change getOrCreatePopup to async

* Rename parentFrameId to frameId, expose frameId property

* Update how proxy popups are created
2020-08-22 14:33:41 -04:00
toasted-nutbread
e9c540a0b9
Fix error during pitch accent info generation for kanji data (#744) 2020-08-22 13:10:50 -04:00
toasted-nutbread
cc9481bd38
Revert "Add PopupVoid (#734)" (#739)
This reverts commit 90d6944290.
2020-08-22 13:04:20 -04:00
toasted-nutbread
1f564b94cb
XMLDocument handling (#738)
* Add tests for SVGs

* Add more null checks for Frontend._popup

* Use null popup when on an XMLDocument
2020-08-22 13:03:35 -04:00
toasted-nutbread
c26c4ae0cb
Frontend initialization refactor (#737)
* Fix incorrect popup depth reassignment

* Rename variable

* Rename property

* Use explicit parameter values

* Refactor setupNestedPopups

* Refactor frontend initialization
2020-08-16 16:16:18 -04:00
toasted-nutbread
90d6944290
Add PopupVoid (#734) 2020-08-15 17:37:56 -04:00
toasted-nutbread
4d6851ec32
Refactor some frontend cross-frame communication (#733)
* Refactor iframe proxy setup

* Simplify document title acquisition
2020-08-15 17:36:42 -04:00
toasted-nutbread
d5865db457
Popup API refactor (#732)
* Simplify how parent/child are set

* Remove unused public frameId property

* Change use of getFrame

* Simplify parent access

* Use property for the container

* Remove isProxy

* Public function API parity

* Public property API parity
2020-08-15 17:27:03 -04:00
toasted-nutbread
d582c7a0f8
JSON schema refactor (#731)
* Remove JsonSchema.clone

* Move createProxy function

* Group public properties first

* Create private version of getPropertySchema

* Mark functions as private

* Use non-static getValidValueOrDefault

* Mark private

* Make public validate function not take an info parameter

* Remove JsonSchema

* Add isValid function

* Use isValid for some tests

* Fix incorrect type
2020-08-15 17:23:09 -04:00
toasted-nutbread
d8649f40d5
JSON-schema-based profile conditions (#730)
* Add ProfileConditions class

* Add URL to VM

* Add new ProfileConditions tests
2020-08-15 17:22:23 -04:00
toasted-nutbread
587822c16e
More JSON schema improvements (#729)
* Add support for constant values

* Add contains check for arrays

* Add tests

* Simplify getValidValueOrDefault testing
2020-08-11 19:21:26 -04:00
toasted-nutbread
abfa0362dd
Remove leftover handlebars.js imports (#728) 2020-08-09 21:18:36 -04:00
toasted-nutbread
2a86d66092
DOM + DocumentUtil merge (#727)
* Add DOM functions to DocumentUtil

* Use DocumentUtil instead of DOM

* Remove DOM

* Move document-util.js into mixed
2020-08-09 21:07:11 -04:00
toasted-nutbread
9f8f83508e
Merge dictionary.js functions into Translator class (#726)
* Move dictFieldSplit

* Copy dictionary.js definitions into translator.js

* Convert to member functions

* Refactor names

* Remove dictionary.js

* Rename
2020-08-09 21:04:09 -04:00
toasted-nutbread
f502dd4f21
Search refactoring (#725)
* Rename node fields to disambiguate

* Change order
2020-08-09 21:03:11 -04:00
toasted-nutbread
486d44f719
Json schema improvements (#722)
* Add support for regex pattern testing

* Add tests

* Separate JsonSchemaProxyHandler statics into JsonSchemaValidator

* Use this instead of JsonSchemaValidator

* Make JsonSchemaValidator non-static

* Use cache map for regex
2020-08-09 14:18:59 -04:00
toasted-nutbread
fbe575c577
Fix a stray error printed due to not catching (#723) 2020-08-09 14:14:56 -04:00
toasted-nutbread
6da02c6eee
document.js refactor (#719)
* Refactor document.js into a class

* Move public functions first

* Rename private functions

* Rename

* Rename argument

* Use instance of DocumentUtil

* Update tests

* Refactor

* Rename (test-)document.js to (test-)document-util.js
2020-08-09 13:27:21 -04:00
toasted-nutbread
480e0e15e3
Translator refactor (#720)
* Move simple find sort into translator.js

* Remove unused

* Use direct reference to database

* Make field private

* Remove statics

* Convert functions to private

* Organize by public/private
2020-08-09 13:21:14 -04:00
toasted-nutbread
427cf99b9f
Remove unused dependencies on context.html (#718) 2020-08-09 13:20:48 -04:00
toasted-nutbread
e87cc5c37d
Query parser text scanner options refactor (#717)
* Add _setSelectedParser helper

* Update TextScanner internal options representation

* Update QueryParser internal options representation
2020-08-09 13:19:42 -04:00
toasted-nutbread
b3eb2cb1ef
Fix overlapping version checks (#716) 2020-08-09 13:17:15 -04:00
toasted-nutbread
d856e4caac
CacheMap (#715)
* Create CacheMap class

* Add test
2020-08-09 13:15:56 -04:00
toasted-nutbread
8ee717cdf7
Persistent display mode (#714)
* Simplify calls using chrome.tabs.sendMessage and getMessageResponseResult

* Rename message handlers

* Move onMessage handler into Display

* Assign search popup mode which persists across refreshes

* Update clipboard monitor on the search page

* Remove mode param
2020-08-09 13:11:41 -04:00
toasted-nutbread
04d47bf8a9
Build system changes (#721)
* Refactor manifest.json

* Change end-of-line convention for built plain-text files

* Ignore builds directory

* Mark the "dev" directory as using the node environment

* Create build script

* Register build scripts

* Remove old build script

* Fix 64x64 icon

* Add test to ensure manifest data is updated properly
2020-08-09 13:09:06 -04:00
14efd8a824 Update verison to 20.8.3.0 2020-08-03 17:01:40 -07:00
toasted-nutbread
b253cdc92e
Fix extension unload cases (#712)
* Add _invokeSafe function to silently ignore extension unload errors

* Remove "Api" from function names

* Add invokeSafe to Popup

* Don't redundantly set content type to 'unloaded'
2020-08-02 21:51:51 -04:00
toasted-nutbread
a81d69d6c1
Add support for history navigation using mouse buttons in the popup window (#707) 2020-08-02 19:00:36 -04:00
toasted-nutbread
1184320e3e
Button and image scanning (#705)
* Update TextSourceElement.equals check to match TextSourceRange.equals

* Force full query to be visible when scanning buttons or images with more text

* Update style of query parser
2020-08-02 18:59:35 -04:00
toasted-nutbread
bdcdf9b1f5
Strip request origin (#710)
* Add web request permissions

* Create fetch wrapper that anonymizes the request

* Fix Firefox not supporting 'extraHeaders' option
2020-08-02 18:58:19 -04:00
toasted-nutbread
a37ca1d378
Fix _setContentTermsOrKanjiUpdateAdderButtons not working (#709)
this._setContentToken was cleared, so comparison exited.
There is not really a good reason to clear this object.
2020-08-02 16:58:15 -04:00
toasted-nutbread
b1b33f8beb
Fix fetch requests (#708)
* Revert audio fetching functionality to use XMLHttpRequest

* Replace requestJson

* Replace requestJson

* Replace requestJson

* Replace requestJson and requestText

* Fix tests

* Include support for vulgar word searches

* Remove request.js
2020-08-02 13:30:55 -04:00
toasted-nutbread
a562a11498
Display try catch refactor (#704)
* Remove try-catch from _termLookup

Already handled by _onTermLookup

* Move try-catch out of _onTermLookup and into _onGlossaryMouseUp
2020-08-01 16:33:21 -04:00
toasted-nutbread
838fd211c6
Pitch accent Anki field templates (#701)
* Template helper updates

* Add pitch data to exported field formatting data

* Reuse note data

* Add no-op

* Set up pitch accent templates

* Refactor version update functions

* Implement upgrade process for new Anki templates

* Consistency

* Update README and anki.js to have matching markers
2020-08-01 16:23:33 -04:00
toasted-nutbread
1e839cd230
More display refactoring (#697)
* Remove some unnecessary _setQuery calls

* Add support for forcing the query parser to be visible or hidden

* Move _setEventListenersActive calls

* Remove URL for kanji links

* Refactor _setContentTermsOrKanji

* Move search query text assignment into Display

* Move title updates into Display

* Move popup close calls

* Prevent infinite loop of extension unload events
2020-08-01 16:22:00 -04:00
toasted-nutbread
b52074b3f0
Options util (#700)
* Move options functions into a class

* Rename and privatize

* Organize by public/private

* Refactor to use async function

* Simplify update function signature

* Add comment for update

* Rename

* Copy _applyUpdates into _legacyProfileUpdateUpdateVersion

* Organize

* Move profile options updates

* Refactor update details

* Add async support

* Formatting
2020-08-01 11:46:35 -04:00
toasted-nutbread
f1e7288c11
Additional template renderer helpers (#699)
* Add spread function

* Add generic operator evaluation function

* Add variable get/set/scope functions

* Add isMoraPitchHigh function
2020-07-31 16:17:58 -04:00
toasted-nutbread
736d3c892e
Dictionary data utility class (#698)
* Create utility class for helping format dictionary data

* Change format
2020-07-30 20:45:52 -04:00
toasted-nutbread
6e0b25c5d6
Standardize hotkey action naming convention (#696) 2020-07-26 20:25:15 -04:00
toasted-nutbread
313476aa92
Query parser fix (#695)
* Standardize setContent calls

* Rename _queryText to _fullQuery

* Move query parser into Display and update float.html

* Generalize params

* Add "full" parameter to maintain the original full query
2020-07-26 19:29:12 -04:00
toasted-nutbread
0512258c8e
Display scroll refactor (#694)
* Cache navigation header

* Create _focusEntry

* Update scroll restoration

* Require explicit entry focus index
2020-07-26 18:49:38 -04:00
toasted-nutbread
104650627d
Merge redundant toggle handling code (#693) 2020-07-26 16:53:24 -04:00
toasted-nutbread
fca0004597
Don't assign mode as a search parameter (#692) 2020-07-26 16:52:45 -04:00
toasted-nutbread
208217198e
Display history refactor (#691)
* Create DisplayHistory

* Change arguments for _setContentTermsOrKanji

* Set up history-driven content updates

* Use new history only

* Load definitions if missing

* Refactor definitions getting

* Add support for wildcards

* Move definitions setup

* Add events

* Allow state change even if there is no history state

* Update search page to use history

* Fix history overwriting

* Fix search page not seeing state chang events during prepare

* Update state if necessary

* Don't reassign query text if the same

* Remove DisplayContext

* Initialize with real history state

* Track URL

* Update DisplayHistory to support pseudo-history

* Configure history settings on search page

* Fix state

* Use full URL

* Change data format of setContent

* Rename details to content

* Update event arguments

* Fix animation

* Remove old state changes

* Clear content properly

* Remove set/clear content overrides

* Fix setting up event listeners for content clear

* Make clearContent private

* Make focus opt-in

* Validate source

* Add unloaded type

* Generalize content params

* Update how extension unload content is assigned

* Restore query blurring
2020-07-26 16:51:54 -04:00
toasted-nutbread
e153971cd4
Add eachUpTo function (#690) 2020-07-26 16:50:56 -04:00
toasted-nutbread
2ed2b22d49
Fix search popup mode (#687)
* Fix missing mode on search popup

* Remove mode update
2020-07-25 13:23:51 -04:00
toasted-nutbread
4a43b41f79
Set content refactor (#686)
* Simplify invoke

* Pass isTerms instead of type

* Update DisplaySearch.setContent to pass argument array

* Simplify argument object structure for setContent

* Move focus and disableHistory level

* Always include focus and disableHistory options

* Change disableHistory to history

* Pass source text to setContent

* Use consistent argument/object field order

* Remove unused previous field

* Combine logic for forward/back navigation
2020-07-25 09:58:06 -04:00
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