From e885e82acd47d3fa4f126731d6437ed4bdba9039 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 1 Jun 2019 21:10:29 +0200 Subject: [PATCH] Fix ISBN script --- manuels/static/manuels/fetch-isbn.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/manuels/static/manuels/fetch-isbn.js b/manuels/static/manuels/fetch-isbn.js index 0543843..602b28d 100644 --- a/manuels/static/manuels/fetch-isbn.js +++ b/manuels/static/manuels/fetch-isbn.js @@ -63,14 +63,16 @@ document.addEventListener("DOMContentLoaded", function (event) { var editorValue = ""; var editorIsOther = false; - for (var option of document.querySelector('#id_editor').children) { - if (editorValue === "" && option.firstChild.data.toLowerCase().indexOf('autre') !== -1) { - editorValue = option.value; - editorIsOther = true; - } - if (option.firstChild.data.toLowerCase() === data.editor.toLowerCase()) { - editorValue = option.value; - editorIsOther = false; + if (data.editor) { + for (var option of document.querySelector('#id_editor').children) { + if (editorValue === "" && option.firstChild.data.toLowerCase().indexOf('autre') !== -1) { + editorValue = option.value; + editorIsOther = true; + } + if (option.firstChild.data.toLowerCase() === data.editor.toLowerCase()) { + editorValue = option.value; + editorIsOther = false; + } } } editor.value = editorValue;