MediaWiki:Gadget-tilemarkers-core.js

From RuneRealm Wiki
Jump to navigation Jump to search

After saving, you may need to bypass your browser's cache to see the changes. For further information, see Wikipedia:Bypass your cache.

  • In most Windows and Linux browsers: Hold down Ctrl and press F5.
  • In Safari: Hold down ⇧ Shift and click the Reload button.
  • In Chrome and Firefox for Mac: Hold down both ⌘ Cmd+⇧ Shift and press R.
var ACTIVE_TEXT = 'Copied'
var DEFAULT_TEXT = 'Copy tile markers'

function onClick(button) {
    t = button.$element[0]
	navigator.clipboard.writeText(t.nextElementSibling.innerHTML);
	
	// Set the copied state and queue changing back
    button.setLabel(ACTIVE_TEXT); button.setIcon('check')
    setTimeout(function() { button.setLabel(DEFAULT_TEXT); button.setIcon(null) }, 3000)
}

function createButton() {
	button = new OO.ui.ButtonWidget({
        label: DEFAULT_TEXT,
        flags: ['primary', 'progressive'],
        classes: ['tile-marker-button']
    });
    button.on('click', onClick, [button])
    return button
}

$('.tilemarker-div').before(function() { return createButton().$element})