From 434af64850f374ff1fd818f090d4761e04fc9887 Mon Sep 17 00:00:00 2001 From: Kylart Date: Sun, 5 Mar 2017 20:26:18 +0100 Subject: [PATCH] Added changeDir and refreshDir buttons to local Page. Removed useless functions from main.js --- main.js | 28 ---------------------------- src/localPage/functions.js | 15 ++++++++++++--- src/localPage/index.js | 26 +++++++++++++++++++++++++- src/style.css | 5 +++++ 4 files changed, 42 insertions(+), 32 deletions(-) diff --git a/main.js b/main.js index 3189713..f3d0902 100644 --- a/main.js +++ b/main.js @@ -90,34 +90,6 @@ exports.openDownloader = () => { }) } -exports.getInfoPage = () => { - mainWindow.loadURL(url.format({ - pathname: path.join(__dirname, 'app', 'InformationPage', 'index.html'), - protocol: 'file:', - slashes: true - })) -} - -exports.getMainPage = () => { - mainWindow.loadURL(url.format({ - pathname: path.join(__dirname, 'index.html'), - protocol: 'file:', - slashes: true - })) -} - -exports.openTorrents = () => { - const TORRENT_PATH = path.join(BASE_PATH, '.KawAnime') - - const tmpFiles = fs.readdirSync(TORRENT_PATH) - - tmpFiles.forEach( (elem) => { - if (elem.split('.').pop() === 'torrent') - shell.openItem(path.join(TORRENT_PATH, elem)) - }) -} - - // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. diff --git a/src/localPage/functions.js b/src/localPage/functions.js index d30b1a2..2307c3f 100644 --- a/src/localPage/functions.js +++ b/src/localPage/functions.js @@ -15,10 +15,11 @@ const fs = require('fs') const path = require('path') const os = require('os') const shell = require('electron').shell +const {dialog} = require('electron').remote const mal = require('malapi').Anime -const DIR = path.join(os.userInfo().homedir, downloadRep) +exports.DIR = path.join(os.userInfo().homedir, downloadRep) exports.filterFiles = (files, filters) => { let filteredFiles = [] @@ -77,8 +78,8 @@ exports.searchAnime = (filename, object) => { }) } -exports.findFiles = (object) => { - const allFiles = fs.readdirSync(DIR) +exports.findFiles = (object, dir) => { + const allFiles = fs.readdirSync(dir) const filteredFiles = self.filterFiles(allFiles, ['.mkv', '.mp4']) @@ -103,4 +104,12 @@ exports.delFile = (object, name) => { }) } +exports.changePathDiaog = (object) => { + dialog.showOpenDialog({properties: ['openDirectory']}, (dirPath) => { + object.files = [] + object.currentDir = dirPath[0] + self.findFiles(object, dirPath[0]) + }) +} + // TODO: make an initial findFiles method \ No newline at end of file diff --git a/src/localPage/index.js b/src/localPage/index.js index 8bc8b88..321fd63 100644 --- a/src/localPage/index.js +++ b/src/localPage/index.js @@ -11,6 +11,16 @@ const functions = require('./functions.js') const html = `
+
+ + + + Change Dir + +