|
163 | 163 |
|
164 | 164 | h5 {
|
165 | 165 | font-size: 14px;
|
166 |
| - padding: 0 0 5px; |
167 |
| - margin: 0; |
| 166 | + padding: 0 0 5px; |
| 167 | + margin: 0; |
168 | 168 | }
|
169 | 169 |
|
170 | 170 | h5 a {
|
171 |
| - font-size: 12px; |
| 171 | + font-size: 12px; |
172 | 172 | font-weight: normal;
|
173 | 173 | }
|
174 | 174 |
|
175 | 175 | .quality-group {
|
176 |
| - padding: 5px 0 5px; |
| 176 | + padding: 5px 0 5px; |
177 | 177 | border-radius: 3px;
|
178 |
| - margin: 0 0 15px; |
| 178 | + margin: 0 0 15px; |
179 | 179 | }
|
180 | 180 |
|
181 | 181 | .quality-group:last-child {
|
|
191 | 191 | }
|
192 | 192 |
|
193 | 193 | .input-quality {
|
194 |
| - position: relative; |
195 |
| - padding: 0; |
| 194 | + position: relative; |
| 195 | + padding: 0; |
196 | 196 | margin-bottom: -5px;
|
197 |
| - background: transparent; |
198 |
| - border: 0; |
199 |
| - outline: none 0; |
200 |
| - font-size: 14px; |
201 |
| - font-weight: 500; |
202 |
| - min-width: 350px; |
| 197 | + background: transparent; |
| 198 | + border: 0; |
| 199 | + outline: none 0; |
| 200 | + font-size: 14px; |
| 201 | + font-weight: 500; |
| 202 | + min-width: 350px; |
203 | 203 | }
|
204 | 204 |
|
205 | 205 | .channel-logo {
|
206 |
| - display: inline-block; |
207 |
| - border: 1px solid #808080; |
| 206 | + display: inline-block; |
| 207 | + border: 1px solid #808080; |
208 | 208 | background: #585858;
|
209 |
| - color: #fff; |
210 |
| - padding: 5px 10px; |
| 209 | + color: #fff; |
| 210 | + padding: 5px 10px; |
211 | 211 | }
|
212 | 212 | </style>
|
213 | 213 | <script type="text/javascript">
|
214 |
| - window.loadInit = function() { |
| 214 | + window.loadInit = function () { |
215 | 215 |
|
216 | 216 | // ### Initial Focus on Channel Name Field
|
217 | 217 | // When the page loads, focus on the input field with the name "name".
|
218 |
| - $( 'input[name="name"]' ).focus(); |
| 218 | + $('input[name="name"]').focus(); |
219 | 219 |
|
220 | 220 | // ### Handle Stat Input Changes
|
221 | 221 | // When the stat selection changes, update the stat configuration fields accordingly.
|
222 |
| - $( 'select#stats' ).on( 'change', function() { |
| 222 | + $('select#stats').on('change', function () { |
223 | 223 |
|
224 |
| - let $this = $( this ); |
225 |
| - let $statsConf = $( '.stats-conf' ); |
226 |
| - switch ( $this.val() ) { |
| 224 | + let $this = $(this); |
| 225 | + let $statsConf = $('.stats-conf'); |
| 226 | + switch ($this.val()) { |
227 | 227 |
|
228 | 228 | // ### Dynamic Cases Generated via PHP
|
229 | 229 | // For each tracking method, generate corresponding fields.
|
|
234 | 234 | }
|
235 | 235 | @endphp
|
236 | 236 | case '<?= $key ?>':
|
237 |
| - $statsConf.html( '<?= $fields ?>' ); |
| 237 | + $statsConf.html('<?= $fields ?>'); |
238 | 238 | break;
|
239 | 239 | @php endforeach @endphp
|
240 | 240 |
|
|
246 | 246 |
|
247 | 247 | return false;
|
248 | 248 |
|
249 |
| - } ); |
| 249 | + }); |
250 | 250 |
|
251 | 251 | // ### Add a New Stream Group
|
252 | 252 | // When the "Add Group" button is clicked, add a new quality group.
|
253 |
| - $( '.add-group' ).on( 'click', function() { |
| 253 | + $('.add-group').on('click', function () { |
254 | 254 |
|
255 | 255 | // Calculate the new group's index.
|
256 |
| - let xid = parseInt( $( '.quality-group' ).index( $( '.quality-group' ).last() ) ) + 1 || 0; |
257 |
| - let quality = 'Default Quality' + ( xid >= 1 ? ' (' + ( xid + 1 ) + ')' : '' ); |
| 256 | + let xid = parseInt($('.quality-group').index($('.quality-group').last())) + 1 || 0; |
| 257 | + let quality = 'Default Quality' + (xid >= 1 ? ' (' + (xid + 1) + ')' : ''); |
258 | 258 |
|
259 | 259 | // Create the HTML structure for the new quality group.
|
260 | 260 | let $html = $(
|
|
270 | 270 | '</div>'
|
271 | 271 | );
|
272 | 272 |
|
273 |
| - // Append the new group to the streams list. |
274 |
| - $( '.streams-list' ).append( $html ); |
| 273 | + // Append the new group to the stream list. |
| 274 | + $('.streams-list').append($html); |
275 | 275 |
|
276 | 276 | // Automatically add a stream row to the new group.
|
277 |
| - $html.find( '.add-row' ).trigger( 'click' ); |
| 277 | + $html.find('.add-row').trigger('click'); |
278 | 278 |
|
279 | 279 | return false;
|
280 | 280 |
|
281 |
| - } ); |
| 281 | + }); |
282 | 282 |
|
283 | 283 | // ### Delete a Stream Group
|
284 | 284 | // Handle the deletion of a quality group.
|
285 |
| - $( '.streams-list' ).on( 'click', '.delete-group', function() { |
286 |
| - if ( confirm( 'Are you sure you wish to delete the whole group?' ) ) { |
| 285 | + $('.streams-list').on('click', '.delete-group', function () { |
| 286 | + if (confirm('Are you sure you wish to delete the whole group?')) { |
287 | 287 |
|
288 | 288 | // Remove the quality group.
|
289 |
| - $( this ).closest( '.quality-group' ).remove(); |
| 289 | + $(this).closest('.quality-group').remove(); |
290 | 290 |
|
291 | 291 | // ### Reindex the Remaining Groups
|
292 | 292 | // Update the name attributes to maintain correct indices.
|
293 | 293 | let xid = 0;
|
294 |
| - $( '.quality-group' ).each( function() { |
295 |
| - $( this ).find( 'select, input' ).each( function() { |
| 294 | + $('.quality-group').each(function () { |
| 295 | + $(this).find('select, input').each(function () { |
296 | 296 |
|
297 |
| - let $input = $( this ); |
298 |
| - let currentName = $input.attr( 'name' ); |
| 297 | + let $input = $(this); |
| 298 | + let currentName = $input.attr('name'); |
299 | 299 |
|
300 |
| - if ( currentName != null ) { |
| 300 | + if (currentName != null) { |
301 | 301 | // Use regex to replace the index number in the name attribute.
|
302 |
| - $input.attr( 'name', currentName.replace( /_([0-9]+)\[\]/, '_' + xid + '[]' ) ); |
| 302 | + $input.attr('name', currentName.replace(/_([0-9]+)\[\]/, '_' + xid + '[]')); |
303 | 303 | }
|
304 | 304 |
|
305 |
| - } ); |
| 305 | + }); |
306 | 306 |
|
307 | 307 | xid++; // Increment the group index.
|
308 | 308 |
|
309 |
| - } ); |
| 309 | + }); |
310 | 310 | }
|
311 | 311 |
|
312 | 312 | return false;
|
313 | 313 |
|
314 |
| - } ); |
| 314 | + }); |
315 | 315 |
|
316 | 316 | // ### Delete a Stream Row
|
317 | 317 | // Handle the deletion of individual stream rows.
|
318 |
| - $( '.streams-list' ).on( 'click', '.remove-row', function() { |
| 318 | + $('.streams-list').on('click', '.remove-row', function () { |
319 | 319 |
|
320 |
| - if ( confirm( 'Are you sure you wish to delete this stream?' ) ) { |
| 320 | + if (confirm('Are you sure you wish to delete this stream?')) { |
321 | 321 |
|
322 | 322 | // Remove the entire table row containing the stream.
|
323 |
| - $( this ).closest( 'tr' ).remove(); |
| 323 | + $(this).closest('tr').remove(); |
324 | 324 |
|
325 | 325 | }
|
326 | 326 |
|
327 | 327 | return false;
|
328 | 328 |
|
329 |
| - } ); |
| 329 | + }); |
330 | 330 |
|
331 | 331 | // ### Add a Stream Row
|
332 | 332 | // Add a new stream input row within a quality group.
|
333 |
| - $( '.streams-list' ).on( 'click', '.add-row', function() { |
| 333 | + $('.streams-list').on('click', '.add-row', function () { |
334 | 334 |
|
335 | 335 | // Get the index of the current quality group.
|
336 |
| - let xid = parseInt( $( '.quality-group' ).index( $( this ).closest( '.quality-group' ) ) ) || 0; |
| 336 | + let xid = parseInt($('.quality-group').index($(this).closest('.quality-group'))) || 0; |
337 | 337 |
|
338 | 338 | // Append a new stream row to the group's table body.
|
339 |
| - $( this ) |
340 |
| - .closest( '.quality-group' ) |
341 |
| - .find( 'tbody' ) |
| 339 | + $(this) |
| 340 | + .closest('.quality-group') |
| 341 | + .find('tbody') |
342 | 342 | .append(
|
343 | 343 | '<tr class="stream-row">' +
|
344 | 344 | '<td class="col-sm-9">' +
|
|
360 | 360 | );
|
361 | 361 |
|
362 | 362 | // Re-initialize custom select boxes (if using a plugin).
|
363 |
| - $( 'select' ).selectbox(); |
| 363 | + $('select').selectbox(); |
364 | 364 | return false;
|
365 | 365 |
|
366 |
| - } ); |
| 366 | + }); |
367 | 367 |
|
368 | 368 | // ### Update File Input
|
369 | 369 | // the selected file name in a custom input field.
|
370 |
| - $( 'input[type="file"]' ).on( 'change', function() { |
| 370 | + $('input[type="file"]').on('change', function () { |
371 | 371 |
|
372 |
| - let fileName = $( this ).val().replace( /.*\\fakepath\\/, '' ); |
373 |
| - $( this ).parent( '.file-input' ).find( 'input.file-name' ).val( fileName ); |
| 372 | + let fileName = $(this).val().replace(/.*\\fakepath\\/, ''); |
| 373 | + $(this).parent('.file-input').find('input.file-name').val(fileName); |
374 | 374 |
|
375 |
| - } ); |
| 375 | + }); |
376 | 376 |
|
377 | 377 | // ### Delete Existing Logo (Edit Mode Only)
|
378 | 378 | // Allow users to delete the existing logo when editing.
|
379 | 379 | @if (isset($_GET['action']) && $_GET['action'] === 'edit')
|
380 |
| - $( '.delete-logo' ).on( 'click', function() { |
| 380 | + $('.delete-logo').on('click', function () { |
381 | 381 |
|
382 |
| - let $this = $( this ); |
| 382 | + let $this = $(this); |
383 | 383 |
|
384 | 384 | // Send a request to delete the logo.
|
385 |
| - $.get( 'index.php?page=channels&action=edit&channel={{$_GET['channel']}}&logo=delete', function() { |
| 385 | + $.get('index.php?page=channels&action=edit&channel={{$_GET['channel']}}&logo=delete', function () { |
386 | 386 |
|
387 | 387 | // Remove the logo container from the DOM.
|
388 |
| - $this.closest( '.logo-container' ).remove(); |
| 388 | + $this.closest('.logo-container').remove(); |
389 | 389 |
|
390 |
| - } ); |
| 390 | + }); |
391 | 391 |
|
392 | 392 | return false;
|
393 | 393 |
|
394 |
| - } ); |
| 394 | + }); |
395 | 395 | @endif
|
396 | 396 |
|
397 | 397 | // ### Trigger Stats Change on Page Load
|
398 | 398 | // If the form has been submitted or the action is not 'add', trigger the stat change event to populate fields.
|
399 | 399 | @if (!empty( $_POST ) || $_GET['action'] !== 'add')
|
400 |
| - $( 'select#stats' ).trigger( 'change' ); |
| 400 | + $('select#stats').trigger('change'); |
401 | 401 | @endif
|
402 | 402 |
|
403 | 403 | // ### Ensure at Least One Quality Group Exists
|
404 | 404 | // If no quality groups are present, automatically add one.
|
405 |
| - if ( $( '.streams-list .quality-group' ).length === 0 ) { |
| 405 | + if ($('.streams-list .quality-group').length === 0) { |
406 | 406 |
|
407 |
| - $( '.add-group' ).trigger( 'click' ); |
| 407 | + $('.add-group').trigger('click'); |
408 | 408 |
|
409 | 409 | }
|
410 | 410 | };
|
|
0 commit comments