2015-12-09 21:05:24 +01:00
|
|
|
const TAG_UUID = "data-player-uuid";
|
|
|
|
|
|
|
|
var elements = document.querySelectorAll('[' + TAG_UUID + ']'); // NodeList type
|
|
|
|
|
|
|
|
for (var i = 0; i < elements.length; i++)
|
|
|
|
{
|
|
|
|
var element = elements.item(i);
|
|
|
|
|
|
|
|
element.addEventListener("click", (function(element)
|
|
|
|
{
|
|
|
|
return function(e)
|
|
|
|
{
|
|
|
|
var uuid = element.getAttribute("data-player-uuid");
|
2015-12-13 20:12:32 +01:00
|
|
|
copy(uuid);
|
|
|
|
alertElement('<b>Copied UUID to clipboard.</b>', element, 1500);
|
2015-12-09 21:05:24 +01:00
|
|
|
}
|
|
|
|
})(element));
|
|
|
|
|
2015-12-13 20:12:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to copy the supplied text into the users clipboard.
|
|
|
|
* If this fails they are presented with a box allowing them to copy and paste the text.
|
|
|
|
* This will only work on a supported browser and if this action is caused by some sort of player input.
|
|
|
|
*
|
|
|
|
* @param text the text to put in the users clipboard
|
|
|
|
*/
|
|
|
|
function copy(text)
|
|
|
|
{
|
|
|
|
var copyElement = document.createElement('input');
|
|
|
|
copyElement.setAttribute('type', 'text');
|
|
|
|
copyElement.setAttribute('value', text);
|
|
|
|
copyElement = document.body.appendChild(copyElement);
|
|
|
|
copyElement.select();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
document.execCommand('copy');
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
console.log("document.execCommand('copy'); is not supported by this browser.");
|
|
|
|
prompt('Copy the value below. (CTRL + C, ENTER)', text);
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
copyElement.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function alertElement(html, element, millis)
|
|
|
|
{
|
|
|
|
var original = element.innerHTML;
|
|
|
|
element.innerHTML = html;
|
|
|
|
setTimeout(function() { element.innerHTML = original; }, millis);
|
2015-12-09 21:05:24 +01:00
|
|
|
}
|