stage-manager/assets/coffee/wyrm.coffee

38 lines
1.1 KiB
CoffeeScript
Raw Normal View History

$(document).ready(() ->
$('.channel-path').click(updateAttribute)
2023-03-07 10:53:18 -05:00
$('.video-active').click(updateAttribute)
$('.video-status').click(updateAttribute)
$('.video-serial').click(updateAttribute)
)
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()
if attr == 'starred'
newValue = (String(newValue).toLowerCase() == 'true')
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)
if attr == 'starred'
newValue = if newValue then 'True' else 'False'
elem.find('span').text(newValue)
)
else
console.log('User canceled attribute "' + attr + '" update.')
capitalizeWord = (str) ->
return str.charAt(0).toUpperCase() + str.slice(1)