From 6053e302eea9c666b89232052b401600b7f2aece Mon Sep 17 00:00:00 2001
From: symant233 <symant233@gmail.com>
Date: Sun, 5 May 2019 22:02:24 +0800
Subject: [PATCH] fix output_dir make gen-main error

---
 nhentai/utils.py          | 6 +++++-
 nhentai/viewer/scripts.js | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/nhentai/utils.py b/nhentai/utils.py
index 00e6b00..98a239a 100644
--- a/nhentai/utils.py
+++ b/nhentai/utils.py
@@ -100,7 +100,11 @@ def generate_main_html(output_dir='.'):
                 </div>\n\
             </div>\n'
     
-    os.chdir(output_dir) # switch to given dir
+    if output_dir == '':
+        os.chdir('.')
+    else:
+        os.chdir(output_dir) 
+    # switch to given dir
     doujinshi_dirs = next(os.walk('.'))[1] 
     # https://stackoverflow.com/questions/141291/how-to-list-only-top-level-directories-in-python
 
diff --git a/nhentai/viewer/scripts.js b/nhentai/viewer/scripts.js
index cb49af5..8e3f8bf 100644
--- a/nhentai/viewer/scripts.js
+++ b/nhentai/viewer/scripts.js
@@ -50,6 +50,7 @@ document.onkeypress = event => {
         case 'a':
             changePage(currentPage - 1);
             break;
+        // Return to previous page
         case 'q':
             window.history.go(-1);
             break;