Skip to content

Commit

Permalink
(v0.5.1) Fix save as
Browse files Browse the repository at this point in the history
  • Loading branch information
KeziahMoselle committed Feb 17, 2018
1 parent ee656c3 commit 0ef8f61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<ul id="sidenavImageDetails" class="sidenav">
<li><a class="subheader">Image informations</a></li>
<li><a class="waves-effect" id="sidenavImageSource" class="waves-effect" href=""><i class="material-icons">open_in_new</i>Source</a></li>
<li><a class="waves-effect" id="sidenavImageSaveAs" class="waves-effect" href=""><i class="material-icons">save</i>Save as</a></li>
<li><a class="waves-effect" id="sidenavImageDirectory"></a></li>
<li><a class="waves-effect" id="sidenavImageOwner"></a></li>
<li><a class="waves-effect" id="sidenavImageScore"></a></li>
Expand Down
24 changes: 11 additions & 13 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ var lastTheme = store.get('theme');

// Sidenav image details

// Listen to the click on img and launch openImageDetails()
document.addEventListener('click', (event) => {
if (event.target.localName === 'img')
{
openImageDetails(event);
}
});

function openImageDetails(event)
{
// Fetch image informations with ID
Expand All @@ -121,6 +113,7 @@ var lastTheme = store.get('theme');
tags = image.tags.split(' ');
// Update values
sidenavImageSource.setAttribute('href', `https://gelbooru.com/index.php?page=post&s=view&id=${image.id}`);
sidenavImageSaveAs.setAttribute('href', `${image.file_url}`);
sidenavImageDirectory.innerHTML = `<i class="material-icons">folder</i> Directory: ${image.directory}`;
sidenavImageOwner.innerHTML = `<i class="material-icons">account_circle</i> Owner: ${image.owner}`;
sidenavImageScore.innerHTML = `<i class="material-icons">show_chart</i> Score: ${image.score}`;
Expand Down Expand Up @@ -302,20 +295,25 @@ var lastTheme = store.get('theme');

// Handle links
document.addEventListener('click', (event) => {
console.log(event);
if (event.target.tagName === 'A')
{
if (event.target.href.startsWith('https://gelbooru.com/') || event.target.href.startsWith('https://github.com/'))
{
event.preventDefault();
shell.openExternal(event.target.href);
}
else if (event.target.id === 'sidenavImageSaveAs')
{
event.preventDefault();
saveFile(event.target.href)
.then()
.catch(err => console.error(err.stack));
}
}
else if (event.target.tagName === 'A' && event.target.href.startsWith('https://simg3.gelbooru.com/'))
else if (event.target.localName === 'img')
{
event.preventDefault();
saveFile(event.target.href)
.then()
.catch(err => console.error(err.stack));
openImageDetails(event);
}
});

Expand Down

0 comments on commit 0ef8f61

Please sign in to comment.