From 1677cb245356a762649185ee48e3befaba16c512 Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 2 Feb 2018 07:31:38 +0100 Subject: XO fix --- public/js/qcm.js | 11 ++++++----- public/js/script.js | 23 ++++++++++++----------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'public') 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'; }); }); -- cgit v1.2.3