File tree Expand file tree Collapse file tree 2 files changed +26
-21
lines changed
Expand file tree Collapse file tree 2 files changed +26
-21
lines changed Original file line number Diff line number Diff line change 140140 echo "<div id='messages'> " ;
141141 $ messages = UnityHTTPD::getMessages ();
142142 if (count ($ messages ) >= 3 ) {
143- echo "
144- <button
145- id='clear_all_messages_button'
146- onclick= \"$('#messages .message button').click(); \"
147- >
148- Clear All Messages
149- </button>
150- " ;
143+ echo "<button id='clear_all_messages_button'>Clear All Messages</button> " ;
151144 }
152145 foreach ($ messages as [$ title , $ body , $ level ]) {
153146 echo sprintf (
156149 <h3>%s</h3>
157150 <p>%s</p>
158151 <button
159- onclick= \"
160- this.parentElement.style.display='none';
161- $.ajax({
162- url: '/panel/ajax/delete_message.php',
163- method: 'POST',
164- data: {
165- 'level': '%s',
166- 'title': '%s',
167- 'body': '%s',
168- }
169- });
170- hideClearAllMessagesButtonIfAllMessagesAlreadyCleared();
171- \"
152+ data-level='%s'
153+ data-title='%s'
154+ data-body='%s'
172155 >
173156 ×
174157 </button>
Original file line number Diff line number Diff line change @@ -4,3 +4,25 @@ function hideClearAllMessagesButtonIfAllMessagesAlreadyCleared() {
44 $ ( '#clear_all_messages_button' ) . hide ( ) ;
55 }
66}
7+
8+ $ ( document ) . ready ( function ( ) {
9+ $ ( '#messages' ) . on ( 'click' , '.message button' , function ( ) {
10+ var button = $ ( this ) ;
11+ var message = button . parent ( ) ;
12+ message . hide ( ) ;
13+ $ . ajax ( {
14+ url : '/panel/ajax/delete_message.php' ,
15+ method : 'POST' ,
16+ data : {
17+ 'level' : button . data ( 'level' ) ,
18+ 'title' : button . data ( 'title' ) ,
19+ 'body' : button . data ( 'body' )
20+ }
21+ } ) ;
22+ hideClearAllMessagesButtonIfAllMessagesAlreadyCleared ( ) ;
23+ } ) ;
24+
25+ $ ( '#clear_all_messages_button' ) . on ( 'click' , function ( ) {
26+ $ ( '#messages .message button' ) . click ( ) ;
27+ } ) ;
28+ } ) ;
You can’t perform that action at this time.
0 commit comments