Add DocLoad aucmd

This commit is contained in:
Colin Caine 2018-07-18 14:36:35 +01:00
parent 2cce4f3571
commit 6ed83eacdb
2 changed files with 13 additions and 6 deletions

View file

@ -1,5 +1,11 @@
# Tridactyl changelog
## Unreleased
* New features
* `DocLoad` autocmd added. It fires on DOMContentLoaded.
## Release 1.13.1 / 2018-06-20
* New features

View file

@ -1318,14 +1318,15 @@ export async function reader() {
//@hidden
//#content_helper
// {
loadaucmds("DocStart")
//#content_helper
window.addEventListener("pagehide", () => loadaucmds("DocEnd"))
window.addEventListener("DOMContentLoaded", () => loadaucmds("DocLoad"))
// }
/** @hidden */
//#content
export async function loadaucmds(cmdType: "DocStart" | "DocEnd" | "TabEnter" | "TabLeft") {
export async function loadaucmds(cmdType: "DocStart" | "DocLoad" | "DocEnd" | "TabEnter" | "TabLeft") {
let aucmds = await config.getAsync("autocmds", cmdType)
const ausites = Object.keys(aucmds)
const aukeyarr = ausites.filter(e => window.document.location.href.search(e) >= 0)
@ -2500,10 +2501,10 @@ export function set(key: string, ...values: string[]) {
/** @hidden */
//#background_helper
let AUCMDS = ["DocStart", "DocEnd", "TriStart", "TabEnter", "TabLeft"]
let AUCMDS = ["DocStart", "DocLoad", "DocEnd", "TriStart", "TabEnter", "TabLeft"]
/** Set autocmds to run when certain events happen.
@param event Curently, 'TriStart', 'DocStart', 'DocEnd', 'TabEnter' and 'TabLeft' are supported.
@param event Curently, 'TriStart', 'DocStart', 'DocLoad', 'DocEnd', 'TabEnter' and 'TabLeft' are supported.
@param url For DocStart, DocEnd, TabEnter, and TabLeft: a fragment of the URL on which the events will trigger, or a JavaScript regex (e.g, `/www\.amazon\.co.*\/`)
@ -2526,7 +2527,7 @@ export function autocmd(event: string, url: string, ...excmd: string[]) {
}
/** Remove autocmds
@param event Curently, 'TriStart', 'DocStart', 'DocEnd', 'TabEnter' and 'TabLeft' are supported.
@param event Curently, 'TriStart', 'DocStart', 'DocLoad', 'DocEnd', 'TabEnter' and 'TabLeft' are supported.
@param url For DocStart, DocEnd, TabEnter, and TabLeft: a fragment of the URL on which the events will trigger, or a JavaScript regex (e.g, `/www\.amazon\.co.*\/`)
*/