From 06281fccacf506db9b907fb0b00e7b1688877c1f Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Fri, 11 Mar 2016 12:29:39 -0700 Subject: [PATCH] Catch export error if dictionary has no words. --- js/dictionaryBuilder.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/dictionaryBuilder.js b/js/dictionaryBuilder.js index 7800342..7ae568b 100644 --- a/js/dictionaryBuilder.js +++ b/js/dictionaryBuilder.js @@ -574,11 +574,15 @@ function SavePreviousDictionary () { } function ExportDictionary() { - var downloadName = removeDiacritics(stripHtmlEntities(currentDictionary.name)).replace(/\W/g, ''); - if (downloadName == "") { - downloadName = "export"; + if (currentDictionary.words.length > 0) { + var downloadName = removeDiacritics(stripHtmlEntities(currentDictionary.name)).replace(/\W/g, ''); + if (downloadName == "") { + downloadName = "export"; + } + download(downloadName + ".dict", localStorage.getItem('dictionary')); + } else { + alert("Dictionary must have at least 1 word to export.") } - download(downloadName + ".dict", localStorage.getItem('dictionary')); } function ImportDictionary() {