Diferencia entre revisiones de «MediaWiki:Gadget-extra-hooks.js»

(try this)
 
m (always forward args)
 
(No se muestra una edición intermedia del mismo usuario)
Línea 1: Línea 1:
// this gadget sets up all the extra hooks that the coppermind uses for it's other gadgets
// this gadget sets up all the extra hooks that the coppermind uses for it's other gadgets
mw.hook('wikipage.content').add(function extra_hooks() {
mw.hook('wikipage.content').add(function extra_hooks(content) {


/// hook for catching particular pages
/// hook for catching particular pages
Línea 6: Línea 6:
const page_hook = mw.config.get('wgPageName')
const page_hook = mw.config.get('wgPageName')
console.debug('extra-hook:', page_hook)
console.debug('extra-hook:', page_hook)
mw.hook(page_hook).fire()
mw.hook(page_hook).fire(content)
}
}


Línea 13: Línea 13:
const ns_hook = 'mw-ns-'+ mw.config.get('wgNamespaceNumber')
const ns_hook = 'mw-ns-'+ mw.config.get('wgNamespaceNumber')
console.debug('extra-hook:', ns_hook)
console.debug('extra-hook:', ns_hook)
mw.hook(ns_hook).fire()
mw.hook(ns_hook).fire(content)
}
}


Línea 20: Línea 20:
const act_hook = 'mw-action.'+ mw.config.get('wgAction')
const act_hook = 'mw-action.'+ mw.config.get('wgAction')
console.debug('extra-hook:', act_hook)
console.debug('extra-hook:', act_hook)
mw.hook(act_hook).fire()
mw.hook(act_hook).fire(content)
}
}


Línea 26: Línea 26:
if (mw.config.exists('wgPostEdit')) {
if (mw.config.exists('wgPostEdit')) {
const act_hook = 'mw-action.just-saved'
const act_hook = 'mw-action.just-saved'
console.debug('extra-hook:', act-hook)
console.debug('extra-hook:', act_hook)
mw.hook(act_hook).fire()
mw.hook(act_hook).fire(content)
}
}



Revisión actual - 21:22 21 abr 2020

// this gadget sets up all the extra hooks that the coppermind uses for it's other gadgets
mw.hook('wikipage.content').add(function extra_hooks(content) {

/// hook for catching particular pages
/**/{
  const page_hook = mw.config.get('wgPageName')
  console.debug('extra-hook:', page_hook)
  mw.hook(page_hook).fire(content)
}

/// hook for catching particular namespace
/**/{
  const ns_hook = 'mw-ns-'+ mw.config.get('wgNamespaceNumber')
  console.debug('extra-hook:', ns_hook)
  mw.hook(ns_hook).fire(content)
}

/// hook for catching different page actions
if (mw.config.get('wgAction') != 'view') {
  const act_hook = 'mw-action.'+ mw.config.get('wgAction')
  console.debug('extra-hook:', act_hook)
  mw.hook(act_hook).fire(content)
}

/// hook for catching after a page has been saved
if (mw.config.exists('wgPostEdit')) {
  const act_hook = 'mw-action.just-saved'
  console.debug('extra-hook:', act_hook)
  mw.hook(act_hook).fire(content)
}

})