-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.py
46 lines (36 loc) · 1.04 KB
/
web.py
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
from pyscript import window,document
from atrtool import *
from web2 import *
import web2
import traceback
def validate_text(event = None):
global atr_obj
textbox = document.getElementById("hextext")
text_data = textbox.value
char_error = False
try:
bdata = bytes.fromhex(text_data)
except:
char_error = True
if char_error:
textbox.classList.add("text-danger")
textbox.classList.remove("text-bg-warning")
return
else:
textbox.classList.remove("text-danger")
parse_error = False
try:
web2.atr_obj = ATR.from_bytes(bdata)
ui_update_all()
except:
window.console.error(traceback.format_exc())
parse_error = True
if parse_error:
textbox.classList.add("text-bg-warning")
else:
textbox.classList.remove("text-bg-warning")
apply_updaters() # add onchange functions to UI elements
validate_text() # reset all fields based on default text
#loading finished
from js import hideLoadingModal
hideLoadingModal()