From 0e4b79b0bd1ee0eb2e88ff96e185f0a139e9de10 Mon Sep 17 00:00:00 2001 From: dgmid Date: Fri, 29 May 2020 06:52:42 +0200 Subject: [PATCH] generate favicon on add bookmark --- app-source/js/favicons.js | 21 ++++++++++++++------- app-source/js/fetch.js | 3 ++- app-source/js/main.js | 8 +++++++- app-source/js/modal-add-bookmark.js | 5 ++++- dist/js/favicons.min.js | 21 ++++++++++++++------- dist/js/fetch.min.js | 3 ++- dist/js/main.min.js | 8 +++++++- dist/js/maps/favicons.min.js.map | 2 +- dist/js/maps/fetch.min.js.map | 2 +- dist/js/maps/main.min.js.map | 2 +- dist/js/maps/modal-add-bookmark.min.js.map | 2 +- dist/js/modal-add-bookmark.min.js | 5 ++++- 12 files changed, 58 insertions(+), 24 deletions(-) diff --git a/app-source/js/favicons.js b/app-source/js/favicons.js index 8a4d16a..6ee92f3 100644 --- a/app-source/js/favicons.js +++ b/app-source/js/favicons.js @@ -33,7 +33,7 @@ module.exports.regenerate = function ( winId ) { if ( err ) return console.error( err ) log.info( `deleted cached favicons` ) - module.exports.generate( winId, true ) + module.exports.generate( winId, false, true ) }) } @@ -51,7 +51,7 @@ function notify( title, body ) { -module.exports.generate = function ( winId, notify ) { +module.exports.generate = function ( winId, singleBookmark, notify ) { let win = BrowserWindow.fromId( winId ), bookmarks = new Store( {name: 'bookmarks'} ), @@ -60,13 +60,20 @@ module.exports.generate = function ( winId, notify ) { faviconCount = 0, faviconArray = [] - for( let bookmark of bookmarkData ) { + if( singleBookmark ) { - if( !defaultArray.includes( bookmark.id ) && - !fs.pathExistsSync( `${dir}/favicons/${bookmark.id}.png` - ) ) { + faviconArray.push( singleBookmark ) + + } else { + + for( let bookmark of bookmarkData ) { - faviconArray.push( bookmark ) + if( !defaultArray.includes( bookmark.id ) && + !fs.pathExistsSync( `${dir}/favicons/${bookmark.id}.png` + ) ) { + + faviconArray.push( bookmark ) + } } } diff --git a/app-source/js/fetch.js b/app-source/js/fetch.js index 07dd13f..ba63a9f 100644 --- a/app-source/js/fetch.js +++ b/app-source/js/fetch.js @@ -160,10 +160,11 @@ module.exports.bookmarksApi = function( call, id, data, callback ) { break + //todo - not needed case 'single': callback( message ) break - default: callback() + default: callback( message ) } }).catch(function( error ) { diff --git a/app-source/js/main.js b/app-source/js/main.js index 78b65b5..fa28e4d 100644 --- a/app-source/js/main.js +++ b/app-source/js/main.js @@ -104,7 +104,7 @@ function createWindow() { win.once('ready-to-show', () => { win.show() - favicons.generate( win.id, false ) + favicons.generate( win.id, false, false ) }) win.on('resize', saveWindowBounds) @@ -247,6 +247,12 @@ ipcMain.on('refresh', (event, message) => { +ipcMain.on('update-favicon', (event, message) => { + + favicons.generate( win.id, message, false ) +}) + + ipcMain.on('loginflow', (event, message) => { loginFlow = new BrowserWindow({ diff --git a/app-source/js/modal-add-bookmark.js b/app-source/js/modal-add-bookmark.js index 9b6e86c..c2a7a2f 100644 --- a/app-source/js/modal-add-bookmark.js +++ b/app-source/js/modal-add-bookmark.js @@ -148,7 +148,10 @@ $(document).ready(function() { data += '&folders[]=' + encodeURIComponent(folder['id']) } - fetch.bookmarksApi( 'add', '', data, function() { + fetch.bookmarksApi( 'add', '', data, function( message ) { + + let returnedBookmark = JSON.parse( message ) + ipc.send('update-favicon', returnedBookmark['item'] ) ipc.send('refresh', 'refresh') closeModal() diff --git a/dist/js/favicons.min.js b/dist/js/favicons.min.js index aed118e..8a24ef7 100644 --- a/dist/js/favicons.min.js +++ b/dist/js/favicons.min.js @@ -33,7 +33,7 @@ module.exports.regenerate = function ( winId ) { if ( err ) return console.error( err ) log.info( `deleted cached favicons` ) - module.exports.generate( winId, true ) + module.exports.generate( winId, false, true ) }) } @@ -51,7 +51,7 @@ function notify( title, body ) { -module.exports.generate = function ( winId, notify ) { +module.exports.generate = function ( winId, singleBookmark, notify ) { let win = BrowserWindow.fromId( winId ), bookmarks = new Store( {name: 'bookmarks'} ), @@ -60,13 +60,20 @@ module.exports.generate = function ( winId, notify ) { faviconCount = 0, faviconArray = [] - for( let bookmark of bookmarkData ) { + if( singleBookmark ) { - if( !defaultArray.includes( bookmark.id ) && - !fs.pathExistsSync( `${dir}/favicons/${bookmark.id}.png` - ) ) { + faviconArray.push( singleBookmark ) + + } else { + + for( let bookmark of bookmarkData ) { - faviconArray.push( bookmark ) + if( !defaultArray.includes( bookmark.id ) && + !fs.pathExistsSync( `${dir}/favicons/${bookmark.id}.png` + ) ) { + + faviconArray.push( bookmark ) + } } } diff --git a/dist/js/fetch.min.js b/dist/js/fetch.min.js index 3c2a79d..335a4fc 100644 --- a/dist/js/fetch.min.js +++ b/dist/js/fetch.min.js @@ -160,10 +160,11 @@ module.exports.bookmarksApi = function( call, id, data, callback ) { break + //todo - not needed case 'single': callback( message ) break - default: callback() + default: callback( message ) } }).catch(function( error ) { diff --git a/dist/js/main.min.js b/dist/js/main.min.js index 7b6f8ab..7a673cb 100644 --- a/dist/js/main.min.js +++ b/dist/js/main.min.js @@ -104,7 +104,7 @@ function createWindow() { win.once('ready-to-show', () => { win.show() - favicons.generate( win.id, false ) + favicons.generate( win.id, false, false ) }) win.on('resize', saveWindowBounds) @@ -247,6 +247,12 @@ ipcMain.on('refresh', (event, message) => { +ipcMain.on('update-favicon', (event, message) => { + + favicons.generate( win.id, message, false ) +}) + + ipcMain.on('loginflow', (event, message) => { loginFlow = new BrowserWindow({ diff --git a/dist/js/maps/favicons.min.js.map b/dist/js/maps/favicons.min.js.map index 749d9a9..3d84ecd 100644 --- a/dist/js/maps/favicons.min.js.map +++ b/dist/js/maps/favicons.min.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["favicons.js"],"sourcesContent":["'use strict'\n\nconst {\n\tapp,\n\tBrowserWindow,\n\tNotification\n\n} = require( 'electron' )\n\nconst path \t\t\t= require( 'path' )\nconst fs \t\t\t= require( 'fs-extra' )\nconst nativeImage \t= require( 'electron' ).nativeImage\nconst axios \t\t= require( 'axios' ).default\nconst Store\t\t\t= require( 'electron-store' )\nconst store \t\t= new Store()\nconst log \t\t\t= require( 'electron-log' )\n\nconst dir \t\t\t= store.get( 'dirPath' )\n\n\n\nmodule.exports.regenerate = function ( winId ) {\n\t\n\tconst i18n = require( './i18n.min' )\n\t\n\tlog.info( `regenerating favicons` )\n\t\n\tnotify( app.name, i18n.t('favicons:regenerating', 'Regenerating all favicons') )\n\tstore.set( 'defaultIcons', [] )\n\t\n\tfs.remove( `${dir}/favicons/`, err => {\n\t\t\n\t\tif ( err ) return console.error( err )\n\t\t\n\t\tlog.info( `deleted cached favicons` )\n\t\tmodule.exports.generate( winId, true )\n\t})\n}\n\n\n\nfunction notify( title, body ) {\n\t\n\tconst note ={\n\t\ttitle: title,\n\t\tbody: body\n\t}\n\t\n\tnew Notification( note ).show()\n}\n\n\n\nmodule.exports.generate = function ( winId, notify ) {\n\t\n\tlet win \t\t\t= BrowserWindow.fromId( winId ),\n\t\tbookmarks \t\t= new Store( {name: 'bookmarks'} ),\n\t\tbookmarkData \t= bookmarks.get( 'data' ),\n\t\tdefaultArray\t= store.get( 'defaultIcons' ),\n\t\tfaviconCount \t= 0,\n\t\tfaviconArray\t= []\n\t\n\tfor( let bookmark of bookmarkData ) {\n\t\t\n\t\tif( !defaultArray.includes( bookmark.id ) &&\n\t\t\t!fs.pathExistsSync( `${dir}/favicons/${bookmark.id}.png`\n\t\t) ) {\n\t\t\t\n\t\t\tfaviconArray.push( bookmark )\n\t\t}\n\t}\n\t\n\tlet arrayLength = faviconArray.length\n\t\n\tif( arrayLength < 1 ) {\n\t\t\n\t\tlog.info( `No favicons to generate` )\n\t\tlog.info( `Default favicons are: ${defaultArray}` )\n\t\twin.webContents.send( 'load-tray-menu' )\n\t}\n\t\n\tfor( let i = 0; i < arrayLength; i++ ) {\n\t\t\n\t\tlet bookmarkUrl = new URL( faviconArray[i].url ),\n\t\t\tdomain \t\t= bookmarkUrl.hostname,\n\t\t\ticonurl \t= `https://api.faviconkit.com/${domain}/32`,\n\t\t\tfile \t\t= `${dir}/favicons/${faviconArray[i].id}.png`,\n\t\t\tfile2x\t\t= `${dir}/favicons/${faviconArray[i].id}@2x.png`\n\t\t\n\t\taxios.get(iconurl, { responseType: 'arraybuffer' })\n\t\t.then( function( response ) {\n\t\t\t\n\t\t\tconst buffer = Buffer.from(response.data, \"utf-8\")\n\t\t\t\n\t\t\tif(\n\t\t\t\tresponse.headers['content-type'].includes('png') ||\n\t\t\t\tresponse.headers['content-type'].includes('jpeg') ||\n\t\t\t\tresponse.headers['content-type'].includes('x-icon')\n\t\t\t) {\n\t\t\t\t\n\t\t\t\tlet imgpng = nativeImage.createFromBuffer(buffer, {\n\t\t\t\t\t\t\n\t\t\t\t\t\tscaleFactor: 1.0\n\t\t\t\t\t}).resize({\n\t\t\t\t\t\twidth: 16,\n\t\t\t\t\t\theight: 16,\n\t\t\t\t\t\tquality: 'best'\n\t\t\t\t\t}).toPNG()\n\t\t\t\t\n\t\t\t\tlet imgpng2x = nativeImage.createFromBuffer(buffer, {\n\t\t\t\t\t\t\n\t\t\t\t\t\tscaleFactor: 1.0\n\t\t\t\t\t}).resize({\n\t\t\t\t\t\twidth: 32,\n\t\t\t\t\t\theight: 32,\n\t\t\t\t\t\tquality: 'best'\n\t\t\t\t\t}).toPNG()\n\t\t\t\t\n\t\t\t\tfs.outputFileSync(file, imgpng, err => {\n\t\t\t\t\t\n\t\t\t\t\tif(err) log.info(err)\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\tfs.outputFileSync(file2x, imgpng2x, err => {\n\t\t\t\t\t\n\t\t\t\t\tif(err) log.info(err)\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\tlog.info( `favicon: ${faviconArray[i].id} - generated` )\n\t\t\t\t\n\t\t\t\tfaviconCount++\n\t\t\t\tif( faviconCount === arrayLength ) {\n\t\t\t\t\t\n\t\t\t\t\tgeneratedFavicons( win, faviconCount, defaultArray, notify )\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\tfaviconFallback( bookmarkData[i].id, bookmarkUrl, file, file2x, function( theDefault ) {\n\t\t\t\t\t\n\t\t\t\t\tlog.info( `favicon: ${faviconArray[i].id} - generated` )\n\t\t\t\t\t\n\t\t\t\t\tif( !defaultArray.includes( theDefault ) ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefaultArray.push( theDefault )\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfaviconCount++\n\t\t\t\t\tif( faviconCount === arrayLength ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tgeneratedFavicons( win, faviconCount, defaultArray, notify )\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\t.catch( function( err ) {\n\t\t\t\n\t\t\tlog.info( `favicon error: ${faviconArray[i].id}: ${err.message}` )\n\t\t\t\n\t\t\tfaviconFallback( bookmarkData[i].id, bookmarkUrl, file, file2x, function( theDefault ) {\n\t\t\t\t\n\t\t\t\tlog.info( `favicon: ${faviconArray[i].id} - generated` )\n\t\t\t\t\n\t\t\t\t\tif( !defaultArray.includes( theDefault ) ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefaultArray.push( theDefault )\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfaviconCount++\n\t\t\t\tif( faviconCount === arrayLength ) {\n\t\t\t\t\t\n\t\t\t\t\tgeneratedFavicons( win, faviconCount, defaultArray, notify )\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n}\n\n\n\nmodule.exports.get = function ( id ) {\n\t\n\tif( fs.pathExistsSync( `${dir}/favicons/${id}.png` ) ) {\n\t\t\n\t\treturn `${dir}/favicons/${id}.png`\n\t\t\n\t} else {\n\t\t\n\t\treturn path.join(__dirname, '../assets/png/faviconTemplate.png') \n\t}\n}\n\n\n\nmodule.exports.exists = function ( id ) {\n\t\n\treturn ( fs.pathExistsSync( `${dir}/favicons/${id}.png` ) ) ? true : false\n}\n\n\n\nfunction faviconFallback( id, url, file, file2x, callback ) {\n\t\n\tlet iconurl = 'https://www.google.com/s2/favicons?sz=32&domain_url=' + url,\n\ttheDefault = null\n\n\taxios.get(iconurl, { responseType: 'arraybuffer' })\n\t.then( function( response ) {\n\t\t\n\t\tconst buffer = Buffer.from(response.data, \"utf-8\")\n\t\t\n\t\tlet imgpng = nativeImage.createFromBuffer(buffer, {\n\t\t\t\t\n\t\t\t\tscaleFactor: 1.0\n\t\t\t}).resize({\n\t\t\t\twidth: 16,\n\t\t\t\theight: 16,\n\t\t\t\tquality: 'best'\n\t\t\t}).toPNG()\n\t\t\n\t\tlet imgpng2x = nativeImage.createFromBuffer(buffer, {\n\t\t\t\t\n\t\t\t\tscaleFactor: 1.0\n\t\t\t}).resize({\n\t\t\t\twidth: 32,\n\t\t\t\theight: 32,\n\t\t\t\tquality: 'best'\n\t\t\t}).toPNG()\n\t\t\n\t\tlet b64enc = Buffer.from(imgpng, 'binary').toString('base64')\n\t\t\n\t\tif( isNotDefaultIcon( b64enc ) ) {\n\t\t\t\n\t\t\tfs.outputFileSync(file, imgpng, err => {\n\t\t\t\t\n\t\t\t\tif (err) log.info(err)\n\t\t\t})\n\t\t\t\n\t\t\tfs.outputFileSync(file2x, imgpng2x, err => {\n\t\t\t\t\n\t\t\t\tif (err) log.info(err)\n\t\t\t})\n\t\t\n\t\t} else {\n\t\t\t\n\t\t\ttheDefault = id\n\t\t}\n\t\t\n\t\tcallback( theDefault )\n\t})\n\t.catch( function( err ) {\n\t\t\n\t\tlog.info( `fallback favicon error: ${id}: ${err.message}` )\n\t})\n}\n\n\n\nfunction generatedFavicons( win, count, defaults, notification ) {\n\t\n\tconst i18n = require( './i18n.min' )\n\t\n\tlog.info( `Generated ${count} favicons` )\n\tstore.set( 'defaultIcons', defaults )\n\tif( notification ) notify( app.name, i18n.t('favicons:regenerated', 'Favicons regenerated') )\n\t\n\tlog.info('load tray menu')\n\twin.webContents.send( 'load-tray-menu' )\n}\n\n\n\nfunction isNotDefaultIcon( b64 ) {\n\t\n\treturn ( b64 === 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACs0lEQVQ4jaWTzU8bBxDFf7V31/baXn+sP2oDduxaCZFKqiKDEDSHKKLKiRs55JCPQ070zyGHinsrxbk0kXpBqsTBKQUbqa1AUCgFk0C8trv2YrNm1y69gJWoveWdZqR5b97MaOAj8clVMD//3FO1apGZfHbCtnoLetPMt4yuD0Dxu9uhoKckuYRnxdL+elyK1guF++ZAYH7+uadt68nc9fjTdud8LpdRY6lsWLXsPpLoJJNSWV7ebhxUdE3xSy/3/qgt+cTQcaFw3xQAqlYt8sWNoadnZu/B57cSI5m0ileWGB8bpnNmkU4qZFMR9fftY/W778u+XC7Kr7snz4AjB8BMPjthtLtzTx5NjGTSKgCW3Wd143Awa0yVEUUnjx9OjrQ653Mz+ewEgAPAOu8tXBsJxaa+TA0Itt3HtvuEAjIAHbNHs2USCnhIDYVi3a69MBDQm2Z+dnZU7Zi9DzZ896vrKF4BAK9H4MZnMfYrf3Pv3k1V1808gADQMkxfPKKgeAW8ssRwIshwIjggAzgdUK2fAhCPKBiG6Rs4APDKEgBT49d4c9LEsj90cwVRdAJwcZkLV3fer9SVRDSF4hX4+naOYrnCzmVRNhUhEZW5M5Wh3uyy86eG4ne3Bw7CIbm0vLzdeL/T2GgSrd5Gq7dZ3Thg7bdjACJBN69ebTbCQbk0EBBFYfGgomvFcuV/bQO8PWnS/weK5QrH1ZbmcouLAE4AR2C6k04GAz//cpiOfqoEUskALsmBKIpol4sbG02ys6/x7dLro6Df9aK0efTD4c6PhhNg8tZj+12tsZtIKNLr1QO1tHHkcPtccrN1xolmYJx2WVnZa/y0snsY9Lte7O3VlsKSWt3aKvT+80zT49n8uWV/o+tm3jjt+i4uLlD87rYaltdlt7C4VvqrHHjvmT4a/wJLYRPRy3Z+JAAAAABJRU5ErkJggg==' ) ? false : true\n}\n"],"file":"../favicons.min.js"} \ No newline at end of file +{"version":3,"names":[],"mappings":"","sources":["favicons.js"],"sourcesContent":["'use strict'\n\nconst {\n\tapp,\n\tBrowserWindow,\n\tNotification\n\n} = require( 'electron' )\n\nconst path \t\t\t= require( 'path' )\nconst fs \t\t\t= require( 'fs-extra' )\nconst nativeImage \t= require( 'electron' ).nativeImage\nconst axios \t\t= require( 'axios' ).default\nconst Store\t\t\t= require( 'electron-store' )\nconst store \t\t= new Store()\nconst log \t\t\t= require( 'electron-log' )\n\nconst dir \t\t\t= store.get( 'dirPath' )\n\n\n\nmodule.exports.regenerate = function ( winId ) {\n\t\n\tconst i18n = require( './i18n.min' )\n\t\n\tlog.info( `regenerating favicons` )\n\t\n\tnotify( app.name, i18n.t('favicons:regenerating', 'Regenerating all favicons') )\n\tstore.set( 'defaultIcons', [] )\n\t\n\tfs.remove( `${dir}/favicons/`, err => {\n\t\t\n\t\tif ( err ) return console.error( err )\n\t\t\n\t\tlog.info( `deleted cached favicons` )\n\t\tmodule.exports.generate( winId, false, true )\n\t})\n}\n\n\n\nfunction notify( title, body ) {\n\t\n\tconst note ={\n\t\ttitle: title,\n\t\tbody: body\n\t}\n\t\n\tnew Notification( note ).show()\n}\n\n\n\nmodule.exports.generate = function ( winId, singleBookmark, notify ) {\n\t\n\tlet win \t\t\t= BrowserWindow.fromId( winId ),\n\t\tbookmarks \t\t= new Store( {name: 'bookmarks'} ),\n\t\tbookmarkData \t= bookmarks.get( 'data' ),\n\t\tdefaultArray\t= store.get( 'defaultIcons' ),\n\t\tfaviconCount \t= 0,\n\t\tfaviconArray\t= []\n\t\n\tif( singleBookmark ) {\n\t\t\n\t\tfaviconArray.push( singleBookmark )\n\t\t\n\t} else {\n\t\n\t\tfor( let bookmark of bookmarkData ) {\n\t\t\t\n\t\t\tif( !defaultArray.includes( bookmark.id ) &&\n\t\t\t\t!fs.pathExistsSync( `${dir}/favicons/${bookmark.id}.png`\n\t\t\t) ) {\n\t\t\t\t\n\t\t\t\tfaviconArray.push( bookmark )\n\t\t\t}\n\t\t}\n\t}\n\t\n\tlet arrayLength = faviconArray.length\n\t\n\tif( arrayLength < 1 ) {\n\t\t\n\t\tlog.info( `No favicons to generate` )\n\t\tlog.info( `Default favicons are: ${defaultArray}` )\n\t\twin.webContents.send( 'load-tray-menu' )\n\t}\n\t\n\tfor( let i = 0; i < arrayLength; i++ ) {\n\t\t\n\t\tlet bookmarkUrl = new URL( faviconArray[i].url ),\n\t\t\tdomain \t\t= bookmarkUrl.hostname,\n\t\t\ticonurl \t= `https://api.faviconkit.com/${domain}/32`,\n\t\t\tfile \t\t= `${dir}/favicons/${faviconArray[i].id}.png`,\n\t\t\tfile2x\t\t= `${dir}/favicons/${faviconArray[i].id}@2x.png`\n\t\t\n\t\taxios.get(iconurl, { responseType: 'arraybuffer' })\n\t\t.then( function( response ) {\n\t\t\t\n\t\t\tconst buffer = Buffer.from(response.data, \"utf-8\")\n\t\t\t\n\t\t\tif(\n\t\t\t\tresponse.headers['content-type'].includes('png') ||\n\t\t\t\tresponse.headers['content-type'].includes('jpeg') ||\n\t\t\t\tresponse.headers['content-type'].includes('x-icon')\n\t\t\t) {\n\t\t\t\t\n\t\t\t\tlet imgpng = nativeImage.createFromBuffer(buffer, {\n\t\t\t\t\t\t\n\t\t\t\t\t\tscaleFactor: 1.0\n\t\t\t\t\t}).resize({\n\t\t\t\t\t\twidth: 16,\n\t\t\t\t\t\theight: 16,\n\t\t\t\t\t\tquality: 'best'\n\t\t\t\t\t}).toPNG()\n\t\t\t\t\n\t\t\t\tlet imgpng2x = nativeImage.createFromBuffer(buffer, {\n\t\t\t\t\t\t\n\t\t\t\t\t\tscaleFactor: 1.0\n\t\t\t\t\t}).resize({\n\t\t\t\t\t\twidth: 32,\n\t\t\t\t\t\theight: 32,\n\t\t\t\t\t\tquality: 'best'\n\t\t\t\t\t}).toPNG()\n\t\t\t\t\n\t\t\t\tfs.outputFileSync(file, imgpng, err => {\n\t\t\t\t\t\n\t\t\t\t\tif(err) log.info(err)\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\tfs.outputFileSync(file2x, imgpng2x, err => {\n\t\t\t\t\t\n\t\t\t\t\tif(err) log.info(err)\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\tlog.info( `favicon: ${faviconArray[i].id} - generated` )\n\t\t\t\t\n\t\t\t\tfaviconCount++\n\t\t\t\tif( faviconCount === arrayLength ) {\n\t\t\t\t\t\n\t\t\t\t\tgeneratedFavicons( win, faviconCount, defaultArray, notify )\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\tfaviconFallback( bookmarkData[i].id, bookmarkUrl, file, file2x, function( theDefault ) {\n\t\t\t\t\t\n\t\t\t\t\tlog.info( `favicon: ${faviconArray[i].id} - generated` )\n\t\t\t\t\t\n\t\t\t\t\tif( !defaultArray.includes( theDefault ) ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefaultArray.push( theDefault )\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfaviconCount++\n\t\t\t\t\tif( faviconCount === arrayLength ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tgeneratedFavicons( win, faviconCount, defaultArray, notify )\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\t.catch( function( err ) {\n\t\t\t\n\t\t\tlog.info( `favicon error: ${faviconArray[i].id}: ${err.message}` )\n\t\t\t\n\t\t\tfaviconFallback( bookmarkData[i].id, bookmarkUrl, file, file2x, function( theDefault ) {\n\t\t\t\t\n\t\t\t\tlog.info( `favicon: ${faviconArray[i].id} - generated` )\n\t\t\t\t\n\t\t\t\t\tif( !defaultArray.includes( theDefault ) ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefaultArray.push( theDefault )\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfaviconCount++\n\t\t\t\tif( faviconCount === arrayLength ) {\n\t\t\t\t\t\n\t\t\t\t\tgeneratedFavicons( win, faviconCount, defaultArray, notify )\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n}\n\n\n\nmodule.exports.get = function ( id ) {\n\t\n\tif( fs.pathExistsSync( `${dir}/favicons/${id}.png` ) ) {\n\t\t\n\t\treturn `${dir}/favicons/${id}.png`\n\t\t\n\t} else {\n\t\t\n\t\treturn path.join(__dirname, '../assets/png/faviconTemplate.png') \n\t}\n}\n\n\n\nmodule.exports.exists = function ( id ) {\n\t\n\treturn ( fs.pathExistsSync( `${dir}/favicons/${id}.png` ) ) ? true : false\n}\n\n\n\nfunction faviconFallback( id, url, file, file2x, callback ) {\n\t\n\tlet iconurl = 'https://www.google.com/s2/favicons?sz=32&domain_url=' + url,\n\ttheDefault = null\n\n\taxios.get(iconurl, { responseType: 'arraybuffer' })\n\t.then( function( response ) {\n\t\t\n\t\tconst buffer = Buffer.from(response.data, \"utf-8\")\n\t\t\n\t\tlet imgpng = nativeImage.createFromBuffer(buffer, {\n\t\t\t\t\n\t\t\t\tscaleFactor: 1.0\n\t\t\t}).resize({\n\t\t\t\twidth: 16,\n\t\t\t\theight: 16,\n\t\t\t\tquality: 'best'\n\t\t\t}).toPNG()\n\t\t\n\t\tlet imgpng2x = nativeImage.createFromBuffer(buffer, {\n\t\t\t\t\n\t\t\t\tscaleFactor: 1.0\n\t\t\t}).resize({\n\t\t\t\twidth: 32,\n\t\t\t\theight: 32,\n\t\t\t\tquality: 'best'\n\t\t\t}).toPNG()\n\t\t\n\t\tlet b64enc = Buffer.from(imgpng, 'binary').toString('base64')\n\t\t\n\t\tif( isNotDefaultIcon( b64enc ) ) {\n\t\t\t\n\t\t\tfs.outputFileSync(file, imgpng, err => {\n\t\t\t\t\n\t\t\t\tif (err) log.info(err)\n\t\t\t})\n\t\t\t\n\t\t\tfs.outputFileSync(file2x, imgpng2x, err => {\n\t\t\t\t\n\t\t\t\tif (err) log.info(err)\n\t\t\t})\n\t\t\n\t\t} else {\n\t\t\t\n\t\t\ttheDefault = id\n\t\t}\n\t\t\n\t\tcallback( theDefault )\n\t})\n\t.catch( function( err ) {\n\t\t\n\t\tlog.info( `fallback favicon error: ${id}: ${err.message}` )\n\t})\n}\n\n\n\nfunction generatedFavicons( win, count, defaults, notification ) {\n\t\n\tconst i18n = require( './i18n.min' )\n\t\n\tlog.info( `Generated ${count} favicons` )\n\tstore.set( 'defaultIcons', defaults )\n\tif( notification ) notify( app.name, i18n.t('favicons:regenerated', 'Favicons regenerated') )\n\t\n\tlog.info('load tray menu')\n\twin.webContents.send( 'load-tray-menu' )\n}\n\n\n\nfunction isNotDefaultIcon( b64 ) {\n\t\n\treturn ( b64 === 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACs0lEQVQ4jaWTzU8bBxDFf7V31/baXn+sP2oDduxaCZFKqiKDEDSHKKLKiRs55JCPQ070zyGHinsrxbk0kXpBqsTBKQUbqa1AUCgFk0C8trv2YrNm1y69gJWoveWdZqR5b97MaOAj8clVMD//3FO1apGZfHbCtnoLetPMt4yuD0Dxu9uhoKckuYRnxdL+elyK1guF++ZAYH7+uadt68nc9fjTdud8LpdRY6lsWLXsPpLoJJNSWV7ebhxUdE3xSy/3/qgt+cTQcaFw3xQAqlYt8sWNoadnZu/B57cSI5m0ileWGB8bpnNmkU4qZFMR9fftY/W778u+XC7Kr7snz4AjB8BMPjthtLtzTx5NjGTSKgCW3Wd143Awa0yVEUUnjx9OjrQ653Mz+ewEgAPAOu8tXBsJxaa+TA0Itt3HtvuEAjIAHbNHs2USCnhIDYVi3a69MBDQm2Z+dnZU7Zi9DzZ896vrKF4BAK9H4MZnMfYrf3Pv3k1V1808gADQMkxfPKKgeAW8ssRwIshwIjggAzgdUK2fAhCPKBiG6Rs4APDKEgBT49d4c9LEsj90cwVRdAJwcZkLV3fer9SVRDSF4hX4+naOYrnCzmVRNhUhEZW5M5Wh3uyy86eG4ne3Bw7CIbm0vLzdeL/T2GgSrd5Gq7dZ3Thg7bdjACJBN69ebTbCQbk0EBBFYfGgomvFcuV/bQO8PWnS/weK5QrH1ZbmcouLAE4AR2C6k04GAz//cpiOfqoEUskALsmBKIpol4sbG02ys6/x7dLro6Df9aK0efTD4c6PhhNg8tZj+12tsZtIKNLr1QO1tHHkcPtccrN1xolmYJx2WVnZa/y0snsY9Lte7O3VlsKSWt3aKvT+80zT49n8uWV/o+tm3jjt+i4uLlD87rYaltdlt7C4VvqrHHjvmT4a/wJLYRPRy3Z+JAAAAABJRU5ErkJggg==' ) ? false : true\n}\n"],"file":"../favicons.min.js"} \ No newline at end of file diff --git a/dist/js/maps/fetch.min.js.map b/dist/js/maps/fetch.min.js.map index 2d9dce9..3e60702 100644 --- a/dist/js/maps/fetch.min.js.map +++ b/dist/js/maps/fetch.min.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["fetch.js"],"sourcesContent":["'use strict'\n\nconst i18n\t\t\t= require( './i18n.min' )\n\nconst { remote }\t= require( 'electron' )\nconst ipc \t\t\t= require( 'electron' ).ipcRenderer\nconst dialog\t\t= remote.dialog\nconst Store\t\t\t= require( 'electron-store' )\nconst store\t\t\t= new Store()\nconst $\t\t\t\t= require( 'jquery' )\nconst log\t\t\t= require( 'electron-log' )\n\n\n\nlet bookmarkFile = new Store({\n\t\n\tname: 'bookmarks',\n\tdefaults: {\n\t\tdata: null\n\t}\n})\n\n\n\nconst path = '/index.php/apps/bookmarks/public/rest/v2'\nconst calltype = {\n\t\n\t'all': {\n\t\t'method': 'GET',\n\t\t'url': '/bookmark?page=-1'\t\n\t},\n\t'single': {\n\t\t'method': 'GET',\n\t\t'url': '/bookmark/'\n\t},\n\t'add': {\n\t\t'method': 'POST',\n\t\t'url': '/bookmark?'\n\t},\n\t'modify': {\n\t\t'method': 'PUT',\n\t\t'url': '/bookmark/',\n\t},\n\t'delete': {\n\t\t'method': 'DELETE',\n\t\t'url': '/bookmark/'\n\t},\n\t'modifytag': {\n\t\t'method': 'POST',\n\t\t'url': '/tag?'\n\t},\n\t'deletetag': {\n\t\t'method': 'DELETE',\n\t\t'url': '/tag?old_name='\n\t},\n\t'folders': {\n\t\t'method': 'GET',\n\t\t'url': '/folder'\n\t},\n\t'addfolder': {\n\t\t'method': 'POST',\n\t\t'url': '/folder?'\n\t},\n\t'addtofolder': {\n\t\t'method': 'POST',\n\t\t'url': '/folder/'\n\t},\n\t'deletefromfolder': {\n\t\t'method': 'DELETE',\n\t\t'url': '/folder/'\n\t},\n\t'deletefolder': {\n\t\t'method': 'DELETE',\n\t\t'url': '/folder/'\n\t}\n}\n\n\n\nmodule.exports.bookmarksApi = function( call, id, data, callback ) {\n\t\n\tlet server \t\t= store.get( 'loginCredentials.server' ),\n\t\tusername \t= store.get( 'loginCredentials.username' ),\n\t\tpassword \t= store.get( 'loginCredentials.password' )\n\t\n\tlet init = {\n\t\t\n\t\tmethod: calltype[call]['method'],\n\t\theaders: {\n\t\t\t'Authorization': 'Basic ' + btoa( username + ':' + password ),\n\t\t\t'Content-Type': 'application/json'\n\t\t},\n\t\tmode: 'cors',\n\t\tcache: 'no-cache',\n\t\tcredentials: 'omit'\n\t}\n\t\n\tlet url = `${path}${calltype[call]['url']}${id}${data}`\n\tlog.info(`${call} : ${url}`)\n\t\n\tfetch(server + url, init)\n\t.then(function(response) {\n\t\t\n\t\tif(!response.ok) {\n\t\t\t\n\t\t\tlog.warn(`fetch error: ${response.status} - ${response.statusText}`)\n\t\t\tlet errTxt = parseErrorMessage( response.status )\n\t\t\tthrow Error( `${response.status} ${errTxt}` )\n\t\t\t\n\t\t} else {\n\t\t\n\t\t\tlog.info( `response ok` )\n\t\t\treturn response.text()\n\t\t}\n\t\t\n\t}).then(function(message) {\n\t\t\n\t\tlet doc = JSON.parse(message)\n\t\t\n\t\tswitch( call ) {\n\t\t\t\n\t\t\tcase 'all':\n\t\t\t\t\n\t\t\t\tif (doc['status'] == 'error') {\n\t\t\t\t\t\n\t\t\t\t\tdialog.showErrorBox(\n\t\t\t\t\t\ti18n.t('fetch:errorbox.title.json', 'JSON parsing error'),\n\t\t\t\t\t\ti18n.t('fetch:errorbox.content.json', 'An error occured parsing the bookmarks')\n\t\t\t\t\t)\n\t\t\t\t\t\n\t\t\t\t\tlog.error(doc['message'])\n\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\tcallback( doc.data )\n\t\t\t\t\tbookmarkFile.set('data', doc.data)\n\t\t\t\t}\n\t\t\tbreak\n\t\t\t\n\t\t\tcase 'folders':\n\t\t\t\t\n\t\t\t\tlet folders = []\n\t\t\t\t\n\t\t\t\tfunction traverseFolders( obj ) {\n\t\t\t\t\n\t\t\t\t\tfor( let prop in obj ) {\n\t\t\t\t\n\t\t\t\t\t\tfolders.push( { \"id\": parseInt( obj[prop].id, 10 ), \"text\": obj[prop].title } )\n\t\t\t\t\t\t\n\t\t\t\t\t\tif( typeof obj[prop]=='object' ) {\n\t\t\t\t\n\t\t\t\t\t\t\ttraverseFolders( obj[prop].children )\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttraverseFolders( doc.data )\n\t\t\t\tstore.set( 'folders', folders )\n\t\t\t\tcallback()\n\t\t\t\t\n\t\t\tbreak\n\t\t\t\n\t\t\tcase 'single': callback( message )\n\t\t\tbreak\n\t\t\t\n\t\t\tdefault: callback()\n\t\t}\n\t\t\n\t}).catch(function( error ) {\n\t\t\n\t\tlog.error(error)\n\t\t\n\t\tdialog.showErrorBox(\n\t\t\t\n\t\t\ti18n.t('fetch:errorbox.title.error', 'Server error'),\n\t\t\ti18n.t('fetch:errorbox.content.error', 'there was an error retrieving:\\n{{- server}}{{- url}}\\n\\n{{error}}', {server: server, url: url, error: error})\n\t\t)\n\t})\n}\n\n\n\nfunction parseErrorMessage( message ) {\n\t\n\tlet errMsg\n\t\n\tswitch( message ) {\n\t\t\n\t\tcase 400: errMsg = i18n.t('fetch:dialog.error.message.400', 'Bad Request')\n\t\tbreak\n\t\tcase 401: errMsg = i18n.t('fetch:dialog.error.message.401', 'Unauthorized')\n\t\tbreak\n\t\tcase 403: errMsg = i18n.t('fetch:dialog.error.message.403', 'Forbidden')\n\t\tbreak\n\t\tcase 404: errMsg = i18n.t('fetch:dialog.error.message.404', 'Not Found')\n\t\tbreak\n\t\tcase 500: errMsg = i18n.t('fetch:dialog.error.message.500', 'Internal Server Error')\n\t\tbreak\n\t\tcase 501: errMsg = i18n.t('fetch:dialog.error.message.501', 'Not Implemented')\n\t\tbreak\n\t\tcase 502: errMsg = i18n.t('fetch:dialog.error.message.502', 'Bad Gateway')\n\t\tbreak\n\t\tcase 503: errMsg = i18n.t('fetch:dialog.error.message.503', 'Service Unavailable')\n\t\tbreak\n\t\tcase 504: errMsg = i18n.t('fetch:dialog.error.message.504', 'Gateway Timeout')\n\t\tbreak\n\t\t\n\t\tdefault: errMsg = i18n.t('fetch:dialog.error.message.default', 'Unspecified')\n\t}\n\t\n\treturn errMsg\n}\n"],"file":"../fetch.min.js"} \ No newline at end of file +{"version":3,"names":[],"mappings":"","sources":["fetch.js"],"sourcesContent":["'use strict'\n\nconst i18n\t\t\t= require( './i18n.min' )\n\nconst { remote }\t= require( 'electron' )\nconst ipc \t\t\t= require( 'electron' ).ipcRenderer\nconst dialog\t\t= remote.dialog\nconst Store\t\t\t= require( 'electron-store' )\nconst store\t\t\t= new Store()\nconst $\t\t\t\t= require( 'jquery' )\nconst log\t\t\t= require( 'electron-log' )\n\n\n\nlet bookmarkFile = new Store({\n\t\n\tname: 'bookmarks',\n\tdefaults: {\n\t\tdata: null\n\t}\n})\n\n\n\nconst path = '/index.php/apps/bookmarks/public/rest/v2'\nconst calltype = {\n\t\n\t'all': {\n\t\t'method': 'GET',\n\t\t'url': '/bookmark?page=-1'\t\n\t},\n\t'single': {\n\t\t'method': 'GET',\n\t\t'url': '/bookmark/'\n\t},\n\t'add': {\n\t\t'method': 'POST',\n\t\t'url': '/bookmark?'\n\t},\n\t'modify': {\n\t\t'method': 'PUT',\n\t\t'url': '/bookmark/',\n\t},\n\t'delete': {\n\t\t'method': 'DELETE',\n\t\t'url': '/bookmark/'\n\t},\n\t'modifytag': {\n\t\t'method': 'POST',\n\t\t'url': '/tag?'\n\t},\n\t'deletetag': {\n\t\t'method': 'DELETE',\n\t\t'url': '/tag?old_name='\n\t},\n\t'folders': {\n\t\t'method': 'GET',\n\t\t'url': '/folder'\n\t},\n\t'addfolder': {\n\t\t'method': 'POST',\n\t\t'url': '/folder?'\n\t},\n\t'addtofolder': {\n\t\t'method': 'POST',\n\t\t'url': '/folder/'\n\t},\n\t'deletefromfolder': {\n\t\t'method': 'DELETE',\n\t\t'url': '/folder/'\n\t},\n\t'deletefolder': {\n\t\t'method': 'DELETE',\n\t\t'url': '/folder/'\n\t}\n}\n\n\n\nmodule.exports.bookmarksApi = function( call, id, data, callback ) {\n\t\n\tlet server \t\t= store.get( 'loginCredentials.server' ),\n\t\tusername \t= store.get( 'loginCredentials.username' ),\n\t\tpassword \t= store.get( 'loginCredentials.password' )\n\t\n\tlet init = {\n\t\t\n\t\tmethod: calltype[call]['method'],\n\t\theaders: {\n\t\t\t'Authorization': 'Basic ' + btoa( username + ':' + password ),\n\t\t\t'Content-Type': 'application/json'\n\t\t},\n\t\tmode: 'cors',\n\t\tcache: 'no-cache',\n\t\tcredentials: 'omit'\n\t}\n\t\n\tlet url = `${path}${calltype[call]['url']}${id}${data}`\n\tlog.info(`${call} : ${url}`)\n\t\n\tfetch(server + url, init)\n\t.then(function(response) {\n\t\t\n\t\tif(!response.ok) {\n\t\t\t\n\t\t\tlog.warn(`fetch error: ${response.status} - ${response.statusText}`)\n\t\t\tlet errTxt = parseErrorMessage( response.status )\n\t\t\tthrow Error( `${response.status} ${errTxt}` )\n\t\t\t\n\t\t} else {\n\t\t\n\t\t\tlog.info( `response ok` )\n\t\t\treturn response.text()\n\t\t}\n\t\t\n\t}).then(function(message) {\n\t\t\n\t\tlet doc = JSON.parse(message)\n\t\t\n\t\tswitch( call ) {\n\t\t\t\n\t\t\tcase 'all':\n\t\t\t\t\n\t\t\t\tif (doc['status'] == 'error') {\n\t\t\t\t\t\n\t\t\t\t\tdialog.showErrorBox(\n\t\t\t\t\t\ti18n.t('fetch:errorbox.title.json', 'JSON parsing error'),\n\t\t\t\t\t\ti18n.t('fetch:errorbox.content.json', 'An error occured parsing the bookmarks')\n\t\t\t\t\t)\n\t\t\t\t\t\n\t\t\t\t\tlog.error(doc['message'])\n\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\tcallback( doc.data )\n\t\t\t\t\tbookmarkFile.set('data', doc.data)\n\t\t\t\t}\n\t\t\tbreak\n\t\t\t\n\t\t\tcase 'folders':\n\t\t\t\t\n\t\t\t\tlet folders = []\n\t\t\t\t\n\t\t\t\tfunction traverseFolders( obj ) {\n\t\t\t\t\n\t\t\t\t\tfor( let prop in obj ) {\n\t\t\t\t\n\t\t\t\t\t\tfolders.push( { \"id\": parseInt( obj[prop].id, 10 ), \"text\": obj[prop].title } )\n\t\t\t\t\t\t\n\t\t\t\t\t\tif( typeof obj[prop]=='object' ) {\n\t\t\t\t\n\t\t\t\t\t\t\ttraverseFolders( obj[prop].children )\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttraverseFolders( doc.data )\n\t\t\t\tstore.set( 'folders', folders )\n\t\t\t\tcallback()\n\t\t\t\t\n\t\t\tbreak\n\t\t\t\n\t\t\t//todo - not needed\n\t\t\tcase 'single': callback( message )\n\t\t\tbreak\n\t\t\t\n\t\t\tdefault: callback( message )\n\t\t}\n\t\t\n\t}).catch(function( error ) {\n\t\t\n\t\tlog.error(error)\n\t\t\n\t\tdialog.showErrorBox(\n\t\t\t\n\t\t\ti18n.t('fetch:errorbox.title.error', 'Server error'),\n\t\t\ti18n.t('fetch:errorbox.content.error', 'there was an error retrieving:\\n{{- server}}{{- url}}\\n\\n{{error}}', {server: server, url: url, error: error})\n\t\t)\n\t})\n}\n\n\n\nfunction parseErrorMessage( message ) {\n\t\n\tlet errMsg\n\t\n\tswitch( message ) {\n\t\t\n\t\tcase 400: errMsg = i18n.t('fetch:dialog.error.message.400', 'Bad Request')\n\t\tbreak\n\t\tcase 401: errMsg = i18n.t('fetch:dialog.error.message.401', 'Unauthorized')\n\t\tbreak\n\t\tcase 403: errMsg = i18n.t('fetch:dialog.error.message.403', 'Forbidden')\n\t\tbreak\n\t\tcase 404: errMsg = i18n.t('fetch:dialog.error.message.404', 'Not Found')\n\t\tbreak\n\t\tcase 500: errMsg = i18n.t('fetch:dialog.error.message.500', 'Internal Server Error')\n\t\tbreak\n\t\tcase 501: errMsg = i18n.t('fetch:dialog.error.message.501', 'Not Implemented')\n\t\tbreak\n\t\tcase 502: errMsg = i18n.t('fetch:dialog.error.message.502', 'Bad Gateway')\n\t\tbreak\n\t\tcase 503: errMsg = i18n.t('fetch:dialog.error.message.503', 'Service Unavailable')\n\t\tbreak\n\t\tcase 504: errMsg = i18n.t('fetch:dialog.error.message.504', 'Gateway Timeout')\n\t\tbreak\n\t\t\n\t\tdefault: errMsg = i18n.t('fetch:dialog.error.message.default', 'Unspecified')\n\t}\n\t\n\treturn errMsg\n}\n"],"file":"../fetch.min.js"} \ No newline at end of file diff --git a/dist/js/maps/main.min.js.map b/dist/js/maps/main.min.js.map index ff44492..f7ac7e7 100644 --- a/dist/js/maps/main.min.js.map +++ b/dist/js/maps/main.min.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["main.js"],"sourcesContent":["'use strict'\n\nconst {app, BrowserWindow, ipcMain, protocol, Menu} = require( 'electron' )\nconst url \t\t\t\t= require( 'url' ) \nconst path \t\t\t\t= require( 'path' )\nconst dialog \t\t\t= require( 'electron' ).dialog\nconst Store \t\t\t= require( 'electron-store' )\nconst log\t\t\t\t= require( 'electron-log' )\nconst detectBrowsers\t= require( 'detect-browsers' )\n\nconst menuApp \t\t\t= require( './menu-app.min' )\nconst menuTable \t\t= require( './menu-table.min' )\nconst menuSidebar \t\t= require( './menu-sidebar.min' )\nconst menuTray \t\t\t= require( './menu-tray.min' )\n\nconst favicons \t\t\t= require( './favicons.min' )\n\n\nlet win,\n\tloginFlow,\n\tisQuitting = false\n\n\nlet store = new Store({\n\tname: 'config',\n\tdefaults: {\n\t\t\n\t\twindowBounds: {\n\t\t\twidth: 1000,\n\t\t\theight: 700,\n\t\t\tx: 0,\n\t\t\ty: 0\n\t\t},\n\t\t\n\t\ttableColumns: {\n\t\t\t\n\t\t\tdescription: false,\n\t\t\turl: false,\n\t\t\tcreated: true,\n\t\t\tmodified: true,\n\t\t\tfolders: false,\n\t\t\ttags: true\n\t\t},\n\t\t\n\t\tloginCredentials: {\n\t\t\t\n\t\t\tserver: '',\n\t\t\tusername: '',\n\t\t\tpassword: ''\n\t\t},\n\t\t\n\t\texportPath: app.getPath('desktop'),\n\t\tdirPath: app.getPath( 'appData' ) + '/' + app.name,\n\t\ttags: null,\n\t\tfolders: null,\n\t\tbrowsers: null,\n\t\tdefaultIcons: []\n\t}\n})\n\nlet bookmarkFile = new Store({\n\tname: 'bookmarks',\n\tdefaults: {\n\t\tdata: null\n\t}\n})\n\n\napp.allowRendererProcessReuse = true\n\n\nfunction createWindow() {\n\t\n\tlet { x, y, width, height } = store.get('windowBounds')\n\t\n\twin = new BrowserWindow({\n\t\tshow: false,\n\t\tx: x,\n\t\ty: y,\n\t\twidth: width,\n\t\theight: height,\n\t\tminWidth: 550,\n\t\tminHeight: 544,\n\t\tvibrancy: 'under-window',\n\t\twebPreferences: {\n\t\t\tdevTools: false,\n\t\t\tpreload: path.join(__dirname, './preload.min.js'),\n\t\t\tnodeIntegration: true,\n\t\t}\n\t})\n\t\n\tfunction saveWindowBounds() {\n\t\t\n\t\tstore.set('windowBounds', win.getBounds())\n\t}\n\t\n\twin.loadURL(url.format ({\n\t\t\n\t\tpathname: path.join(__dirname, '../html/app.html'), \n\t\tprotocol: 'file:',\n\t\tslashes: true \n\t}))\n\t\n\twin.once('ready-to-show', () => {\n\t\t\n\t\twin.show()\n\t\tfavicons.generate( win.id, false )\n\t})\n\t\n\twin.on('resize', saveWindowBounds)\n\twin.on('move', saveWindowBounds)\n\t\n\twin.on('blur', () => {\n\t\t\n\t\twin.webContents.send('state', 'blur')\n\t})\n\t\n\twin.on('focus', () => {\n\t\t\n\t\twin.webContents.send('state', 'focus')\n\t})\n\t\n\tapp.on('before-quit', () => {\n\t\t\n\t\tisQuitting = true\n\t})\n\t\n\twin.on('close', function(e) {\n\t\n\t\tif( !isQuitting ) {\n\t\t\t\n\t\t\te.preventDefault()\n\t\t\tMenu.sendActionToFirstResponder('hide:')\n\t\t}\n\t})\n\t\n\twin.webContents.on('did-fail-load', () => {\n\t\t\n\t\tlog.error( `main window did not load` )\n\t})\n\t\n\twin.webContents.on( 'crashed', ( event, killed ) => {\n\t\t\n\t\tlog.info( `main window has crashed:` )\n\t\tlog.error( event )\n\t})\n\t\n\twin.on( 'unresponsive', () => {\n\t\t\n\t\tlog.info( `main window is not responding…` )\n\t})\n\t\n\twin.on( 'responsive', () => {\n\t\t\n\t\tlog.info( `main window is responding` )\n\t})\n\t\n\tdetectBrowsers.getAvailableBrowsers()\n\t.then(browsers => {\n\t\t\n\t\tstore.set('browsers', browsers )\n\t\n\t})\n\t.catch( error => log.error(error) )\n\t\n\tmenuApp.menuApp()\n\tmenuTable.menuBookmarks( win.id )\n\tmenuTable.menuColumns( win.id )\n\tmenuTable.menuPanels( win.id )\n\tmenuSidebar.menuFolders( win.id )\n\tmenuSidebar.menuTags( win.id )\n\tmenuTray.menuTray()\n}\n\n\n\napp.on('ready', function() {\n\t\n\tcreateWindow()\n\t\n\tprotocol.registerFileProtocol('nc', (request, callack) => {\n\t\t\n\t\tconst url = request.url\n\t\t\n\t\tif( url ) {\n\t\t\t\n\t\t\tconst parts = url.split( '&' )\n\t\t\t\n\t\t\tconst \tuser = parts[1].replace('user:', ''),\n\t\t\t\t\tpass = parts[2].replace('password:', '')\n\t\t\t\n\t\t\tstore.set( 'loginCredentials.username', user )\n\t\t\tstore.set( 'loginCredentials.password', pass )\n\t\t\t\n\t\t\tloginFlow.close()\n\t\t\twin.webContents.send('login-ok', 'login-ok')\n\t\t}\n\t\n\t}, ( error ) => {\n\t\t\n\t\tif (error) {\n\t\t\t\n\t\t\tlog.error('Failed to register protocol')\n\t\t\t\n\t\t\tdialog.showErrorBox(\n\t\t\t\t`Error`,\n\t\t\t\t`Failed to register protocol`\n\t\t\t)\n\t\t}\n\t})\n}) \n\n\n\napp.on('window-all-closed', function () {\n\t\n\tif (process.platform !== 'darwin') {\n\t\t\n\t\tapp.quit()\n\t}\n})\n\n\n\napp.on('activate', ( event, hasVisibleWindows ) => {\n\t\n\tif (!hasVisibleWindows) {\n\t\t\n\t\tcreateWindow()\n\t}\n})\n\n\n\napp.on('quit-app', () => {\n\t\n\tisQuitting = true\n\tapp.quit()\n})\n\n\n\nipcMain.on('refresh', (event, message) => {\n\t\n\twin.webContents.send('refresh-bookmarks', 'refresh')\n})\n\n\n\nipcMain.on('loginflow', (event, message) => {\n\t\n\tloginFlow = new BrowserWindow({\n\t\t\n\t\twidth: 800,\n\t\theight: 600,\n\t\tresizable: false,\n\t\tminimizable: false,\n\t\tmaximizable: false,\n\t\tshow: false,\n\t\ttitleBarStyle: 'hidden',\n\t\tbackgroundColor: '#0082c9',\n\t\twebPreferences: {\n\t\t\tdevTools: false,\n\t\t\tnodeIntegration: false\n\t\t}\n\t})\n\t\n\tloginFlow.loadURL( message + '/index.php/login/flow' , {\n\t\t\n\t\tuserAgent: 'Nextcloud Bookmark Manager - Macintosh',\n\t\textraHeaders: 'OCS-APIRequest: true'\n\t})\n\t\n\tloginFlow.once('ready-to-show', () => {\n\t\t\n\t\tloginFlow.show()\n\t})\n\t\n\tloginFlow.webContents.on('did-fail-load', () => {\n\t\t\n\t\tlog.error( `loginflow window did not load` )\n\t})\n\t\n\tloginFlow.webContents.on( 'crashed', ( event, killed ) => {\n\t\t\n\t\tlog.info( `loginflow window has crashed:` )\n\t\tlog.error( event )\n\t})\n\t\n\tloginFlow.on( 'unresponsive', () => {\n\t\t\n\t\tlog.info( `loginflow window is not responding…` )\n\t})\n\t\n\tloginFlow.on( 'responsive', () => {\n\t\t\n\t\tlog.info( `loginflow window is responding` )\n\t})\n})\n\n\n\nipcMain.on('error-in-render', function(event, message) {\n\t\n\tlog.error(`exception in render process:`)\n\tlog.info (message)\n})\n"],"file":"../main.min.js"} \ No newline at end of file +{"version":3,"names":[],"mappings":"","sources":["main.js"],"sourcesContent":["'use strict'\n\nconst {app, BrowserWindow, ipcMain, protocol, Menu} = require( 'electron' )\nconst url \t\t\t\t= require( 'url' ) \nconst path \t\t\t\t= require( 'path' )\nconst dialog \t\t\t= require( 'electron' ).dialog\nconst Store \t\t\t= require( 'electron-store' )\nconst log\t\t\t\t= require( 'electron-log' )\nconst detectBrowsers\t= require( 'detect-browsers' )\n\nconst menuApp \t\t\t= require( './menu-app.min' )\nconst menuTable \t\t= require( './menu-table.min' )\nconst menuSidebar \t\t= require( './menu-sidebar.min' )\nconst menuTray \t\t\t= require( './menu-tray.min' )\n\nconst favicons \t\t\t= require( './favicons.min' )\n\n\nlet win,\n\tloginFlow,\n\tisQuitting = false\n\n\nlet store = new Store({\n\tname: 'config',\n\tdefaults: {\n\t\t\n\t\twindowBounds: {\n\t\t\twidth: 1000,\n\t\t\theight: 700,\n\t\t\tx: 0,\n\t\t\ty: 0\n\t\t},\n\t\t\n\t\ttableColumns: {\n\t\t\t\n\t\t\tdescription: false,\n\t\t\turl: false,\n\t\t\tcreated: true,\n\t\t\tmodified: true,\n\t\t\tfolders: false,\n\t\t\ttags: true\n\t\t},\n\t\t\n\t\tloginCredentials: {\n\t\t\t\n\t\t\tserver: '',\n\t\t\tusername: '',\n\t\t\tpassword: ''\n\t\t},\n\t\t\n\t\texportPath: app.getPath('desktop'),\n\t\tdirPath: app.getPath( 'appData' ) + '/' + app.name,\n\t\ttags: null,\n\t\tfolders: null,\n\t\tbrowsers: null,\n\t\tdefaultIcons: []\n\t}\n})\n\nlet bookmarkFile = new Store({\n\tname: 'bookmarks',\n\tdefaults: {\n\t\tdata: null\n\t}\n})\n\n\napp.allowRendererProcessReuse = true\n\n\nfunction createWindow() {\n\t\n\tlet { x, y, width, height } = store.get('windowBounds')\n\t\n\twin = new BrowserWindow({\n\t\tshow: false,\n\t\tx: x,\n\t\ty: y,\n\t\twidth: width,\n\t\theight: height,\n\t\tminWidth: 550,\n\t\tminHeight: 544,\n\t\tvibrancy: 'under-window',\n\t\twebPreferences: {\n\t\t\tdevTools: false,\n\t\t\tpreload: path.join(__dirname, './preload.min.js'),\n\t\t\tnodeIntegration: true,\n\t\t}\n\t})\n\t\n\tfunction saveWindowBounds() {\n\t\t\n\t\tstore.set('windowBounds', win.getBounds())\n\t}\n\t\n\twin.loadURL(url.format ({\n\t\t\n\t\tpathname: path.join(__dirname, '../html/app.html'), \n\t\tprotocol: 'file:',\n\t\tslashes: true \n\t}))\n\t\n\twin.once('ready-to-show', () => {\n\t\t\n\t\twin.show()\n\t\tfavicons.generate( win.id, false, false )\n\t})\n\t\n\twin.on('resize', saveWindowBounds)\n\twin.on('move', saveWindowBounds)\n\t\n\twin.on('blur', () => {\n\t\t\n\t\twin.webContents.send('state', 'blur')\n\t})\n\t\n\twin.on('focus', () => {\n\t\t\n\t\twin.webContents.send('state', 'focus')\n\t})\n\t\n\tapp.on('before-quit', () => {\n\t\t\n\t\tisQuitting = true\n\t})\n\t\n\twin.on('close', function(e) {\n\t\n\t\tif( !isQuitting ) {\n\t\t\t\n\t\t\te.preventDefault()\n\t\t\tMenu.sendActionToFirstResponder('hide:')\n\t\t}\n\t})\n\t\n\twin.webContents.on('did-fail-load', () => {\n\t\t\n\t\tlog.error( `main window did not load` )\n\t})\n\t\n\twin.webContents.on( 'crashed', ( event, killed ) => {\n\t\t\n\t\tlog.info( `main window has crashed:` )\n\t\tlog.error( event )\n\t})\n\t\n\twin.on( 'unresponsive', () => {\n\t\t\n\t\tlog.info( `main window is not responding…` )\n\t})\n\t\n\twin.on( 'responsive', () => {\n\t\t\n\t\tlog.info( `main window is responding` )\n\t})\n\t\n\tdetectBrowsers.getAvailableBrowsers()\n\t.then(browsers => {\n\t\t\n\t\tstore.set('browsers', browsers )\n\t\n\t})\n\t.catch( error => log.error(error) )\n\t\n\tmenuApp.menuApp()\n\tmenuTable.menuBookmarks( win.id )\n\tmenuTable.menuColumns( win.id )\n\tmenuTable.menuPanels( win.id )\n\tmenuSidebar.menuFolders( win.id )\n\tmenuSidebar.menuTags( win.id )\n\tmenuTray.menuTray()\n}\n\n\n\napp.on('ready', function() {\n\t\n\tcreateWindow()\n\t\n\tprotocol.registerFileProtocol('nc', (request, callack) => {\n\t\t\n\t\tconst url = request.url\n\t\t\n\t\tif( url ) {\n\t\t\t\n\t\t\tconst parts = url.split( '&' )\n\t\t\t\n\t\t\tconst \tuser = parts[1].replace('user:', ''),\n\t\t\t\t\tpass = parts[2].replace('password:', '')\n\t\t\t\n\t\t\tstore.set( 'loginCredentials.username', user )\n\t\t\tstore.set( 'loginCredentials.password', pass )\n\t\t\t\n\t\t\tloginFlow.close()\n\t\t\twin.webContents.send('login-ok', 'login-ok')\n\t\t}\n\t\n\t}, ( error ) => {\n\t\t\n\t\tif (error) {\n\t\t\t\n\t\t\tlog.error('Failed to register protocol')\n\t\t\t\n\t\t\tdialog.showErrorBox(\n\t\t\t\t`Error`,\n\t\t\t\t`Failed to register protocol`\n\t\t\t)\n\t\t}\n\t})\n}) \n\n\n\napp.on('window-all-closed', function () {\n\t\n\tif (process.platform !== 'darwin') {\n\t\t\n\t\tapp.quit()\n\t}\n})\n\n\n\napp.on('activate', ( event, hasVisibleWindows ) => {\n\t\n\tif (!hasVisibleWindows) {\n\t\t\n\t\tcreateWindow()\n\t}\n})\n\n\n\napp.on('quit-app', () => {\n\t\n\tisQuitting = true\n\tapp.quit()\n})\n\n\n\nipcMain.on('refresh', (event, message) => {\n\t\n\twin.webContents.send('refresh-bookmarks', 'refresh')\n})\n\n\n\nipcMain.on('update-favicon', (event, message) => {\n\t\n\tfavicons.generate( win.id, message, false )\n})\n\n\nipcMain.on('loginflow', (event, message) => {\n\t\n\tloginFlow = new BrowserWindow({\n\t\t\n\t\twidth: 800,\n\t\theight: 600,\n\t\tresizable: false,\n\t\tminimizable: false,\n\t\tmaximizable: false,\n\t\tshow: false,\n\t\ttitleBarStyle: 'hidden',\n\t\tbackgroundColor: '#0082c9',\n\t\twebPreferences: {\n\t\t\tdevTools: false,\n\t\t\tnodeIntegration: false\n\t\t}\n\t})\n\t\n\tloginFlow.loadURL( message + '/index.php/login/flow' , {\n\t\t\n\t\tuserAgent: 'Nextcloud Bookmark Manager - Macintosh',\n\t\textraHeaders: 'OCS-APIRequest: true'\n\t})\n\t\n\tloginFlow.once('ready-to-show', () => {\n\t\t\n\t\tloginFlow.show()\n\t})\n\t\n\tloginFlow.webContents.on('did-fail-load', () => {\n\t\t\n\t\tlog.error( `loginflow window did not load` )\n\t})\n\t\n\tloginFlow.webContents.on( 'crashed', ( event, killed ) => {\n\t\t\n\t\tlog.info( `loginflow window has crashed:` )\n\t\tlog.error( event )\n\t})\n\t\n\tloginFlow.on( 'unresponsive', () => {\n\t\t\n\t\tlog.info( `loginflow window is not responding…` )\n\t})\n\t\n\tloginFlow.on( 'responsive', () => {\n\t\t\n\t\tlog.info( `loginflow window is responding` )\n\t})\n})\n\n\n\nipcMain.on('error-in-render', function(event, message) {\n\t\n\tlog.error(`exception in render process:`)\n\tlog.info (message)\n})\n"],"file":"../main.min.js"} \ No newline at end of file diff --git a/dist/js/maps/modal-add-bookmark.min.js.map b/dist/js/maps/modal-add-bookmark.min.js.map index 9dbde05..31a7f2d 100644 --- a/dist/js/maps/modal-add-bookmark.min.js.map +++ b/dist/js/maps/modal-add-bookmark.min.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["modal-add-bookmark.js"],"sourcesContent":["'use strict'\n\nconst i18n \t\t\t= require( './i18n.min' )\n\nconst remote \t\t= require( 'electron' ).remote\nconst ipc \t\t\t= require( 'electron' ).ipcRenderer\nconst dialog \t\t= remote.dialog\n\nconst Store \t\t= require( 'electron-store' )\nconst store \t\t= new Store()\nconst Mousetrap \t= require( 'mousetrap' )\n\nconst $ \t\t\t= require( 'jquery' )\nconst jqueryI18next = require( 'jquery-i18next' )\n\njqueryI18next.init(i18n, $)\nrequire('select2')($)\n\nconst fetch\t\t\t= require( './fetch.min' )\nconst serialize\t\t= require( './serialize.min' )\n\nlet folders\t\t\t= store.get( 'folders' ).reverse(),\n\ttagsList \t\t= store.get('tags'),\n\turlParams \t\t= new URLSearchParams( location.search ),\n\tcurrentFolder \t= urlParams.get('folder'),\n\tcurrentTag \t\t= urlParams.get('tag'),\n\tnewUrl \t\t\t= urlParams.get('url'),\n\tnewTitle \t\t= urlParams.get('title')\n\nfolders.unshift({\n\t\"id\": -1,\n\t\"text\": i18n.t( 'addbookmark:select.option.home', 'Home' )\n})\n\n\n\n//note(dgmid): log exceptions\n\nwindow.onerror = function( error, url, line ) {\n\t\n\tipc.send( 'error-in-render', {error, url, line} )\n}\n\n\n\n//note(dgmid): set lang & localize strings\n\n$('html').attr('lang', i18n.language)\n$('header').localize()\n$('label').localize()\n$('input').localize()\n$('option').localize()\n$('button').localize()\n\n\n//note(dgmid): register kbd shortcut\n\nMousetrap.bind('command+.', function() {\n\t\n\tcloseModal()\n})\n\n\n//note(dgmid): close modal\n\nfunction closeModal() {\n\t\n\tconst modal = remote.getCurrentWindow()\n\tmodal.close()\n}\n\n\n\n$(document).ready(function() {\n\t\n\tif( newUrl ) $('#url').val( newUrl )\n\tif( newTitle !== null ) $('#title').val( newTitle )\n\t\n\tfor( let folder of folders ) {\n\t\t\n\t\tlet selected = ''\n\t\t\n\t\tif( folder.id == currentFolder ) selected = ' selected';\n\t\t\n\t\t$('#folders').append( `` )\n\t}\n\t\n\t$('#folders').select2({\n\t\t\n\t\ttheme: \"custom\",\n\t\twidth: '320px',\n\t\tlanguage: {\n\t\t\tnoResults:function() { return i18n.t( 'addbookmark:select.noresults', 'No results found' ) }\n\t\t}\n\t})\n\t\n\t$('#tags').select2({\n\t\t\n\t\ttheme: \"custom\",\n\t\twidth: '320px',\n\t\ttags: true,\n\t\ttokenSeparators: [',',';'],\n\t\tdata: store.get('tags')\n\t})\n\t\t\n\tif( currentTag ) {\n\t\t\n\t\tlet tagArray = []\n\t\ttagArray.push( currentTag )\n\t\t\n\t\t$('#tags').val( tagArray )\n\t\t$('#tags').trigger( 'change' )\n\t}\n\t\n\t\n\t//note(dgmid): cancel modal\n\t\n\t$('#cancel').click( function() {\n\t\t\n\t\tcloseModal()\n\t})\n\t\n\t\n\t//note(dgmid): update data\n\t\n\t$('#modal-form').submit( function( e ) {\n\t\t\n\t\te.preventDefault()\n\t\t\n\t\tlet data = serialize.serialize({\n\t\t\t\n\t\t\t'url': $('input[name=\"url\"]').val(),\n\t\t\t'title': $('input[name=\"title\"]').val(),\n\t\t\t'description': $('textarea[name=\"description\"]').val()\n\t\t})\n\t\t\n\t\tlet selectedTags = $('#tags').select2('data')\n\t\t\n\t\tfor (let tag of selectedTags) {\n\t\t\t\n\t\t\tdata += '&tags[]=' + encodeURIComponent(tag['text'])\n\t\t}\n\t\t\n\t\tlet selectedFolders = $('#folders').select2('data')\n\t\t\n\t\tfor(let folder of selectedFolders) {\n\t\t\t\n\t\t\tdata += '&folders[]=' + encodeURIComponent(folder['id'])\n\t\t}\n\t\t\n\t\tfetch.bookmarksApi( 'add', '', data, function() {\n\t\t\t\n\t\t\tipc.send('refresh', 'refresh')\n\t\t\tcloseModal()\n\t\t})\n\t})\n})\n"],"file":"../modal-add-bookmark.min.js"} \ No newline at end of file +{"version":3,"names":[],"mappings":"","sources":["modal-add-bookmark.js"],"sourcesContent":["'use strict'\n\nconst i18n \t\t\t= require( './i18n.min' )\n\nconst remote \t\t= require( 'electron' ).remote\nconst ipc \t\t\t= require( 'electron' ).ipcRenderer\nconst dialog \t\t= remote.dialog\n\nconst Store \t\t= require( 'electron-store' )\nconst store \t\t= new Store()\nconst Mousetrap \t= require( 'mousetrap' )\n\nconst $ \t\t\t= require( 'jquery' )\nconst jqueryI18next = require( 'jquery-i18next' )\n\njqueryI18next.init(i18n, $)\nrequire('select2')($)\n\nconst fetch\t\t\t= require( './fetch.min' )\nconst serialize\t\t= require( './serialize.min' )\n\nlet folders\t\t\t= store.get( 'folders' ).reverse(),\n\ttagsList \t\t= store.get('tags'),\n\turlParams \t\t= new URLSearchParams( location.search ),\n\tcurrentFolder \t= urlParams.get('folder'),\n\tcurrentTag \t\t= urlParams.get('tag'),\n\tnewUrl \t\t\t= urlParams.get('url'),\n\tnewTitle \t\t= urlParams.get('title')\n\nfolders.unshift({\n\t\"id\": -1,\n\t\"text\": i18n.t( 'addbookmark:select.option.home', 'Home' )\n})\n\n\n\n//note(dgmid): log exceptions\n\nwindow.onerror = function( error, url, line ) {\n\t\n\tipc.send( 'error-in-render', {error, url, line} )\n}\n\n\n\n//note(dgmid): set lang & localize strings\n\n$('html').attr('lang', i18n.language)\n$('header').localize()\n$('label').localize()\n$('input').localize()\n$('option').localize()\n$('button').localize()\n\n\n//note(dgmid): register kbd shortcut\n\nMousetrap.bind('command+.', function() {\n\t\n\tcloseModal()\n})\n\n\n//note(dgmid): close modal\n\nfunction closeModal() {\n\t\n\tconst modal = remote.getCurrentWindow()\n\tmodal.close()\n}\n\n\n\n$(document).ready(function() {\n\t\n\tif( newUrl ) $('#url').val( newUrl )\n\tif( newTitle !== null ) $('#title').val( newTitle )\n\t\n\tfor( let folder of folders ) {\n\t\t\n\t\tlet selected = ''\n\t\t\n\t\tif( folder.id == currentFolder ) selected = ' selected';\n\t\t\n\t\t$('#folders').append( `` )\n\t}\n\t\n\t$('#folders').select2({\n\t\t\n\t\ttheme: \"custom\",\n\t\twidth: '320px',\n\t\tlanguage: {\n\t\t\tnoResults:function() { return i18n.t( 'addbookmark:select.noresults', 'No results found' ) }\n\t\t}\n\t})\n\t\n\t$('#tags').select2({\n\t\t\n\t\ttheme: \"custom\",\n\t\twidth: '320px',\n\t\ttags: true,\n\t\ttokenSeparators: [',',';'],\n\t\tdata: store.get('tags')\n\t})\n\t\t\n\tif( currentTag ) {\n\t\t\n\t\tlet tagArray = []\n\t\ttagArray.push( currentTag )\n\t\t\n\t\t$('#tags').val( tagArray )\n\t\t$('#tags').trigger( 'change' )\n\t}\n\t\n\t\n\t//note(dgmid): cancel modal\n\t\n\t$('#cancel').click( function() {\n\t\t\n\t\tcloseModal()\n\t})\n\t\n\t\n\t//note(dgmid): update data\n\t\n\t$('#modal-form').submit( function( e ) {\n\t\t\n\t\te.preventDefault()\n\t\t\n\t\tlet data = serialize.serialize({\n\t\t\t\n\t\t\t'url': $('input[name=\"url\"]').val(),\n\t\t\t'title': $('input[name=\"title\"]').val(),\n\t\t\t'description': $('textarea[name=\"description\"]').val()\n\t\t})\n\t\t\n\t\tlet selectedTags = $('#tags').select2('data')\n\t\t\n\t\tfor (let tag of selectedTags) {\n\t\t\t\n\t\t\tdata += '&tags[]=' + encodeURIComponent(tag['text'])\n\t\t}\n\t\t\n\t\tlet selectedFolders = $('#folders').select2('data')\n\t\t\n\t\tfor(let folder of selectedFolders) {\n\t\t\t\n\t\t\tdata += '&folders[]=' + encodeURIComponent(folder['id'])\n\t\t}\n\t\t\n\t\tfetch.bookmarksApi( 'add', '', data, function( message ) {\n\t\t\t\n\t\t\tlet returnedBookmark = JSON.parse( message )\n\t\t\tipc.send('update-favicon', returnedBookmark['item'] )\n\t\t\t\n\t\t\tipc.send('refresh', 'refresh')\n\t\t\tcloseModal()\n\t\t})\n\t})\n})\n"],"file":"../modal-add-bookmark.min.js"} \ No newline at end of file diff --git a/dist/js/modal-add-bookmark.min.js b/dist/js/modal-add-bookmark.min.js index 8cd653d..98d53e2 100644 --- a/dist/js/modal-add-bookmark.min.js +++ b/dist/js/modal-add-bookmark.min.js @@ -148,7 +148,10 @@ $(document).ready(function() { data += '&folders[]=' + encodeURIComponent(folder['id']) } - fetch.bookmarksApi( 'add', '', data, function() { + fetch.bookmarksApi( 'add', '', data, function( message ) { + + let returnedBookmark = JSON.parse( message ) + ipc.send('update-favicon', returnedBookmark['item'] ) ipc.send('refresh', 'refresh') closeModal()