'use strict';
-module.exports = (ctx, pageTitle) => {
+module.exports = (ctx, pageTitle, logoUrl) => {
+ const logoImg = logoUrl ? `<img src="${logoUrl}" class="logo">` : '';
return `<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="static/theme.css">
</head>
<body>
- <script type="text/javascript">
+ <script type="text/javascript">` + (!ctx.createdLink ? '0;' : `
document.addEventListener('DOMContentLoaded', function () {
- document.querySelector('.copy-button').addEventListener('click', function(event) {
+ let timeout;
+ document.querySelector('.copy-button').addEventListener('click', function (event) {
const linkHref = document.querySelector('.link').href;
navigator.clipboard.writeText(linkHref);
const copyButton = this;
copyButton.style.backgroundColor = 'lightgreen';
- setTimeout(function () {
+ if (timeout) {
+ clearTimeout(timeout);
+ }
+ timeout = setTimeout(function () {
copyButton.style.backgroundColor = 'initial';
+ timeout = undefined;
}, 3000);
});
- });
- </script>
+ });`) + `
+ </script>
<header>
- <h1>${pageTitle}</h1>
+ <h1>${logoImg}${pageTitle}</h1>
</header>` +
(!ctx.createdLink ? '' : `
<section class="created-link">