2023-03-06 17:59:58 -05:00
|
|
|
$(document).ready(() ->
|
2023-03-07 11:29:10 -05:00
|
|
|
$('.channel-path').click(updateAttribute)
|
2023-03-07 10:53:18 -05:00
|
|
|
|
2023-03-13 22:23:34 -04:00
|
|
|
$('.video-active').click(updateAttribute)
|
|
|
|
|
2023-03-07 11:29:10 -05:00
|
|
|
$('.video-status').click(updateAttribute)
|
2023-03-06 17:59:58 -05:00
|
|
|
|
2023-03-07 11:29:10 -05:00
|
|
|
$('.video-serial').click(updateAttribute)
|
2023-03-06 17:59:58 -05:00
|
|
|
)
|
|
|
|
|
2023-03-07 11:29:10 -05:00
|
|
|
updateAttribute = (e) ->
|
|
|
|
elem = $(this)
|
|
|
|
type = elem.data('type')
|
|
|
|
attr = elem.data('attribute')
|
|
|
|
newValue = prompt('Enter new ' + type + ' ' + attr + ':', elem.find('span').text())
|
|
|
|
if newValue
|
|
|
|
if attr == 'status'
|
|
|
|
newValue = newValue.toLowerCase()
|
2023-03-13 22:23:34 -04:00
|
|
|
if attr == 'starred'
|
|
|
|
newValue = (String(newValue).toLowerCase() == 'true')
|
2023-03-07 11:29:10 -05:00
|
|
|
payload =
|
|
|
|
value: newValue
|
|
|
|
objectId = $('#' + type + '-id').val()
|
|
|
|
url = '/' + type + '/' + objectId + '/edit/' + attr
|
|
|
|
$.post(url, payload, (data) ->
|
|
|
|
if data == 'success'
|
|
|
|
if attr == 'status'
|
|
|
|
newValue = capitalizeWord(newValue)
|
2023-03-13 22:23:34 -04:00
|
|
|
if attr == 'starred'
|
|
|
|
newValue = if newValue then 'True' else 'False'
|
2023-03-07 11:29:10 -05:00
|
|
|
elem.find('span').text(newValue)
|
|
|
|
)
|
|
|
|
else
|
|
|
|
console.log('User canceled attribute "' + attr + '" update.')
|
|
|
|
|
2023-03-06 17:59:58 -05:00
|
|
|
capitalizeWord = (str) ->
|
|
|
|
return str.charAt(0).toUpperCase() + str.slice(1)
|