Skip to content

Commit

Permalink
Auto update & display actual settings (v0.0.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
KeziahMoselle committed Feb 10, 2018
1 parent 00e3c85 commit 2aacf5d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 19 deletions.
Binary file modified assets/preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<a class="brand-logo center">Gel<b>booru</b></a>
<ul id="nav-mobile" class="left hide-on-med-and-down">
<li class="active"><a id="openSidenav" href="#"><i class="material-icons">menu</i></a></li>
<li><a href="#"><i id="displayRating" class="material-icons">lock_outline</i></a></li>
<li><a href="#"><div id="displayLimit" class="chip">10 images</div></a></li>
<li><a href="#"><i id="displayLayout" class="material-icons">view_module</i></a></li>
</ul>
<ul class="right hide-on-med-and-down">
<li><a id="win-minimize"><i class="material-icons">remove</i></a></li>
Expand Down
69 changes: 50 additions & 19 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// Modules

// Electron
const shell = require('electron').shell;
const remote = require('electron').remote;

// Axios
const axios = require('axios');
const shell = require('electron').shell,
remote = require('electron').remote,
axios = require('axios');

// Var

// HTML elements
const root = document.getElementById('root'); // Body
const searchBar = document.getElementById('searchBar'); // Input type text
const loading = document.getElementById('loading'); // Display loading or not
const container = document.getElementById('container'); // Container of images
const enableNsfw = document.getElementById('enableNsfw'); // Checkbox for nsfw
const themeBtn = document.getElementById('themeBtn'); // Checkbox for theme
const imgLimit = document.getElementById('imgLimit'); // Select for img limit
const selectCardLayout = document.getElementById('selectCardLayout'); // Select for Card Layout
const root = document.getElementById('root'), // Body
searchBar = document.getElementById('searchBar'), // Input type text
loading = document.getElementById('loading'), // Display loading or not
container = document.getElementById('container'), // Container of images
enableNsfw = document.getElementById('enableNsfw'), // Checkbox for nsfw
themeBtn = document.getElementById('themeBtn'), // Checkbox for theme
imgLimit = document.getElementById('imgLimit'), // Select for img limit
selectCardLayout = document.getElementById('selectCardLayout'), // Select for Card Layout
displayRating = document.getElementById('displayRating'), // Display Rating
displayLimit = document.getElementById('displayLimit'), // Display Image limit
displayLayout = document.getElementById('displayLayout'); // Display Card Layout

// Value
var tags;
var isNsfw = "rating:safe";
var limit = 10;
var layout = 'm4';
Expand Down Expand Up @@ -59,7 +59,7 @@
searchBar.onkeypress = (event) => {
if (event.keyCode === 13)
{
let tags = searchBar.value;
tags = searchBar.value;
console.log(`Searching images for ${tags} and ${isNsfw}`);
search(tags, limit, layout);
}
Expand All @@ -69,25 +69,47 @@

// Enable NSFW
enableNsfw.addEventListener('change', () => {
if (enableNsfw.checked) {
if (enableNsfw.checked)
{
isNsfw = "rating:explicit";
displayRating.innerHTML = 'lock_open';
search(tags, limit, layout);
console.log('Images are now nsfw');
}
else {
else
{
isNsfw = "rating:safe";
displayRating.innerHTML = 'lock_outline';
search(tags, limit, layout);
console.log('Images are now safe');
}
});

// Image limit
imgLimit.addEventListener('change', () => {
limit = imgLimit.value;
displayLimit.innerHTML = `${limit} images`;
search(tags, limit, layout);
console.log(`Image limit is now ${limit}`);
});

// Card layout
selectCardLayout.addEventListener('change', () => {
layout = selectCardLayout.value;
switch (layout) {
case 'm4':
displayLayout.innerHTML = 'view_module';
break;

case 'm6':
displayLayout.innerHTML = 'view_carousel';
break;

case 'm8 offset-m2':
displayLayout.innerHTML = 'view_agenda';
break;
}
search(tags, limit, layout);
console.log(`Card layout is now ${layout}`);
});

Expand Down Expand Up @@ -223,6 +245,9 @@ function search(tags, limit = 10, layout)

}

/**
* Remove all images in container
*/
function clearImg()
{
while (container.firstChild)
Expand All @@ -231,11 +256,17 @@ function clearImg()
}
}

/**
* Show loading
*/
function displayLoading()
{
loading.classList.remove('hide');
}

/**
* Hide loading
*/
function hideLoading()
{
loading.classList.add('hide');
Expand Down

0 comments on commit 2aacf5d

Please sign in to comment.