Skip to content

Commit

Permalink
Added Standard linting
Browse files Browse the repository at this point in the history
  • Loading branch information
terkelg committed Sep 17, 2016
1 parent 30b667f commit 17c9f88
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 292 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> Unofficial Instagram Desktop App
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

<br>
[![](media/screenshot.png)](https://github.com/terkelg/ramme/releases/latest)

Expand All @@ -12,7 +14,7 @@

When closing the window, the app will continue running in the background, in the dock on macOS and the tray on Linux/Windows. Right-click the dock/tray icon and choose `Quit` to completely quit the app. On macOS, click the dock icon to show the window. On Linux, right-click the tray icon and choose `Toggle` to toggle the window. On Windows, click the tray icon to toggle the window.

### Dark mode
### Dark mode
You can toggle dark mode in the Ramme menu or with <kbd>Cmd</kbd> <kbd>D</kbd> / <kbd>Ctrl</kbd> <kbd>D</kbd>.

<img src="media/screenshot-dark.png" width="589" />
Expand Down
144 changes: 67 additions & 77 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,133 +1,123 @@
'use strict';
const electron = require('electron');
const config = require('./config');
const elementReady = require('element-ready');
'use strict'
const electron = require('electron')
const config = require('./config')
const elementReady = require('element-ready')

const ipcRenderer = electron.ipcRenderer;
const $ = document.querySelector.bind(document);
const ipcRenderer = electron.ipcRenderer
const $ = document.querySelector.bind(document)

var post = 0;
var post = 0

const selectors = {
root: '#react-root ._onabe',
loginButton: '#react-root ._fcn8k'
};

}

ipcRenderer.on('toggle-dark-mode', () => {
config.set('darkMode', !config.get('darkMode'));
setDarkMode();
});

config.set('darkMode', !config.get('darkMode'))
setDarkMode()
})

ipcRenderer.on('navigate-home', () => {
const home = $('._n7q2c ._r1svv:nth-child(1) a');
if(home) {
home.click();
const home = $('._n7q2c ._r1svv:nth-child(1) a')
if (home) {
home.click()
}
});

})

ipcRenderer.on('navigate-discover', () => {
const discover = $('._n7q2c ._r1svv:nth-child(2) a');
if(discover) {
discover.click();
const discover = $('._n7q2c ._r1svv:nth-child(2) a')
if (discover) {
discover.click()
}
});

})

ipcRenderer.on('navigate-notifications', () => {
const notifications = $('._n7q2c ._r1svv:nth-child(3) a');
if(notifications) {
notifications.click();
const notifications = $('._n7q2c ._r1svv:nth-child(3) a')
if (notifications) {
notifications.click()
}
});

})

ipcRenderer.on('navigate-profile', () => {
const profile = $('._n7q2c ._r1svv:nth-child(4) a');
console.log(profile);
if(profile) {
profile.click();
const profile = $('._n7q2c ._r1svv:nth-child(4) a')
console.log(profile)
if (profile) {
profile.click()
}
});
})

ipcRenderer.on('navigate-up', () => {
if (post > 1 ){
post -= 1;
var title = $('#react-root > section > main > section > div > div:nth-child(1) > article:nth-child('+post+') > header');
var rect = title.getBoundingClientRect();
window.scrollBy(0,rect.top);
if (post > 1) {
post -= 1
var title = $('#react-root > section > main > section > div > div:nth-child(1) > article:nth-child(' + post + ') > header')
var rect = title.getBoundingClientRect()
window.scrollBy(0, rect.top)
}
});
})

ipcRenderer.on('navigate-down', () => {
post += 1;
var title = $('#react-root > section > main > section > div > div:nth-child(1) > article:nth-child('+post+') > header');
var rect = title.getBoundingClientRect();
window.scrollBy(0,rect.top);
});
post += 1
var title = $('#react-root > section > main > section > div > div:nth-child(1) > article:nth-child(' + post + ') > header')
var rect = title.getBoundingClientRect()
window.scrollBy(0, rect.top)
})


function backButton() {
const body = $('body');
const link = document.createElement('a');
const element = document.createElement('div');
function backButton () {
const body = $('body')
const link = document.createElement('a')
const element = document.createElement('div')

link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22.84 17.39"><polygon points="22.84 8.22 1.82 8.22 9.37 0.67 8.7 0 0 8.7 8.7 17.39 9.37 16.72 1.82 9.17 22.84 9.17 22.84 8.22"/></svg>'
element.classList.add('back-btn', 'inactive');
element.appendChild(link);
body.appendChild(element);
element.classList.add('back-btn', 'inactive')
element.appendChild(link)
body.appendChild(element)

link.addEventListener('click', event => {
ipcRenderer.send('back');
});
ipcRenderer.send('back')
})

ipcRenderer.on('set-button-state', (event, enabled) => {
if (enabled) {
element.classList.remove('inactive');
element.classList.remove('inactive')
} else {
element.classList.add('inactive');
element.classList.add('inactive')
}
});
})
}


function login(elm) {
function login (elm) {
elm.addEventListener('click', (e) => {
elm.classList.toggle('goback');
elm.classList.toggle('goback')
process.nextTick(() => {
if (elm.classList.contains('goback')) {
elm.innerText = 'Go back';
elm.innerText = 'Go back'
} else {
elm.innerText = 'Log In';
elm.innerText = 'Log In'
}
});
});
})
})
}


function setDarkMode() {
document.documentElement.classList.toggle('dark-mode', config.get('darkMode'));
function setDarkMode () {
document.documentElement.classList.toggle('dark-mode', config.get('darkMode'))
}


function init() {
backButton();
setDarkMode();
function init () {
backButton()
setDarkMode()

// Prevent flash of white on startup when in dark mode
// TODO: Find solution to this with pure css
if (config.get('darkMode')) {
document.documentElement.style.backgroundColor = '#192633';
document.documentElement.style.backgroundColor = '#192633'
}
}


document.addEventListener('DOMContentLoaded', (event) => {
// enable OS specific styles
document.documentElement.classList.add(`os-${process.platform}`);
document.documentElement.classList.add(`os-${process.platform}`)

elementReady(selectors.root).then(init);
elementReady(selectors.loginButton).then(login);
});
elementReady(selectors.root).then(init)
elementReady(selectors.loginButton).then(login)
})
6 changes: 3 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const Config = require('electron-config');
'use strict'
const Config = require('electron-config')

module.exports = new Config({
defaults: {
Expand All @@ -10,4 +10,4 @@ module.exports = new Config({
height: 700
}
}
});
})
Loading

0 comments on commit 17c9f88

Please sign in to comment.