aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-02-02 07:31:38 +0100
committerache <ache@ache.one>2018-02-02 07:31:38 +0100
commit1677cb245356a762649185ee48e3befaba16c512 (patch)
tree59b4c17de670664fc4603067bdb4748ed8eee1bb
parentRemoving unnecessary libraries (diff)
XO fix
-rw-r--r--app.js46
-rw-r--r--package.json14
-rw-r--r--public/js/qcm.js11
-rw-r--r--public/js/script.js23
4 files changed, 50 insertions, 44 deletions
diff --git a/app.js b/app.js
index 5d19e75..eb95838 100644
--- a/app.js
+++ b/app.js
@@ -8,7 +8,7 @@ const path = 'md';
const app = express();
process.on('uncaughtException', err => {
- console.error('[' + new Date() + '] > ' + 'Error - ' + err);
+ console.error('[' + new Date() + '] > Error - ' + err);
});
const report = require('vfile-reporter');
@@ -26,20 +26,16 @@ const multiChoice = require('remark-multiple-choice');
const lineInput = require('remark-line-input');
const select = require('remark-select');
const textInput = require('remark-text-input');
-
const raw = require('rehype-raw');
const rehypeKatex = require('rehype-katex');
const rehypeStringify = require('rehype-stringify');
-
const unified = require('unified');
const remark = require('remark-parse');
-const inspect = require('unist-util-inspect');
-
const useLandScript = '';
-const userSide_Button = '<button class="raw_button" ><div><div>Raw</div></div></button></form>';
+const rawButton = '<button class="raw_button" ><div><div>Raw</div></div></button></form>';
-function to_HTML(data, fnc) {
+function toHTML(data, fnc) {
unified()
.use(remark)
.use(lineInput)
@@ -64,15 +60,15 @@ app.get('/' + path + '/*', (req, res) => {
const url = decodeURI(req._parsedUrl.pathname);
const query = req.query;
- console.log('[' + new Date() + '] > ' + '200 - ' + url);
- if (query && query.raw == 'true') {
+ console.log('[' + new Date() + '] > ' + 200 + ' - ' + url);
+ if (query && query.raw === 'true') {
res.sendFile(url, {root: '.',
dotfiles: 'deny',
headers: {
'x-timestamp': Date.now(),
'x-sent': true}}, err => {
if (err) {
- next(err);
+ console.log('Error : ', err);
} else {
console.log('Sent : ', url);
}
@@ -96,27 +92,27 @@ app.get('/' + path + '/*', (req, res) => {
console.log(inspect(a));
*/
- to_HTML(data, (err, file) => {
+ toHTML(data, (err, file) => {
res.send(String(file) + useLandScript +
- '<a href="' + url + '?raw=true" class="no-style">' + userSide_Button + '</a>');
+ '<a href="' + url + '?raw=true" class="no-style">' + rawButton + '</a>');
console.error(report(err || file));
});
});
});
app.get('/data', (req, res) => {
- console.log('[' + new Date() + '] > ' + '200 - ' + req.url);
+ console.log('[' + new Date() + '] > ' + 200 + ' - ' + req.url);
res.send(dirTree(path, {extensions: /\.md/}));
});
app.get('/img/*', (req, res) => {
- console.log('[' + new Date() + '] > ' + '200 - ' + req.url);
- if (path == '/img/ic_info_black_48px.svg' ||
- path == '/imr/ic_error_black_48px.svg' ||
- path == '/imr/ic_good_black_48px.svg' ||
- path == '/imr/ic_bad_black_48px.svg' ||
- path == '/imr/ic_comment_black_48px.svg' ||
- path == '/imr/ic_help_black_48px.svg') {
+ console.log('[' + new Date() + '] > ' + 200 + ' - ' + req.url);
+ if (path === '/img/ic_info_black_48px.svg' ||
+ path === '/imr/ic_error_black_48px.svg' ||
+ path === '/imr/ic_good_black_48px.svg' ||
+ path === '/imr/ic_bad_black_48px.svg' ||
+ path === '/imr/ic_comment_black_48px.svg' ||
+ path === '/imr/ic_help_black_48px.svg') {
const img = fs.readFileSync(path);
res.writeHead(200, {'Content-Type': 'image/svg'});
res.end(img, 'binary');
@@ -128,7 +124,7 @@ app.get('/img/*', (req, res) => {
});
app.get('/', (req, res) => {
- console.log('[' + new Date() + '] > ' + '200 - ' + req.url);
+ console.log('[' + new Date() + '] > ' + 200 + ' - ' + req.url);
fs.readFile('public/index.html', 'utf8', (err, data) => {
if (err) {
return console.log(err);
@@ -138,13 +134,13 @@ app.get('/', (req, res) => {
});
app.get('*', (req, res) => {
- console.error('[' + new Date() + '] > ' + '404 - ' + req.url);
+ console.error('[' + new Date() + '] > ' + 404 + ' - ' + req.url);
fs.readFile('public/404.md', 'utf8', (err, data) => {
if (err) {
return console.log(err);
}
fs.readFile('public/css/style.css', 'utf8', (err, style) => {
- to_HTML(data, (err, file) => {
+ toHTML(data, (err, file) => {
let html = '<html>';
html += '<head>';
html += '<style>' + style + '</style>';
@@ -159,8 +155,8 @@ app.get('*', (req, res) => {
});
});
-var server = app.listen(8090, () => {
+const server = app.listen(8090, () => {
const host = server.address().address;
const port = server.address().port;
- console.log('[' + new Date() + '] > ' + 'App listening at http://%s:%s', host, port);
+ console.log('[' + new Date() + '] > App listening at http://%s:%s', host, port);
});
diff --git a/package.json b/package.json
index 8ea88d2..675e828 100644
--- a/package.json
+++ b/package.json
@@ -20,15 +20,23 @@
"remark-line-input": "git+http://git.ache.one/remark-line-input/",
"remark-math": "^1.0.0",
"remark-mermaid-simple": "git+http://git.ache.one/remark-mermaid-simple/",
- "remark-preset-lint-markdown-style-guide": "^2.1.1",
"remark-multiple-choice": "git+http://git.ache.one/remark-multiple-choice",
+ "remark-parse": "^5.0.0",
+ "remark-preset-lint-markdown-style-guide": "^2.1.1",
"remark-rehype": "^3.0.0",
- "remark-special-box": "git+http://git.ache.one/remark-special-box/",
"remark-select": "git+http://git.ache.one/remark-select/",
+ "remark-special-box": "git+http://git.ache.one/remark-special-box/",
"remark-text-input": "git+http://git.ache.one/remark-text-input/",
+ "unified": "^6.1.6",
"unist-util-inspect": "^4.1.2",
"vfile-reporter": "^4.0.0"
},
"author": "Titely",
- "license": ""
+ "license": "",
+ "devDependencies": {
+ "xo": "^0.18.2"
+ },
+ "xo": {
+ "space": true
+ }
}
diff --git a/public/js/qcm.js b/public/js/qcm.js
index e6b8190..3ce5724 100644
--- a/public/js/qcm.js
+++ b/public/js/qcm.js
@@ -1,14 +1,14 @@
'use strict';
+/* eslint-env browser */
+/* exported check */
+
/*
* Écrit par Hédy GIRAUDEAU
*
*/
-/* eslint-env browser */
-/* exported check */
-
-function check(id/* , tab */) {
+const check = (id => {
const fieldQCM = document.getElementById(id);
Array.from(fieldQCM.getElementsByTagName('INPUT')).forEach(input => {
@@ -36,7 +36,7 @@ function check(id/* , tab */) {
// Empty
}
});
-}
+});
function shuffle(array) {
let currentIndex = array.length;
@@ -76,3 +76,4 @@ document.addEventListener('DOMContentLoaded', () => {
});
}, false);
+document.check = check;
diff --git a/public/js/script.js b/public/js/script.js
index 5fd9b07..e90198c 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -1,37 +1,38 @@
'use strict';
+/* global document XMLHttpRequest */
+
document.addEventListener('DOMContentLoaded', () => {
const httpRequest = new XMLHttpRequest();
-
+
httpRequest.onreadystatechange = () => {
- if( httpRequest.readyState ===4 && httpRequest.status === 200) {
+ if (httpRequest.readyState === 4 && httpRequest.status === 200) {
const response = httpRequest.responseText;
const data = JSON.parse(response);
document.getElementById('tree').appendChild(addDirectory(data));
- Array.from(document.getElementsByTagName('a')).forEach( (a) => {
+ Array.from(document.getElementsByTagName('a')).forEach(a => {
a.onclick = (function (e) {
e.preventDefault();
e.stopPropagation();
const setMd = new XMLHttpRequest();
setMd.onreadystatechange = () => {
- if( setMd.readyState ===4 && setMd.status === 200) {
- document.getElementById('md');
- md.innerHTML = setMd.responseText;
+ if (setMd.readyState === 4 && setMd.status === 200) {
+ document.getElementById('md').innerHTML = setMd.responseText;
}
- }
+ };
setMd.open('GET', a.href);
setMd.send();
});
});
- Array.from(document.getElementsByClassName("directory")).forEach( (dir) => {
- dir.querySelectorAll('ul').forEach( (ul) => {
+ Array.from(document.getElementsByClassName('directory')).forEach(dir => {
+ dir.querySelectorAll('ul').forEach(ul => {
ul.style.display = 'none';
});
- dir.onclick = ( (e) => {
+ dir.onclick = (e => {
e.stopPropagation();
- dir.querySelectorAll('ul').forEach( (ul) => {
+ dir.querySelectorAll('ul').forEach(ul => {
ul.style.display = ul.style.display === 'none' ? 'block' : 'none';
});
});