1+ // Custom styled alert with OK option
2+ function createCustomAlert ( message ) {
3+ if ( document . getElementById ( "modalContainer" ) ) return ;
4+
5+ mObj = document . createElement ( "div" ) ;
6+ mObj . id = "modalContainer" ;
7+
8+ alertObj = mObj . appendChild ( document . createElement ( "div" ) ) ;
9+ alertObj . id = "alertBox" ;
10+
11+ msg = alertObj . appendChild ( document . createElement ( "p" ) ) ;
12+ msg . innerHTML = message ;
13+
14+ btn = alertObj . appendChild ( document . createElement ( "div" ) ) ;
15+ btn . id = "closeBtn" ;
16+ btn . appendChild ( document . createTextNode ( "OK" ) ) ;
17+ //btn.focus();
18+ btn . addEventListener ( 'click' , ( ) => {
19+ document . getElementById ( "modalContainer" ) . remove ( ) ;
20+ } ) ;
21+
22+ document . body . appendChild ( mObj ) ;
23+ }
24+
25+ function createCustomYesNoPrompt ( message , yesHandler , noHandler ) {
26+ if ( document . getElementById ( "modalContainer" ) ) return ;
27+
28+ mObj = document . createElement ( "div" ) ;
29+ mObj . id = "modalContainer" ;
30+
31+ alertObj = mObj . appendChild ( document . createElement ( "div" ) ) ;
32+ alertObj . id = "alertBox" ;
33+
34+ msg = alertObj . appendChild ( document . createElement ( "p" ) ) ;
35+ msg . innerHTML = message ;
36+
37+ btn = alertObj . appendChild ( document . createElement ( "div" ) ) ;
38+ btn . id = "yesBtn" ;
39+ btn . appendChild ( document . createTextNode ( "Sim" ) ) ;
40+ btn . addEventListener ( 'click' , ( ) => {
41+ yesHandler ( ) ;
42+ document . getElementById ( "modalContainer" ) . remove ( ) ;
43+ } ) ;
44+
45+
46+ btn = alertObj . appendChild ( document . createElement ( "div" ) ) ;
47+ btn . id = "noBtn" ;
48+ btn . appendChild ( document . createTextNode ( "Não" ) ) ;
49+ btn . addEventListener ( 'click' , ( ) => {
50+ noHandler ( ) ;
51+ document . getElementById ( "modalContainer" ) . remove ( ) ;
52+ } ) ;
53+
54+ document . body . appendChild ( mObj ) ;
55+ }
56+
57+
58+ function createCustomTextPrompt ( message , yesHandler , noHandler ) {
59+ if ( document . getElementById ( "modalContainer" ) ) return ;
60+
61+ mObj = document . createElement ( "div" ) ;
62+ mObj . id = "modalContainer" ;
63+
64+ alertObj = mObj . appendChild ( document . createElement ( "div" ) ) ;
65+ alertObj . id = "alertBox" ;
66+
67+ input = alertObj . appendChild ( document . createElement ( "input" ) ) ;
68+ input . id = "customTextPromptInput" ;
69+ input . placeholder = message ;
70+
71+ btn = alertObj . appendChild ( document . createElement ( "div" ) ) ;
72+ btn . id = "yesBtn" ;
73+ btn . appendChild ( document . createTextNode ( "Enviar" ) ) ;
74+ btn . addEventListener ( 'click' , ( ) => {
75+ yesHandler ( ) ;
76+ document . getElementById ( "modalContainer" ) . remove ( ) ;
77+ } ) ;
78+
79+
80+ btn = alertObj . appendChild ( document . createElement ( "div" ) ) ;
81+ btn . id = "noBtn" ;
82+ btn . appendChild ( document . createTextNode ( "Ignorar" ) ) ;
83+ btn . addEventListener ( 'click' , ( ) => {
84+ noHandler ( ) ;
85+ document . getElementById ( "modalContainer" ) . remove ( ) ;
86+ } ) ;
87+
88+ document . body . appendChild ( mObj ) ;
89+ }
0 commit comments