Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ca189b1

Browse files
committedJan 29, 2025
Fix: when adding channel logo and editing channel again, image reference disparaged #6
1 parent 87ea771 commit ca189b1

File tree

2 files changed

+69
-69
lines changed

2 files changed

+69
-69
lines changed
 

‎panel/channels.edit.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
// Prepare output config array
315315
$conf[] = [
316316
'name' => $pawtunes->strToUTF8($_POST['name']),
317-
'logo' => ((empty($logoPath)) ? ($channels[$_GET['e'] ?? null]['logo'] ?? null) : $logoPath),
317+
'logo' => ((empty($logoPath)) ? ($channels[$_GET['channel'] ?? null]['logo'] ?? null) : $logoPath),
318318
'skin' => ( ! empty($_POST['skin'])) ? $_POST['skin'] : null,
319319
'streams' => $quality_groups,
320320
'stats' => $stats ?? [],

‎panel/views/channel-edit.blade.php

+68-68
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,19 @@
163163
164164
h5 {
165165
font-size: 14px;
166-
padding: 0 0 5px;
167-
margin: 0;
166+
padding: 0 0 5px;
167+
margin: 0;
168168
}
169169
170170
h5 a {
171-
font-size: 12px;
171+
font-size: 12px;
172172
font-weight: normal;
173173
}
174174
175175
.quality-group {
176-
padding: 5px 0 5px;
176+
padding: 5px 0 5px;
177177
border-radius: 3px;
178-
margin: 0 0 15px;
178+
margin: 0 0 15px;
179179
}
180180
181181
.quality-group:last-child {
@@ -191,39 +191,39 @@
191191
}
192192
193193
.input-quality {
194-
position: relative;
195-
padding: 0;
194+
position: relative;
195+
padding: 0;
196196
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;
203203
}
204204
205205
.channel-logo {
206-
display: inline-block;
207-
border: 1px solid #808080;
206+
display: inline-block;
207+
border: 1px solid #808080;
208208
background: #585858;
209-
color: #fff;
210-
padding: 5px 10px;
209+
color: #fff;
210+
padding: 5px 10px;
211211
}
212212
</style>
213213
<script type="text/javascript">
214-
window.loadInit = function() {
214+
window.loadInit = function () {
215215
216216
// ### Initial Focus on Channel Name Field
217217
// When the page loads, focus on the input field with the name "name".
218-
$( 'input[name="name"]' ).focus();
218+
$('input[name="name"]').focus();
219219
220220
// ### Handle Stat Input Changes
221221
// When the stat selection changes, update the stat configuration fields accordingly.
222-
$( 'select#stats' ).on( 'change', function() {
222+
$('select#stats').on('change', function () {
223223
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()) {
227227
228228
// ### Dynamic Cases Generated via PHP
229229
// For each tracking method, generate corresponding fields.
@@ -234,7 +234,7 @@
234234
}
235235
@endphp
236236
case '<?= $key ?>':
237-
$statsConf.html( '<?= $fields ?>' );
237+
$statsConf.html('<?= $fields ?>');
238238
break;
239239
@php endforeach @endphp
240240
@@ -246,15 +246,15 @@
246246
247247
return false;
248248
249-
} );
249+
});
250250
251251
// ### Add a New Stream Group
252252
// When the "Add Group" button is clicked, add a new quality group.
253-
$( '.add-group' ).on( 'click', function() {
253+
$('.add-group').on('click', function () {
254254
255255
// 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) + ')' : '');
258258
259259
// Create the HTML structure for the new quality group.
260260
let $html = $(
@@ -270,75 +270,75 @@
270270
'</div>'
271271
);
272272
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);
275275
276276
// Automatically add a stream row to the new group.
277-
$html.find( '.add-row' ).trigger( 'click' );
277+
$html.find('.add-row').trigger('click');
278278
279279
return false;
280280
281-
} );
281+
});
282282
283283
// ### Delete a Stream Group
284284
// 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?')) {
287287
288288
// Remove the quality group.
289-
$( this ).closest( '.quality-group' ).remove();
289+
$(this).closest('.quality-group').remove();
290290
291291
// ### Reindex the Remaining Groups
292292
// Update the name attributes to maintain correct indices.
293293
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 () {
296296
297-
let $input = $( this );
298-
let currentName = $input.attr( 'name' );
297+
let $input = $(this);
298+
let currentName = $input.attr('name');
299299
300-
if ( currentName != null ) {
300+
if (currentName != null) {
301301
// 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 + '[]'));
303303
}
304304
305-
} );
305+
});
306306
307307
xid++; // Increment the group index.
308308
309-
} );
309+
});
310310
}
311311
312312
return false;
313313
314-
} );
314+
});
315315
316316
// ### Delete a Stream Row
317317
// Handle the deletion of individual stream rows.
318-
$( '.streams-list' ).on( 'click', '.remove-row', function() {
318+
$('.streams-list').on('click', '.remove-row', function () {
319319
320-
if ( confirm( 'Are you sure you wish to delete this stream?' ) ) {
320+
if (confirm('Are you sure you wish to delete this stream?')) {
321321
322322
// Remove the entire table row containing the stream.
323-
$( this ).closest( 'tr' ).remove();
323+
$(this).closest('tr').remove();
324324
325325
}
326326
327327
return false;
328328
329-
} );
329+
});
330330
331331
// ### Add a Stream Row
332332
// 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 () {
334334
335335
// 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;
337337
338338
// 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')
342342
.append(
343343
'<tr class="stream-row">' +
344344
'<td class="col-sm-9">' +
@@ -360,51 +360,51 @@
360360
);
361361
362362
// Re-initialize custom select boxes (if using a plugin).
363-
$( 'select' ).selectbox();
363+
$('select').selectbox();
364364
return false;
365365
366-
} );
366+
});
367367
368368
// ### Update File Input
369369
// the selected file name in a custom input field.
370-
$( 'input[type="file"]' ).on( 'change', function() {
370+
$('input[type="file"]').on('change', function () {
371371
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);
374374
375-
} );
375+
});
376376
377377
// ### Delete Existing Logo (Edit Mode Only)
378378
// Allow users to delete the existing logo when editing.
379379
@if (isset($_GET['action']) && $_GET['action'] === 'edit')
380-
$( '.delete-logo' ).on( 'click', function() {
380+
$('.delete-logo').on('click', function () {
381381
382-
let $this = $( this );
382+
let $this = $(this);
383383
384384
// 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 () {
386386
387387
// Remove the logo container from the DOM.
388-
$this.closest( '.logo-container' ).remove();
388+
$this.closest('.logo-container').remove();
389389
390-
} );
390+
});
391391
392392
return false;
393393
394-
} );
394+
});
395395
@endif
396396
397397
// ### Trigger Stats Change on Page Load
398398
// If the form has been submitted or the action is not 'add', trigger the stat change event to populate fields.
399399
@if (!empty( $_POST ) || $_GET['action'] !== 'add')
400-
$( 'select#stats' ).trigger( 'change' );
400+
$('select#stats').trigger('change');
401401
@endif
402402
403403
// ### Ensure at Least One Quality Group Exists
404404
// 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) {
406406
407-
$( '.add-group' ).trigger( 'click' );
407+
$('.add-group').trigger('click');
408408
409409
}
410410
};

0 commit comments

Comments
 (0)
Please sign in to comment.