MediaWiki:Common.js: различия между версиями

Нет описания правки
Нет описания правки
 
(не показано 7 промежуточных версий этого же участника)
Строка 1: Строка 1:
if(document.getElementById('currency-converter-root')) {
if(document.getElementById('currency-converter-root')) {
mw.loader.using('ext.gadget.currency-converter', console.log, console.error)
mw.loader.using('ext.gadget.currency-converter', console.log, console.error)
}
const decodeCyrillic = (url) => {
  return url.replace(/%[0-9A-F]{2}/gi, (match) => {
    try {
      const char = decodeURIComponent(match)
      return /[\u0400-\u04FF]/.test(char) ? char : match
    } catch {
      return match
    }
  })
}
}


Строка 18: Строка 7:
if(copyLink) {
if(copyLink) {
copyLink.addEventListener('click', e => {
copyLink.addEventListener('click', e => {
copy(decodeCyrillic(window.document.location.href))
e.preventDefault()
copy(decodeURI(window.document.location.href))
e.target.textContent = 'Ссылка скопирована!'
e.target.textContent = 'Ссылка скопирована!'
if(copyLinkTimeout !== undefined) clearTimeout(copyLinkTimeout)
if(copyLinkTimeout !== undefined) clearTimeout(copyLinkTimeout)
copyLinkTimeout = setTimeout(() => {
copyLinkTimeout = setTimeout(() => {
e.textContent = 'Скопировать ссылку'
e.target.textContent = 'Скопировать ссылку'
}, 3000)
}, 3000)
e.target.closest('a').blur()
return false
})
})
}
}