Greasy Fork is available in English.

Wanikani Open Framework Turbo Events

Adds helpful methods for dealing with Turbo Events to WaniKani Open Framework

יש גרסאות של סקריפט זה עם קוד מעודכן. הצג את כל הגרסאות

  • v4.2.2 27-11-2024

    Updated the warning to not output the stack trace in the message itself.

    Bump version to 4.2.2

  • v4.2.1 27-11-2024

    Removed some leftovers. Moved urlHandlers to the proper section.

    Updated README.md for consistency and accuracy.

    Added the same adjustment to the JSDocs Also removed one of the forced line breaks in the table.

    Removed "Supported" column in README.md table.

    Since all are now supported, the information was superfluous. Added various links to the mozilla docs where appropriate. Updated some descriptions to be more clear.

    Fixed example in README.md.

    Fixed the last example to make the options match the earlier options. Also updated the JSDoc to match earlier changes.

    Updated examples in README.md.

    Updated the examples to use add_event_listeners instead of on.common.eventList

    Added removeListener to events in README.md.

    Added removeListener(callback, options) to each of the events, and bolded the methods instead of using a code block

    Prioritize using "listener" over "callback"

    Updated all the parameter names consistent and most other references to "callback" or "callback function" to now use "listener" for consistency. Removed an inaccurate statement in the example that was leftover of an old version.

    Use Promise.resolve().then() instead of setTimeout().

    setTimeout(callback, 0) creates a macrotask, whereas Promise.resolve().then(callback) creates a microtask, and they both appear to work properly, as far as "turbo:load" is concerned. This also alleviates potential warning messages in the console in the case that the callback of setTimeout took a significant amount of time to execute. The setTimeout version can be used via the options parameter by setting timeout to 'setTimeout'. The noTimeout option has been changed to this setting.

    Reverted default timeout to setTimeout. Added noWarn option. Made url a URL. Bumped version.

    Added noWarn option and removed wkof.turbo.silenceWarnings global configurable. The url parameter passed to the listener is now a URL object. The warning logged to the console is now a custom Error object, which facilitates providing the stack trace. Bumped the version to 4.2.0. Added many links to the README. Updated many descriptions and spacings in the README table. Updated the examples to match the new options and changes.

    Added urlHandler option. Bumped to version 4.2.1.

    urlHandler is a function taking a URL parameter and which returns a boolean indicating whether the listener should be called. Currently not documented in the README.md.

    Added items_pages common location

    Fixed position of comment lines

    Added downloadURL and updateURL

  • v4.1.1 12-08-2024

    #### Added `add_event_listeners`. Deprecated `wkof.turbo.on.common.eventList`. Bumped version.

    Added `wkof.turbo.add_event_listeners(eventList, listener, options)`, replacing `wkof.turbo.on.common.eventList`.
    Updated the README to match.
    Also added wkof.turbo prefixes to links as appropriate in the README

    #### Reverted inlining of `eventMap`.

  • v4.1.0 12-08-2024

    Commit ALL THE THINGS

    Many updates to README.md, including significant formatting updates and internal linking. Added actual support for the AbortSignal (internally). Updated the removeExistingTurboVersion method to hopefully have more consistent behavior with older versions. Added additional checks, fixes, and optimizations.

    Added type indicators to README.md

    Added indicators for the type on each of the properties in README.md

    Updated headings in README.md

    Made all the wkof.turbo headings a Heading 2 (i.e., ####) now, and removed their "code" markdown syntax from their names.

    Updated blank lines in README.md

    Made sure there is at least one blank line before and after a heading.

    Updated indents in README.md

    Made indents four spaces throughout for consistency

    Updated some doc links in README.md. Updates to JSDoc info to match.

    Added correct parameter types to the docs.

    Fixed removeListener.

    Had the findIndex call in the wrong method. Moved removeListener so that it's less confusing

    Added remove_event_listeners

    Can now more easily remove multiple event listeners with a single call.

    Updated the docs with remove_event_listeners

    Updated the example in README.md

    Updated the example to match the object in version 4. Added some more detail and adjusted things to better illustrate how certain thing will and will not function.

    Updated the README.md for compatibility.

    Escaped underscores not in code segments/blocks, and substituted bars "|" in the table for the full-width version "|" so it does not break.

  • v4.0.0 09-08-2024

    Added more effective null/undefined checking. Improved "load" custom event.

    Added better checking for null variables or properties, and made getListenerOptions() return much more explicitly defined. Reverted change to addTypicalPageListener(), so it once again calls the custom "load" event. The custom "load" event, when triggered, now provides the same structure of callback as provided to the Turbo event callbacks. Displays a console warning if attempting to add a listener after the page has already finished loaded. This warning can be silenced with wkof.turbo.silenceWarnings = true, which is automatically done temporarily when calling addTypicalPageListener()

    Fixed the reference to silenceWarnings being on the wrong object

    Refactor to using a new TurboEvents class to handle all the event handlers.

    Each listener is wrapped with a single handler before being added as a separate listener to the page rather than trying to handle them all at the same time.

  • v3.0.4 08-08-2024

    Updated the method of removing the internal listeners to the new structure.

  • v3.0.3 08-08-2024

    Fix to return early when appropriate. Take 2

    Bump the version in the script.

  • v3.0.2 08-08-2024

    Fix to return early when appropriate.

  • v3.0.1 08-08-2024

    Removed persistent from the options.

    This option is no longer being used, and instead, a separate (non-propagating) listener is added at the start.

  • v3.0.0 08-08-2024

    Fixed oversight in old version handling.

    Now forcefully continues to remove the existing version, including versions prior to adding the "_.internal" property to the public object, and display a warning that can be silenced to the user. Also updated isNewerThan to return properly when the provided value is nonexistent.

    Added/modified JSDoc comments. Sorted functions and variables. Added more error checking and optimizations. Added table to README.md.

    Added or modified many JSDoc comments, including defining some interface types. Sorted some functions alphabetically and rearranged some variables. Also added some additional error checks, such as for undefined/null arguments or properties. Made some other optimizations. Added functionality to start supporting using standard AddEventListenerOptions options. Added a table to README.md describing the options object.

  • v2.2.4 06-08-2024

    #### Fix for verifyOptions using the wrong url

    #### Added system for embedded version control

  • v2.2.3 06-08-2024

    Fixed an edge-case for the RegExp tester

    Fixed an issue that could arise if using RegExp objects with the global flag set.

    Added an option for filtering by id. Optimized other areas.

    It is now possible to set targetIds in the options parameter to a list of ids to be matched against the event.target.id property.

    Trying a new option for emitting the handlers. Bumping version.

  • v2.2.2 06-08-2024

    Use Object.definedProperties instead of Object.definedProperty cause it just works.

  • v2.2.1 06-08-2024

    Made locations non-writable as well.

  • v2.2.0 06-08-2024

    Added listeners. Added url parameter. Fixed wrong handler being added internally.

    Added listeners for the remaining unhandled events. Added url parameter to callback arguments. Fixed the problem causing handleEvent() to be used as the callback for internal events instead of the custom handler made in the startup.

    Added deepFreeze method. Sorted various methods. Updated README.md. Bumped version.

    Properly froze or set properties non-writable for the output interface. Added notes, definitions, and explanations to README.md and sorted the property names for event. Finally updated addEventListener to return false for the "load" event if it does not run the callback.

    Fixed a scenario where an event could be called twice with "once:true".

    If "once" was set to true, it was possible that a listener could be called twice before it was actually removed. This attempts to fix that condition.

  • v2.1.0 05-08-2024

    Fixed for URL sometimes not getting set in time. Bump version to 2.1.0.

    Previously, there were times when someone could register a listener and it would trigger before turbo:load had run at least once, thus causing the passed URL not to match. Added additional logic for fetch URLs. Reduced a decent amount of semi-duplicate code in addTurboEvents().

  • v2.0.4 05-08-2024

    Bug fixes and content updates (see GitHub)

  • v2.0.3 31-07-2024

    Fixed removeEventListener behavior in respect to the options parameter

    options no longer needs to be a reference to the same object, but simply must contain the same options.
    The listener still must be a reference to the same listener, however. E.g., if a defined function passed was redefined before being passed to the removal function, it will not match and thus will not be removed.
    The function also no longer returns a false positive in the scenario that at least one handler exists for that event and undefined was passed for the options

  • v2.0.2 30-07-2024
    • Changed wkof.turbo.on.turbo to wkof.turbo.on.event
    • Added noTimeout boolean to the options parameter. Updated/optimized the handleEvent logic.
      • Setting that to true allows the user to have the event fire immediately instead of waiting for it to resolve via the built-in setTimeout call.
  • v2.0.1 29-07-2024

    Complete refactor of the general logic and the structure of the wkof.turbo object

    Also updated the README to match the changes.

  • v1.1.2 28-07-2024
  • v1.1.1 28-07-2024

    Removed some stuff that was added for testing.

  • v1.1.0 28-07-2024

    Updated a variety of areas to allow for more flexibility and added a bunch more examples and explanation to the additional info

  • v1.0.0 28-07-2024