-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathponyRenderer.js
40 lines (31 loc) · 1.01 KB
/
ponyRenderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const { ipcRenderer } = require('electron');
const { SpeakDuration } = require('./Config');
function setImage(imagePath) {
let pi = document.getElementById('Pony');
pi.innerHTML = `<img src="${imagePath}" class=PonyImage>`;
}
function setInitialImage() {
let imagePath = window.process.argv.slice(-1)[0];
setImage(imagePath);
let title = document.getElementById('Title');
title.innerText= window.process.argv.slice(-2)[0];
}
function clearSpeak() {
let speechBubble = document.getElementById('Speak');
speechBubble.innerText='';
speechBubble.style.visibility='hidden';
}
setInitialImage();
console.log('loaded ponyRenderer.js');
ipcRenderer.on('image', (evt,img) => {
setImage(img);
});
ipcRenderer.on('speak', (evt,txt) => {
console.log(txt);
let speechBubble = document.getElementById('Speak');
speechBubble.innerText=txt;
speechBubble.style.visibility='visible';
speechBubble.style.opacity=1;
setTimeout(clearSpeak, SpeakDuration);
});