-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
129 lines (115 loc) · 3.38 KB
/
renderer.js
File metadata and controls
129 lines (115 loc) · 3.38 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
// const {BrowserWindow} = require('electron').remote
const {ipcRenderer} = require('electron')
const closeWindowBtn = document.getElementById('close-window')
const pinWindowBtn = document.getElementById('pin-window')
const reloadWindowBtn = document.getElementById('reload-window')
const windowTitle = document.getElementsByClassName('tradingview-widget-copyright')[0]
const {remote} = require('electron')
const app = remote.app
require('./res/tv.js')
let mainWindow = remote.getCurrentWindow()
let yLock = false
let flag = false
mainWindow.once('ready-to-show', () => {
mainWindow.show()
loadChart()
})
mainWindow.on('closed', function () {
mainWindow = null
})
// mainWindow.on('move', function () {
// let position = mainWindow.getPosition()
// if (position[1] > 0) {
// yLock = false
// }
// if (position[1] === 0) {
// yLock = true
// }
// })
mainWindow.on('blur', () => {
windowTitle.style.background = "#262626";
})
mainWindow.on('focus', () => {
windowTitle.style.background = "#131722";
})
// mainWindow.on('resize', function () {
// if (yLock) {
// mainWindow.setSize(376, 293)
// }
// })
closeWindowBtn.addEventListener('click', () => {
ipcRenderer.send('close-window')
})
pinWindowBtn.addEventListener('click', () => {
if (pinWindow()) {
pinWindowBtn.setAttribute("class", "utils_btn utils_btn_select")
} else {
pinWindowBtn.setAttribute("class", "utils_btn")
}
})
reloadWindowBtn.addEventListener('click', () => {
loadChart()
})
function pinWindow() {
if (mainWindow.isAlwaysOnTop()) {
mainWindow.setAlwaysOnTop(false)
} else {
mainWindow.setAlwaysOnTop(true)
}
return mainWindow.isAlwaysOnTop()
}
function loadChart() {
new TradingView.widget({
"width": 380,
"height": 290,
"symbol": "XAUUSD",
"interval": "15",
"timezone": "Etc/UTC",
"theme": "Dark",
"style": "1",
"locale": app.getLocale().replace('-', '_'),
"toolbar_bg": "#f1f3f6",
"enable_publishing": true,
"hide_side_toolbar": false,
"allow_symbol_change": true,
"studies": [
"MACD@tv-basicstudies"
],
"container_id": "tradingview_44e89"
})
}
// function showWindow() {
// let position = mainWindow.getPosition()
// if (position[1] < 0 && flag) {
// contentWindow.removeEventListener('mouseleave', hideWindow(), false)
// for (let i = position[1]; i <= 0; i = i + 2) {
// mainWindow.setBounds({
// width: 376, height: 293, x: position[0], y: i
// })
// }
// flag = false
// setTimeout(function () {
// contentWindow.addEventListener('mouseleave', hideWindow())
// }, 500)
// }
//
// }
//
// function hideWindow() {
// let position = mainWindow.getPosition()
// if (position[1] === 0 && !flag) {
// for (let i = 0; i > -273; i = i - 2) {
// mainWindow.setBounds({
// width: 376, height: 293, x: position[0], y: i
// })
// }
// flag = true
// }
// }
//
// contentWindow.addEventListener('mouseover', () => {
// showWindow()
// })