Commit a04ec861 authored by Mihkel Putrinš's avatar Mihkel Putrinš

refactor

parent 9ba26304
...@@ -29,25 +29,25 @@ app.on('ready', function() { ...@@ -29,25 +29,25 @@ app.on('ready', function() {
var web_preferences = { var web_preferences = {
'partition': 'persist:panustaja (build ' + (pjson.build) + ')', 'partition': 'persist:panustaja (build ' + (pjson.build) + ')',
} }
windows['authWindow'] = new BrowserWindow({ width: 900, height: 600, show: true, 'web-preferences': web_preferences }) windows.authWindow = new BrowserWindow({ width: 900, height: 600, show: true, 'web-preferences': web_preferences })
// windows['authWindow'].webContents.openDevTools(true) // windows.authWindow.webContents.openDevTools(true)
var title = pjson.name + ' v.' + pjson.version + (pjson.version.indexOf('-') > -1 ? pjson.build : '') + ' | Logi sisse' var title = pjson.name + ' v.' + pjson.version + (pjson.version.indexOf('-') > -1 ? pjson.build : '') + ' | Logi sisse'
windows['authWindow'].center() windows.authWindow.center()
windows['authWindow'].setTitle(title) windows.authWindow.setTitle(title)
windows['authWindow'].loadUrl(auth_url) windows.authWindow.loadUrl(auth_url)
windows['authWindow'].webContents.on('did-get-response-details', function(e, s, new_url) { windows.authWindow.webContents.on('did-get-response-details', function(e, s, new_url) {
windows['authWindow'].setTitle(title) windows.authWindow.setTitle(title)
if (new_url === user_url || new_url === user_url + '#') { if (new_url === user_url || new_url === user_url + '#') {
windows['authWindow'].hide() windows.authWindow.hide()
} }
}) })
windows['authWindow'].webContents.on('did-finish-load', function() { windows.authWindow.webContents.on('did-finish-load', function() {
windows['authWindow'].setTitle(title) windows.authWindow.setTitle(title)
var new_url = windows['authWindow'].webContents.getUrl() var new_url = windows.authWindow.webContents.getUrl()
if (new_url === user_url || new_url === user_url + '#') { if (new_url === user_url || new_url === user_url + '#') {
clipboard.clear() clipboard.clear()
windows['authWindow'].webContents.selectAll() windows.authWindow.webContents.selectAll()
windows['authWindow'].webContents.copy() windows.authWindow.webContents.copy()
var web_preferences = { var web_preferences = {
'partition': 'persist:panustaja (build ' + (pjson.build) + ')', 'partition': 'persist:panustaja (build ' + (pjson.build) + ')',
...@@ -62,8 +62,8 @@ app.on('ready', function() { ...@@ -62,8 +62,8 @@ app.on('ready', function() {
mainWindow.webContents.openDevTools(true) mainWindow.webContents.openDevTools(true)
if (IS_DEV) { if (IS_DEV) {
} }
windows['authWindow'].close() windows.authWindow.close()
delete windows['authWindow'] delete windows.authWindow
}, 1000) }, 1000)
} else { } else {
return return
......
function bytesToSize(bytes) { function bytesToSize(bytes) {
if (bytes === undefined) bytes = 0 if (bytes === undefined) { bytes = 0 }
var sizes = ['B', 'KB', 'MB', 'GB', 'TB'] var sizes = ['B', 'KB', 'MB', 'GB', 'TB']
if (bytes === 0) return '0 B' if (bytes === 0) { return '0 B' }
try { try {
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10) var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10)
var decimals = Math.max(0, i-1) var decimals = Math.max(0, i-1)
......
...@@ -133,7 +133,6 @@ function recurseLocal(parent_resource, paths, loadedCB) { ...@@ -133,7 +133,6 @@ function recurseLocal(parent_resource, paths, loadedCB) {
resource_stats.files.count++ resource_stats.files.count++
resource_stats.files.size += stats.size resource_stats.files.size += stats.size
op.push(parent_resource, 'files', _path) op.push(parent_resource, 'files', _path)
var charset = ''
op.set(resource_stats, ['mime', mimetype, 'count'], op.get(resource_stats, ['mime', mimetype, 'count'], 0) + 1) op.set(resource_stats, ['mime', mimetype, 'count'], op.get(resource_stats, ['mime', mimetype, 'count'], 0) + 1)
op.set(resource_stats, ['mime', mimetype, 'size'], op.get(resource_stats, ['mime', mimetype, 'size'], 0) + stats.size) op.set(resource_stats, ['mime', mimetype, 'size'], op.get(resource_stats, ['mime', mimetype, 'size'], 0) + stats.size)
callback() callback()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment