-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
236 lines (205 loc) · 9.64 KB
/
index.html
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Backdoor Flasher</title>
<!-- Insert this line above script imports // https://stackoverflow.com/questions/32621988/electron-jquery-is-not-defined -->
<script>if (typeof module === 'object') { window.module = module; module = undefined; }</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<link rel='stylesheet' type='text/css' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css'>
<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.all.min.js'></script>
<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>
<style type='text/css'>
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: rgb(230, 230, 230);
text-align: right;
}
</style>
</head>
<body style='background-color:rgb(230, 230, 230);'>
<button class='url ui medium circular inverted violet link icon button' data='https://www.ti.com/lit/ug/swcu117h/swcu117h.pdf'
title='Technical Reference Manual' style='position:absolute; right:40px; top:5px; z-index:1;'>
<i class='microchip icon'></i>
</button>
<button class='url ui medium circular inverted violet link icon button' data='https://github.com/arisoik/backdoor_flasher'
title='Check for Updates' style='position:absolute; right:0px; top:5px; z-index:1;'>
<i class='github icon'></i>
</button>
<div style='position:absolute; left:0px; top:25px; width:100%; padding-left:5px; padding-right:5px;'>
<form class='ui form'>
<h4 class='ui dividing header'>Flashing Parameters</h4>
<div class='three fields'>
<div class='three wide field' title='Click to refresh serial ports list'>
<label>Serial Port</label>
<select id='portsDrp' class='ui fluid dropdown' size='4'>
<option value=''>--</option>
</select>
</div>
<div class='three wide field'>
<label>Baud Rate</label>
<div class='ui input'>
<input id='baudrateInput' type='text' placeholder='e.g. 115200' title='Only positive numbers are accepted'>
</div>
</div>
<div class='ten wide field'>
<label>Hex File</label>
<input id='fileDialog' type='file' name='file[]' accept='.hex' style='display:none;' />
<div class='ui left icon input' title='Only .hex files are accepted'>
<i id='fileDialogBtn' class='inverted circular link file icon'></i>
<input id='filenameFld' type='text' placeholder=' No .hex file chosen...' readonly>
</div>
</div>
</div>
</form>
</div>
<button id='flashBtn' class='ui big circular violet icon button' style='position:absolute; left:50%; top:175px; transform:translate(-50%, -50%);'
title='Flash firmware'><i class='bolt icon'></i>
</button>
<div style='position:absolute; left:0px; top:40%; width:100%; height:57%; padding-left:5px; padding-right:5px;'>
<form class='ui form' style='height:100%;'>
<h4 class='ui dividing header'>Flashing Progress</h4>
<div class='field'>
<div id='progressbar' class='ui indicating progress' style='margin-top:5px; margin-bottom:20px;'>
<div class='bar'></div>
<div class='label'>Waiting...</div>
</div>
</div>
<div class='field' style='height:75%;'>
<label>Logging</label>
<textarea id='logTextarea' style='height:90%;' readonly></textarea>
</div>
</form>
</div>
<div class='footer'>
<div class='summary' style='padding-right:5px;'>
<i>Made with
<a class='url' data='https://electronjs.org/' href='#'>Electron</a> and
<a class='url' data='https://semantic-ui.com/' href='#'>Semantic UI</a>
</i>
</div>
</div>
<script>
$(window).on('load', function () {
const electron = require('electron');
const ipc = electron.ipcRenderer;
$('.url').on('click', function () {
ipc.send('open-URL', $(this).attr('data'));
});
var fileDialog = document.getElementById('fileDialog');
fileDialog.addEventListener('change', function (e) {
var file = e.target.files[0];
$('#filenameFld').val(file.path);
});
$('#fileDialogBtn').on('click', function () {
$('#fileDialog').trigger('click');
});
$('#flashBtn').on('click', function () {
if ($(this).hasClass('disabled') === false) {
$(this).addClass('disabled loading');
$('#progressbar').progress({
label: true,
total: 100,
text: {
active: '{percent}% Complete',
success: 'Completed!'
}
});
const arg = {
'port': $('#portsDrp').dropdown('get text'),
'baudRate': parseInt($('#baudrateInput').val()),
'hexFilename': $('#filenameFld').val()
};
var isParamsValid = true;
var errorMsg = '';
if (arg.port === '--') {
isParamsValid = false;
errorMsg += '- Serial Port' + '</br>';
$('#portsDrp').parent().addClass('error');
}
if (isNaN(arg.baudRate) || arg.baudRate < 0) {
isParamsValid = false;
errorMsg += '- Baud Rate' + '</br>';
$('#baudrateInput').parent().addClass('error');
$('#baudrateInput').val('');
}
if (arg.hexFilename === '' || arg.hexFilename.split('.').pop().toLowerCase() !== 'hex') {
isParamsValid = false;
errorMsg += '- Hex File';
$('#filenameFld').parent().addClass('error');
$('#filenameFld').val('');
}
if (isParamsValid === false) {
$(this).removeClass('disabled loading');
Swal({
type: 'error',
title: 'Invalid Parameters:',
html: errorMsg,
allowOutsideClick: false
});
} else {
$(this).addClass('disabled loading');
ipc.send('start-flash', arg);
}
}
});
$('#portsDrp').dropdown({
onChange: function (value, text, $selectedItem) {
$(this).parent().removeClass('error');
}
});
$('#portsDrp').parent().click(function () {
const reply = ipc.sendSync('sync-list-ports');
$('#portsDrp').empty();
if (reply.length === 0) {
$('#portsDrp').dropdown('restore defaults');
} else {
for (var i = 0; i < reply.length; i++) {
var comName = reply[i].comName;
$('#portsDrp').append($('<option></option>').attr('value', comName).text(comName));
}
}
});
$('#portsDrp').parent().click();
ipc.on('process-status', function (event, arg) {
if (arg.type === 'log') {
appendLog(arg.log);
} else if (arg.type === 'error' || arg.type === 'success') {
if (arg.type === 'error') {
$('#progressbar').progress('reset');
setTimeout(() => {
$('#progressbar').removeClass('active error warning success');
$('#progressbar').find('.label').text('Waiting...');
}, 500);
}
if (arg.log) {
appendLog(arg.log);
}
if (arg.msg) {
Swal({
type: arg.type,
title: 'Flashing Progress',
html: arg.msg,
allowOutsideClick: false
});
}
$('#flashBtn').removeClass('disabled loading');
} else if (arg.type === 'progress') {
$('#progressbar').progress('set percent', arg.percent);
}
});
// HELPER FUNCTIONS //
function appendLog(msg) {
var $logTextarea = $('#logTextarea');
$logTextarea.append(msg + '\n');
$logTextarea.scrollTop($logTextarea[0].scrollHeight - $logTextarea.height());
}
});
</script>
</body>
</html>