Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
dfucci committed Mar 21, 2018
1 parent 1325d30 commit b0d0160
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 227 deletions.
201 changes: 0 additions & 201 deletions LICENSE

This file was deleted.

22 changes: 9 additions & 13 deletions carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@
<div id="question">
<img src="" alt="">
<div id="buttons">
<x-button id="yes">
<x-box vertical>
<x-label>Accept</x-label>
<x-icon name='thumb-up'></x-icon>
</x-box>
</x-button>
<div id="countdown"></div>
<x-button id="no">
<x-box vertical>
<x-label>Decline</x-label>
<x-icon name='thumb-down'></x-icon>
</x-box>
</x-button>
<x-box vertical>
Accept
<br>
<-- </x-box>
<div id="countdown"></div>
<x-box vertical>
Decline
<br> -->
</x-box>
</div>
</div>
</body>
Expand Down
1 change: 0 additions & 1 deletion data.json

This file was deleted.

9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { app, BrowserWindow, ipcMain } from 'electron';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as url from 'url';

Expand Down Expand Up @@ -32,8 +33,12 @@ function createWindow() {
mainWindow = null;
});
}
ipcMain.on('subject:create', (e: any, subject: any) => {
// fs.writeFileSync('./data.json', JSON.stringify(subject), 'utf-8');
ipcMain.on('answers:save', (e: any, answers: any) => {
fs.writeFileSync(
path.join(os.homedir(), `answers_${Date.now()}.csv`),
answers,
'utf-8'
);
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
Expand Down
22 changes: 15 additions & 7 deletions src/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs');
const path = require('path');
const json2csv = require('json2csv').parse;
const BrowserWindow = electron.remote.BrowserWindow;
const remote = require('electron').remote;

let questions: Question[];
window.onload = () => {
Expand Down Expand Up @@ -81,7 +82,8 @@ function startCarousel(): any {
}, 1000);
} else {
const csvAnswers = json2csv(answers);
console.log(csvAnswers);
ipcRenderer.send('answers:save', csvAnswers);
remote.getCurrentWindow().close();
}
}
nextPicture(questions);
Expand All @@ -90,10 +92,10 @@ function startCarousel(): any {
function answerQuestion(e: any) {
let answer: IAnswer;
answer = {
question: document
.getElementById('question')
.children[0].getAttribute('src')
.split('/')[4]
question: path
.basename(
document.getElementById('question').children[0].getAttribute('src')
)
.split('.')[0],
rank: answers.length,
subject: localStorage.getItem('subject'),
Expand All @@ -107,7 +109,13 @@ function replaceImage(obj: Question) {
const el = document.querySelector('img');
el.setAttribute(
'src',
`./assets/questions/${obj.getType()}/${obj.getImage()}`
path.join(
'file://',
__dirname,
'assets/questions/',
obj.getType(),
obj.getImage()
)
);
}

Expand All @@ -120,7 +128,7 @@ function toggleButtons(obj: Question) {

function createQuestionsSequence(): Question[] {
function createQuestionOfType(type: string): Question[] {
const questionFolder = `./assets/questions/${type}`;
const questionFolder = path.join(__dirname, '/assets/questions/', type);
const questionArray: Question[] = [];
fs.readdirSync(questionFolder).forEach((file: any) => {
const q = new Question(file, type);
Expand Down
3 changes: 0 additions & 3 deletions src/renderer.ts

This file was deleted.

0 comments on commit b0d0160

Please sign in to comment.