Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
WeeJeWel committed Aug 16, 2024
2 parents 1503eee + 4c547b6 commit 6827c8b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 52 deletions.
91 changes: 45 additions & 46 deletions www/js/homey.ink.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const CLIENT_ID = '5cbb504da1fc782009f52e46';
const CLIENT_SECRET = 'gvhs0gebgir8vz8yo2l0jfb49u9xzzhrkuo1uvs8';
const REDIRECT_URL = `${window.location.protocol}//${window.location.host}/login.html`;
const REDIRECT_URL = `${window.location.protocol}//${window.location.host}`;

window.addEventListener('load', () => {

let homepage;
let config;

Expand All @@ -12,79 +12,78 @@ window.addEventListener('load', () => {
clientSecret: CLIENT_SECRET,
redirectUrl: REDIRECT_URL,
});

const $setup = document.getElementById('setup');

const $setupStepLogin = $setup.querySelector('.setup-step-login');
const $setupStepLoginButton = $setupStepLogin.querySelector('.setup-step-button');

const $setupStepUpload = $setup.querySelector('.setup-step-upload');
const $setupStepUploadButton = $setupStepUpload.querySelector('.setup-step-button');
const $setupStepUploadFile = $setupStepUpload.querySelector('#setup-step-upload-file');

const $setupStepDownload = $setup.querySelector('.setup-step-download');
const $setupStepDownloadButton = $setupStepDownload.querySelector('.setup-step-button');

$setupStepLoginButton.addEventListener('click', () => {
const url = api.getLoginUrl();
const popup = window.open(url, 'login', 'width=500,height=800');

window.addEventListener('message', message => {
const { code } = message.data;
if(!code) return alert('Something went wrong.');

api.authenticateWithAuthorizationCode(code).then(token => {
token = JSON.stringify(token);
token = btoa(token);

window.location.href = url;
});

const url = new URL(window.location.href);
const code = url.searchParams.get('code');
if (code) {
api.authenticateWithAuthorizationCode(code).then(token => {
token = JSON.stringify(token);
token = btoa(token);

const url = new URL('https://app.homey.ink');
url.searchParams.append('theme', 'kobo-h2o');
url.searchParams.append('token', token);

homepage = url.toString();

// For the nerds!
(function () {
const url = new URL('https://app.homey.ink');
url.searchParams.append('theme', 'kobo-h2o');
url.searchParams.append('theme', 'web');
url.searchParams.append('token', token);

homepage = url.toString();

// For the nerds!
(function() {
const url = new URL('https://app.homey.ink');
url.searchParams.append('theme', 'web');
url.searchParams.append('token', token);
console.log('Web URL:', url.toString());
})();

$setupStepLogin.classList.add('completed');
$setupStepUpload.classList.remove('disabled');
}).catch(err => {
alert(err.message || err.toString());
});
})
});

console.log('Web URL:', url.toString());
})();

$setupStepLogin.classList.add('completed');
$setupStepUpload.classList.remove('disabled');
}).catch(err => {
alert(err.message || err.toString());
});
};

$setupStepUploadFile.addEventListener('change', e => {
const [ file ] = e.target.files;
const [file] = e.target.files;
const reader = new FileReader();
reader.readAsText(file, 'UTF-8');
reader.onload = e => {
config = window.ini.parse(e.target.result);

config.Browser = config.Browser || {};
config.Browser.homePage = homepage;
config.Browser.homePage = homepage;

config.FeatureSettings = config.FeatureSettings || {};
config.FeatureSettings.FullScreenBrowser = true;

$setupStepUpload.classList.add('completed');
$setupStepDownload.classList.remove('disabled');
$setupStepDownload.classList.remove('disabled');
}
reader.onerror = err => {
alert(err.message || err.toString());
}
});


$setupStepDownloadButton.addEventListener('click', () => {
const file = ini.stringify(config);
downloadFile(file, 'Kobo eReader.conf');
$setupStepDownload.classList.add('completed');
});

});
6 changes: 0 additions & 6 deletions www/login.html

This file was deleted.

0 comments on commit 6827c8b

Please sign in to comment.