MediaWiki:Gadget-extra-hooks.js

De La Coppermind
Ir a la navegación Ir a la búsqueda

Nota: tras guardar, quizás necesites actualizar la caché de tu navegador para ver los cambios.

  • Firefox/Safari: Mantén presionada la tecla Mayús mientras pulsas el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
  • Google Chrome: presiona Ctrl+Shift+R (⌘+Mayús+R en Mac)
  • Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar, o presiona Ctrl+F5
  • Opera: dirígete a Menú → Configuración (Opera → Preferencias en Mac) y luego a Privacidad y seguridad → Borrar datos de navegación → Imágenes y archivos en caché.
// 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)
}

})