viewers/plain/pcf.html
<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
body {
overflow: hidden;
}
textarea {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
resize: none;
font-size: 14px;
font-family: Courier New, Courier, Lucida Sans Typewriter,
Lucida Typewriter, monospace;
box-sizing: border-box;
}
</style>
</head>
<body>
<div>
<b>Sorry, PCF file does not exist</b>
</div>
<textarea id="pcf" readonly="true"></textarea>
<script>
'use strict';
function getURLParameter(name) {
return (
decodeURIComponent(
(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(
location.search
) || [null, ''])[1].replace(/\+/g, '%20')
) || null
);
}
window.onload = function () {
const nodeFs = require('fs');
const path = `resources/boards/${getURLParameter('board')}/pinout`;
let ext = 'pcf';
if (!nodeFs.existsSync(`${path}.pcf`)) {
if (!nodeFs.existsSync(`${path}.lpf`)) {
console.error('Pinout file not found!');
return;
}
ext = 'lpf';
}
const text = nodeFs.readFileSync(`${path}.${ext}`);
const node = document.getElementById('pcf');
if (text) {
node.value = text;
} else {
node.style.visibility = 'hidden';
}
};
</script>
</body>
</html>