Commit a02defc8 authored by Robert Knight's avatar Robert Knight

Enable Prettier for code other than PDF.js in dev-server/static/scripts/

We only want to exclude the vendored PDF.js code from Prettier formatting. The
other small scripts in dev-server/static/scripts/ should be formatted.
parent 5f239b1f
**/vendor/*
.*/** .*/**
build/ build/
coverage/ coverage/
docs/ docs/
dev-server/static/* dev-server/static/scripts/pdfjs/*
lib/
/** /**
* Because the code in this file is not transpiled by Babel, it must be compatible * Because the code in this file is not transpiled by Babel, it must be compatible
* with all the supported browsers version (see `browserlist` in `package.json`) * with all the supported browsers version (see `browserlist` in `package.json`)
* without transpilation. Do not include latest EcmaScript features as these * without transpilation. Do not include latest EcmaScript features as these
* will cause exceptions while working on dev (`localhost:3000`) on slightly * will cause exceptions while working on dev (`localhost:3000`) on slightly
* older, yet supported browser versions. * older, yet supported browser versions.
*/ */
// Code for controls on the dev server homepage. // Code for controls on the dev server homepage.
...@@ -24,11 +24,18 @@ ...@@ -24,11 +24,18 @@
}; };
// Set up links whose URLs should have a randomly generated suffix. // Set up links whose URLs should have a randomly generated suffix.
const randomizedLinks = Array.from(document.querySelectorAll('.js-randomize-url')); const randomizedLinks = Array.from(
document.querySelectorAll('.js-randomize-url')
);
for (let link of randomizedLinks) { for (let link of randomizedLinks) {
const randomizeUrl = () => { const randomizeUrl = () => {
const randomHexString = Math.random().toString().slice(2 /* strip "0." prefix */, 6); const randomHexString = Math.random()
link.href = link.href.replace(/(\/rand-.*)?$/, `/rand-${randomHexString}`); .toString()
.slice(2 /* strip "0." prefix */, 6);
link.href = link.href.replace(
/(\/rand-.*)?$/,
`/rand-${randomHexString}`
);
}; };
randomizeUrl(); randomizeUrl();
link.addEventListener('click', randomizeUrl); link.addEventListener('click', randomizeUrl);
......
/** /**
* Because the code in this file is not transpiled by Babel, it must be compatible * Because the code in this file is not transpiled by Babel, it must be compatible
* with all the supported browsers version (see `browserlist` in `package.json`) * with all the supported browsers version (see `browserlist` in `package.json`)
* without transpilation. Do not include latest EcmaScript features as these * without transpilation. Do not include latest EcmaScript features as these
* will cause exceptions while working on dev (`localhost:3000`) on slightly * will cause exceptions while working on dev (`localhost:3000`) on slightly
* older, yet supported browser versions. * older, yet supported browser versions.
*/ */
/** @type {string|null} */ /** @type {string|null} */
let activeClientUrl; let activeClientUrl;
...@@ -27,7 +27,9 @@ function loadClient(clientUrl) { ...@@ -27,7 +27,9 @@ function loadClient(clientUrl) {
* This uses the same method as the browser extension does to deactivate the client. * This uses the same method as the browser extension does to deactivate the client.
*/ */
function unloadClient() { function unloadClient() {
let annotatorLink = document.querySelector('link[type="application/annotator+html"]'); let annotatorLink = document.querySelector(
'link[type="application/annotator+html"]'
);
if (annotatorLink) { if (annotatorLink) {
annotatorLink.dispatchEvent(new Event('destroy')); annotatorLink.dispatchEvent(new Event('destroy'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment