@ -1,17 +1,18 @@
var desertBusStart = new Date ( "1970-01-01T00:00:00Z" ) ;
var timeFormat = 'AGO' ;
pageSetup = function ( isEditor ) {
var timeFormat = "AGO" ;
pageSetup = function ( isEditor ) {
//Get values from ThrimShim
if ( isEditor && /id=/ . test ( document . location . search ) ) {
if ( isEditor && /id=/ . test ( document . location . search ) ) {
var rowId = /id=(.*)(?:&|$)/ . exec ( document . location . search ) [ 1 ] ;
fetch ( "/thrimshim/" + rowId ) . then ( data => data . json ( ) ) . then ( function ( data ) {
fetch ( "/thrimshim/" + rowId )
. then ( data => data . json ( ) )
. then ( function ( data ) {
if ( ! data ) {
alert ( "No video available for stream." ) ;
return ;
}
document . data = data
document . data = data ;
desertBusStart = new Date ( data . bustime _start ) ;
document . getElementById ( "VideoTitlePrefix" ) . value = data . title _prefix ;
document . getElementById ( "VideoTitle" ) . setAttribute ( "maxlength" , data . title _max _length ) ;
@ -19,18 +20,28 @@ pageSetup = function(isEditor) {
document . getElementById ( "StreamName" ) . value = data . video _channel ;
document . getElementById ( "hiddenSubmissionID" ) . value = data . id ;
// for editor, switch to bustime since that's the default
timeFormat = 'BUSTIME' ;
timeFormat = "BUSTIME" ;
// Apply padding - start 1min early, finish 2min late because these times are generally
// rounded down to the minute, so if something ends at "00:10" it might actually end
// at 00:10:59 so we should pad to 00:12:00.
var start = ( data . event _start ) ? new Date ( fromTimestamp ( data . event _start ) . getTime ( ) - 60 * 1000 ) : null ;
var end = ( data . event _end ) ? new Date ( fromTimestamp ( data . event _end ) . getTime ( ) + 2 * 60 * 1000 ) : null ;
var start = data . event _start
? new Date ( fromTimestamp ( data . event _start ) . getTime ( ) - 60 * 1000 )
: null ;
var end = data . event _end
? new Date ( fromTimestamp ( data . event _end ) . getTime ( ) + 2 * 60 * 1000 )
: null ;
setTimeRange ( start , end ) ;
// title and description both default to row description
document . getElementById ( "VideoTitle" ) . value = data . video _title ? data . video _title : data . description ;
document . getElementById ( "VideoDescription" ) . value = data . video _description ? data . video _description : data . description ;
document . getElementById ( "VideoTitle" ) . value = data . video _title
? data . video _title
: data . description ;
document . getElementById ( "VideoDescription" ) . value = data . video _description
? data . video _description
: data . description ;
// tags default to tags from sheet
document . getElementById ( "VideoTags" ) . value = tags _list _to _string ( data . video _tags ? data . video _tags : data . tags ) ;
document . getElementById ( "VideoTags" ) . value = tags _list _to _string (
data . video _tags ? data . video _tags : data . tags
) ;
// If any edit notes, show them
if ( data . notes . length > 0 ) {
@ -39,28 +50,31 @@ pageSetup = function(isEditor) {
}
// Restore advanced options. If any of these are non-default, automatically expand the advanced options pane.
setOptions ( 'uploadLocation' , data . upload _locations , data . upload _location ) ;
setOptions ( "uploadLocation" , data . upload _locations , data . upload _location ) ;
document . getElementById ( "AllowHoles" ) . checked = data . allow _holes ;
document . getElementById ( "uploaderWhitelist" ) . value = ( ! ! data . uploader _whitelist ) ? data . uploader _whitelist . join ( "," ) : "" ;
document . getElementById ( "uploaderWhitelist" ) . value = ! ! data . uploader _whitelist
? data . uploader _whitelist . join ( "," )
: "" ;
if (
(
data . upload _locations . length > 0
&& data . upload _location != null
&& data . upload _location != data . upload _locations [ 0 ]
)
|| data . allow _holes
|| ! ! data . uploader _whitelist
( data . upload _locations . length > 0 &&
data . upload _location != null &&
data . upload _location != data . upload _locations [ 0 ] ) ||
data . allow _holes ||
! ! data . uploader _whitelist
) {
document . getElementById ( 'wubloaderAdvancedInputTable' ) . style . display = "block" ;
document . getElementById ( "wubloaderAdvancedInputTable" ) . style . display = "block" ;
}
loadPlaylist ( isEditor , data . video _start , data . video _end , data . video _quality ) ;
} ) ;
} else {
if ( isEditor ) {
document . getElementById ( "SubmitButton" ) . disabled = true ;
}
else {
if ( isEditor ) { document . getElementById ( 'SubmitButton' ) . disabled = true ; }
fetch ( "/thrimshim/defaults" ) . then ( data => data . json ( ) ) . then ( function ( data ) {
fetch ( "/thrimshim/defaults" )
. then ( data => data . json ( ) )
. then ( function ( data ) {
if ( ! data ) {
alert ( "Editor results call failed, is thrimshim running?" ) ;
return ;
@ -70,136 +84,155 @@ pageSetup = function(isEditor) {
if ( isEditor ) {
document . getElementById ( "VideoTitlePrefix" ) . value = data . title _prefix ;
document . getElementById ( "VideoTitle" ) . setAttribute ( "maxlength" , data . title _max _length ) ;
setOptions ( 'uploadLocation' , data . upload _locations ) ;
setOptions ( "uploadLocation" , data . upload _locations ) ;
}
// Default time format changes depending on mode.
// But in both cases the default input value is 10min ago / "",
// it's just for editor we convert it before the user sees.
if ( isEditor ) {
toggleTimeInput ( 'BUSTIME' ) ;
toggleTimeInput ( "BUSTIME" ) ;
}
loadPlaylist ( isEditor ) ;
} ) ;
}
} ;
// Time-formatting functions
parseDuration = function ( duration ) {
parseDuration = function ( duration ) {
var direction = 1 ;
if ( duration . startsWith ( "-" ) ) {
if ( duration . startsWith ( "-" ) ) {
duration = duration . slice ( 1 ) ;
direction = - 1 ;
}
var parts = duration . split ( ':' ) ;
return ( parseInt ( parts [ 0 ] ) + ( parts [ 1 ] || "0" ) / 60 + ( parts [ 2 ] || "0" ) / 3600 ) * 60 * 60 * direction ;
}
var parts = duration . split ( ":" ) ;
return (
( parseInt ( parts [ 0 ] ) + ( parts [ 1 ] || "0" ) / 60 + ( parts [ 2 ] || "0" ) / 3600 ) * 60 * 60 * direction
) ;
} ;
toBustime = function ( date ) {
return ( date < desertBusStart ? "-" : "" ) + videojs . formatTime ( Math . abs ( ( date - desertBusStart ) / 1000 ) , 600.01 ) . padStart ( 7 , "0:" ) ;
toBustime = function ( date ) {
return (
( date < desertBusStart ? "-" : "" ) +
videojs . formatTime ( Math . abs ( ( date - desertBusStart ) / 1000 ) , 600.01 ) . padStart ( 7 , "0:" )
) ;
} ;
fromBustime = function ( bustime ) {
fromBustime = function ( bustime ) {
return new Date ( desertBusStart . getTime ( ) + 1000 * parseDuration ( bustime ) ) ;
} ;
toTimestamp = function ( date ) {
toTimestamp = function ( date ) {
return date . toISOString ( ) . substring ( 0 , 19 ) ;
}
} ;
fromTimestamp = function ( ts ) {
fromTimestamp = function ( ts ) {
return new Date ( ts + "Z" ) ;
}
} ;
toAgo = function ( date ) {
now = new Date ( )
return ( date < now ? "" : "-" ) + videojs . formatTime ( Math . abs ( ( date - now ) / 1000 ) , 600.01 ) . padStart ( 7 , "0:" ) ;
}
toAgo = function ( date ) {
now = new Date ( ) ;
return (
( date < now ? "" : "-" ) +
videojs . formatTime ( Math . abs ( ( date - now ) / 1000 ) , 600.01 ) . padStart ( 7 , "0:" )
) ;
} ;
fromAgo = function ( ago ) {
fromAgo = function ( ago ) {
return new Date ( new Date ( ) . getTime ( ) - 1000 * parseDuration ( ago ) ) ;
}
} ;
// Set the stream start/end range from a pair of Dates using the current format
// If given null, sets to blank.
setTimeRange = function ( start , end ) {
setTimeRange = function ( start , end ) {
var toFunc = {
UTC : toTimestamp ,
BUSTIME : toBustime ,
AGO : toAgo ,
} [ timeFormat ] ;
document . getElementById ( "StreamStart" ) . value = ( start ) ? toFunc ( start ) : "" ;
document . getElementById ( "StreamEnd" ) . value = ( end ) ? toFunc ( end ) : "" ;
}
document . getElementById ( "StreamStart" ) . value = start ? toFunc ( start ) : "" ;
document . getElementById ( "StreamEnd" ) . value = end ? toFunc ( end ) : "" ;
} ;
// Get the current start/end range as Dates using the current format
// Returns an object containing 'start' and 'end' fields.
// If either is empty / invalid, returns null.
getTimeRange = function ( ) {
getTimeRange = function ( ) {
var fromFunc = {
UTC : fromTimestamp ,
BUSTIME : fromBustime ,
AGO : fromAgo ,
} [ timeFormat ] ;
var convert = function ( value ) {
if ( ! value ) { return null ; }
var convert = function ( value ) {
if ( ! value ) {
return null ;
}
var date = fromFunc ( value ) ;
return ( isNaN ( date ) ) ? null : date ;
return isNaN ( date ) ? null : date ;
} ;
return {
start : convert ( document . getElementById ( "StreamStart" ) . value ) ,
end : convert ( document . getElementById ( "StreamEnd" ) . value ) ,
} ;
}
} ;
getTimeRangeAsTimestamp = function ( ) {
getTimeRangeAsTimestamp = function ( ) {
var range = getTimeRange ( ) ;
return {
// if not null, format as timestamp
start : range . start && toTimestamp ( range . start ) ,
end : range . end && toTimestamp ( range . end ) ,
} ;
}
} ;
toggleHiddenPane = function ( paneID ) {
toggleHiddenPane = function ( paneID ) {
var pane = document . getElementById ( paneID ) ;
pane . style . display = ( pane . style . display === "none" ) ? "block" : "none" ;
}
pane . style . display = pane . style . display === "none" ? "block" : "none" ;
} ;
toggleUltrawide = function ( ) {
toggleUltrawide = function ( ) {
var body = document . getElementsByTagName ( "Body" ) [ 0 ] ;
body . classList . contains ( "ultrawide" ) ? body . classList . remove ( "ultrawide" ) : body . classList . add ( "ultrawide" ) ;
}
body . classList . contains ( "ultrawide" )
? body . classList . remove ( "ultrawide" )
: body . classList . add ( "ultrawide" ) ;
} ;
toggleTimeInput = function ( toggleInput ) {
toggleTimeInput = function ( toggleInput ) {
// Get times using current format, then change format, then write them back
var range = getTimeRange ( ) ;
timeFormat = toggleInput ;
setTimeRange ( range . start , range . end ) ;
}
} ;
// For a given select input element id, add the given list of options.
// If selected is given, it should be the name of an option to select.
// Otherwise the first one is used.
setOptions = function ( element , options , selected ) {
setOptions = function ( element , options , selected ) {
if ( ! selected && options . length > 0 ) {
selected = options [ 0 ]
selected = options [ 0 ] ;
}
options . forEach ( function ( option ) {
document . getElementById ( element ) . innerHTML += '<option value="' + option + '" ' + ( option == selected ? 'selected' : '' ) + '>' + option + '</option>' ;
options . forEach ( function ( option ) {
document . getElementById ( element ) . innerHTML +=
'<option value="' +
option +
'" ' +
( option == selected ? "selected" : "" ) +
">" +
option +
"</option>" ;
} ) ;
}
} ;
buildQuery = function ( params ) {
return Object . keys ( params ) . filter ( key => params [ key ] !== null ) . map ( key =>
encodeURIComponent ( key ) + '=' + encodeURIComponent ( params [ key ] )
) . join ( '&' ) ;
}
buildQuery = function ( params ) {
return Object . keys ( params )
. filter ( key => params [ key ] !== null )
. map ( key => encodeURIComponent ( key ) + "=" + encodeURIComponent ( params [ key ] ) )
. join ( "&" ) ;
} ;
loadPlaylist = function ( isEditor , startTrim , endTrim , defaultQuality ) {
loadPlaylist = function ( isEditor , startTrim , endTrim , defaultQuality ) {
var playlist = "/playlist/" + document . getElementById ( "StreamName" ) . value + ".m3u8" ;
var range = getTimeRangeAsTimestamp ( ) ;
@ -209,64 +242,88 @@ loadPlaylist = function(isEditor, startTrim, endTrim, defaultQuality) {
if ( player && player . trimmingControls && player . vhs . playlists . master ) {
var discontinuities = mapDiscontinuities ( ) ;
if ( ! startTrim ) {
startTrim = getRealTimeForPlayerTime ( discontinuities , player . trimmingControls ( ) . options . startTrim ) ;
if ( startTrim ) { startTrim = startTrim . replace ( 'Z' , '' ) ; }
startTrim = getRealTimeForPlayerTime (
discontinuities ,
player . trimmingControls ( ) . options . startTrim
) ;
if ( startTrim ) {
startTrim = startTrim . replace ( "Z" , "" ) ;
}
}
if ( ! endTrim ) {
endTrim = getRealTimeForPlayerTime ( discontinuities , player . trimmingControls ( ) . options . endTrim ) ;
if ( endTrim ) { endTrim = endTrim . replace ( 'Z' , '' ) ; }
endTrim = getRealTimeForPlayerTime (
discontinuities ,
player . trimmingControls ( ) . options . endTrim
) ;
if ( endTrim ) {
endTrim = endTrim . replace ( "Z" , "" ) ;
}
}
}
setupPlayer ( isEditor , playlist + '?' + queryString , startTrim , endTrim ) ;
setupPlayer ( isEditor , playlist + "?" + queryString , startTrim , endTrim ) ;
//Get quality levels for advanced properties / download
document . getElementById ( 'qualityLevel' ) . innerHTML = "" ;
fetch ( '/files/' + document . getElementById ( 'StreamName' ) . value ) . then ( data => data . json ( ) ) . then ( function ( data ) {
document . getElementById ( "qualityLevel" ) . innerHTML = "" ;
fetch ( "/files/" + document . getElementById ( "StreamName" ) . value )
. then ( data => data . json ( ) )
. then ( function ( data ) {
if ( ! data . length ) {
console . log ( "Could not retrieve quality levels" ) ;
return ;
}
var qualityLevels = data . sort ( ) . reverse ( ) ;
setOptions ( 'qualityLevel' , qualityLevels , defaultQuality ) ;
setOptions ( "qualityLevel" , qualityLevels , defaultQuality ) ;
if ( ! ! defaultQuality && qualityLevels . length > 0 && defaultQuality != qualityLevels [ 0 ] ) {
document . getElementById ( 'wubloaderAdvancedInputTable' ) . style . display = "block" ;
document . getElementById ( "wubloaderAdvancedInputTable" ) . style . display = "block" ;
}
} ) ;
} ;
thrimbletrimmerSubmit = function ( state , override _changes = false ) {
document . getElementById ( 'SubmitButton' ) . disabled = true ;
thrimbletrimmerSubmit = function ( state , override _changes = false ) {
document . getElementById ( "SubmitButton" ) . disabled = true ;
var discontinuities = mapDiscontinuities ( ) ;
var start = getRealTimeForPlayerTime ( discontinuities , player . trimmingControls ( ) . options . startTrim ) ;
if ( start ) { start = start . replace ( 'Z' , '' ) ; }
var start = getRealTimeForPlayerTime (
discontinuities ,
player . trimmingControls ( ) . options . startTrim
) ;
if ( start ) {
start = start . replace ( "Z" , "" ) ;
}
var end = getRealTimeForPlayerTime ( discontinuities , player . trimmingControls ( ) . options . endTrim ) ;
if ( end ) { end = end . replace ( 'Z' , '' ) ; }
if ( end ) {
end = end . replace ( "Z" , "" ) ;
}
var wubData = {
video _start : start ,
video _end : end ,
video _title : document . getElementById ( "VideoTitle" ) . value ,
video _description : document . getElementById ( "VideoDescription" ) . value ,
video _tags : tags _string _to _list ( document . getElementById ( "VideoTags" ) . value ) ,
allow _holes : document . getElementById ( 'AllowHoles' ) . checked ,
upload _location : document . getElementById ( 'uploadLocation' ) . value ,
video _channel : document . getElementById ( "StreamName" ) . value ,
video _quality : document . getElementById ( 'qualityLevel' ) . options [ document . getElementById ( 'qualityLevel' ) . options . selectedIndex ] . value ,
uploader _whitelist : ( document . getElementById ( 'uploaderWhitelist' ) . value ? document . getElementById ( 'uploaderWhitelist' ) . value . split ( ',' ) : null ) ,
state : state ,
video _start : start ,
video _end : end ,
video _title : document . getElementById ( "VideoTitle" ) . value ,
video _description : document . getElementById ( "VideoDescription" ) . value ,
video _tags : tags _string _to _list ( document . getElementById ( "VideoTags" ) . value ) ,
allow _holes : document . getElementById ( "AllowHoles" ) . checked ,
upload _location : document . getElementById ( "uploadLocation" ) . value ,
video _channel : document . getElementById ( "StreamName" ) . value ,
video _quality :
document . getElementById ( "qualityLevel" ) . options [
document . getElementById ( "qualityLevel" ) . options . selectedIndex
] . value ,
uploader _whitelist : document . getElementById ( "uploaderWhitelist" ) . value
? document . getElementById ( "uploaderWhitelist" ) . value . split ( "," )
: null ,
state : state ,
//pass back the sheet columns to check if any have changed
sheet _name : document . data . sheet _name ,
event _start : document . data . event _start ,
event _end : document . data . event _end ,
category : document . data . category ,
description : document . data . description ,
notes : document . data . notes ,
tags : document . data . tags ,
sheet _name : document . data . sheet _name ,
event _start : document . data . event _start ,
event _end : document . data . event _end ,
category : document . data . category ,
description : document . data . description ,
notes : document . data . notes ,
tags : document . data . tags ,
} ;
if ( ! ! user ) {
wubData . token = user . getAuthResponse ( ) . id _token
wubData . token = user . getAuthResponse ( ) . id _token ;
}
if ( override _changes ) {
wubData [ "override_changes" ] = true ;
@ -274,86 +331,113 @@ thrimbletrimmerSubmit = function(state, override_changes=false) {
console . log ( wubData ) ;
console . log ( JSON . stringify ( wubData ) ) ;
if ( ! wubData . video _start ) { alert ( "No start time set" ) ; return ; }
if ( ! wubData . video _end ) { alert ( "No end time set" ) ; return ; }
if ( ! wubData . video _start ) {
alert ( "No start time set" ) ;
return ;
}
if ( ! wubData . video _end ) {
alert ( "No end time set" ) ;
return ;
}
//Submit to thrimshim
var rowId = /id=(.*)(?:&|$)/ . exec ( document . location . search ) [ 1 ] ;
fetch ( "/thrimshim/" + rowId , {
method : 'POST' ,
method : "POST" ,
headers : {
'Accept' : 'application/json' ,
'Content-Type' : 'application/json'
Accept : "application/json" ,
"Content-Type" : "application/json" ,
} ,
body : JSON . stringify ( wubData )
} )
. then ( response => response . text ( ) . then ( text => {
body : JSON . stringify ( wubData ) ,
} ) . then ( response =>
response . text ( ) . then ( text => {
if ( ! response . ok ) {
var error = response . statusText + ": " + text ;
if ( response . status == 409 ) {
dialogue = text + "\nClick Ok to submit anyway; Click Cancel to return to editing"
dialogue = text + "\nClick Ok to submit anyway; Click Cancel to return to editing" ;
if ( confirm ( dialogue ) ) {
thrimbletrimmerSubmit ( state , true ) ;
}
} else {
alert ( error ) ;
}
} else if ( state == 'EDITED' ) {
alert ( ` Edit submitted for video from ${ start } to ${ end } ` )
} else if ( state == "EDITED" ) {
alert ( ` Edit submitted for video from ${ start } to ${ end } ` ) ;
} else {
alert ( "Draft saved" ) ;
}
document . getElementById ( 'SubmitButton' ) . disabled = false ;
} ) ) ;
document . getElementById ( "SubmitButton" ) . disabled = false ;
} )
) ;
} ;
thrimbletrimmerDownload = function ( isEditor ) {
thrimbletrimmerDownload = function ( isEditor ) {
var range = getTimeRangeAsTimestamp ( ) ;
if ( isEditor ) {
if ( player . trimmingControls ( ) . options . startTrim >= player . trimmingControls ( ) . options . endTrim ) {
if ( player . trimmingControls ( ) . options . startTrim >= player . trimmingControls ( ) . options . endTrim ) {
alert ( "End Time must be greater than Start Time" ) ;
return ;
}
var discontinuities = mapDiscontinuities ( ) ;
range . start = getRealTimeForPlayerTime ( discontinuities , player . trimmingControls ( ) . options . startTrim ) ;
range . end = getRealTimeForPlayerTime ( discontinuities , player . trimmingControls ( ) . options . endTrim ) ;
range . start = getRealTimeForPlayerTime (
discontinuities ,
player . trimmingControls ( ) . options . startTrim
) ;
range . end = getRealTimeForPlayerTime (
discontinuities ,
player . trimmingControls ( ) . options . endTrim
) ;
}
var targetURL = "/cut/" + document . getElementById ( "StreamName" ) . value +
"/" + document . getElementById ( 'qualityLevel' ) . options [ document . getElementById ( 'qualityLevel' ) . options . selectedIndex ] . value + ".ts" +
"?" + buildQuery ( {
var targetURL =
"/cut/" +
document . getElementById ( "StreamName" ) . value +
"/" +
document . getElementById ( "qualityLevel" ) . options [
document . getElementById ( "qualityLevel" ) . options . selectedIndex
] . value +
".ts" +
"?" +
buildQuery ( {
start : range . start ,
end : range . end ,
// In non-editor, always use rough cut. They don't have the edit controls to do
// fine time selection anyway.
type : ( isEditor ) ? (
document . getElementById ( 'DownloadType' ) . options [ document . getElementById ( 'DownloadType' ) . options . selectedIndex ] . value
) : "rough" ,
type : isEditor
? document . getElementById ( "DownloadType" ) . options [
document . getElementById ( "DownloadType" ) . options . selectedIndex
] . value
: "rough" ,
// Always allow holes in non-editor, accidentially including holes isn't important
allow _holes : ( isEditor ) ? String ( document . getElementById ( 'AllowHoles' ) . checked ) : "true" ,
allow _holes : isEditor ? String ( document . getElementById ( "AllowHoles" ) . checked ) : "true" ,
} ) ;
console . log ( targetURL ) ;
document . getElementById ( 'DownloadLink' ) . href = targetURL ;
document . getElementById ( 'DownloadLink' ) . style . display = "" ;
document . getElementById ( "DownloadLink" ) . href = targetURL ;
document . getElementById ( "DownloadLink" ) . style . display = "" ;
} ;
thrimbletrimmerManualLink = function ( ) {
thrimbletrimmerManualLink = function ( ) {
document . getElementById ( "ManualButton" ) . disabled = true ;
var rowId = /id=(.*)(?:&|$)/ . exec ( document . location . search ) [ 1 ] ;
var upload _location = ( document . getElementById ( "ManualYoutube" ) . checked ) ? "youtube-manual" : "manual" ;
var body = { link : document . getElementById ( "ManualLink" ) . value , upload _location : upload _location } ;
var upload _location = document . getElementById ( "ManualYoutube" ) . checked
? "youtube-manual"
: "manual" ;
var body = {
link : document . getElementById ( "ManualLink" ) . value ,
upload _location : upload _location ,
} ;
if ( ! ! user ) {
body . token = user . getAuthResponse ( ) . id _token ;
}
fetch ( "/thrimshim/manual-link/" + rowId , {
method : 'POST' ,
fetch ( "/thrimshim/manual-link/" + rowId , {
method : "POST" ,
headers : {
'Accept' : 'application/json' ,
'Content-Type' : 'application/json'
Accept : "application/json" ,
"Content-Type" : "application/json" ,
} ,
body : JSON . stringify ( body )
} )
. then ( response => response . text ( ) . then ( text => {
body : JSON . stringify ( body ) ,
} ) . then ( response =>
response . text ( ) . then ( text => {
if ( ! response . ok ) {
var error = response . statusText + ": " + text ;
console . log ( error ) ;
@ -361,37 +445,43 @@ thrimbletrimmerManualLink = function() {
document . getElementById ( "ManualButton" ) . disabled = false ;
} else {
alert ( "Manual link set to " + body . link ) ;
setTimeout ( ( ) => { window . location . href = '/thrimbletrimmer/dashboard.html' ; } , 500 ) ;
setTimeout ( ( ) => {
window . location . href = "/thrimbletrimmer/dashboard.html" ;
} , 500 ) ;
}
} ) ) ;
} )
) ;
} ;
thrimbletrimmerResetLink = function ( force ) {
thrimbletrimmerResetLink = function ( force ) {
var rowId = /id=(.*)(?:&|$)/ . exec ( document . location . search ) [ 1 ] ;
if ( force && ! confirm (
'Are you sure you want to reset this event? ' +
'This will set the row back to UNEDITED and forget about any video that already may exist. ' +
'It is intended as a last-ditch command to clear a malfunctioning cutter, ' +
'or if a video needs to be re-edited and replaced. ' +
'IT IS YOUR RESPONSIBILITY TO DEAL WITH ANY VIDEO THAT MAY HAVE ALREADY BEEN UPLOADED. '
) ) {
if (
force &&
! confirm (
"Are you sure you want to reset this event? " +
"This will set the row back to UNEDITED and forget about any video that already may exist. " +
"It is intended as a last-ditch command to clear a malfunctioning cutter, " +
"or if a video needs to be re-edited and replaced. " +
"IT IS YOUR RESPONSIBILITY TO DEAL WITH ANY VIDEO THAT MAY HAVE ALREADY BEEN UPLOADED. "
)
) {
return ;
}
document . getElementById ( "ResetButton" ) . disabled = true ;
document . getElementById ( "CancelButton" ) . disabled = true ;
var body = { }
var body = { } ;
if ( ! ! user ) {
body . token = user . getAuthResponse ( ) . id _token ;
}
fetch ( "/thrimshim/reset/" + rowId + "?force=" + force , {
method : 'POST' ,
fetch ( "/thrimshim/reset/" + rowId + "?force=" + force , {
method : "POST" ,
headers : {
'Accept' : 'application/json' ,
'Content-Type' : 'application/json'
Accept : "application/json" ,
"Content-Type" : "application/json" ,
} ,
body : JSON . stringify ( body )
} )
. then ( response => response . text ( ) . then ( text => {
body : JSON . stringify ( body ) ,
} ) . then ( response =>
response . text ( ) . then ( text => {
if ( ! response . ok ) {
var error = response . statusText + ": " + text ;
console . log ( error ) ;
@ -399,25 +489,27 @@ thrimbletrimmerResetLink = function(force) {
document . getElementById ( "ResetButton" ) . disabled = false ;
document . getElementById ( "CancelButton" ) . disabled = true ;
} else {
alert ( "Row has been " + ( ( force ) ? "reset" : "cancelled" ) + ". Reloading..." ) ;
setTimeout ( ( ) => { window . location . reload ( ) ; } , 500 ) ;
alert ( "Row has been " + ( force ? "reset" : "cancelled" ) + ". Reloading..." ) ;
setTimeout ( ( ) => {
window . location . reload ( ) ;
} , 500 ) ;
}
} ) ) ;
} )
) ;
} ;
tags _list _to _string = function ( tag _list ) {
tags _list _to _string = function ( tag _list ) {
return tag _list . join ( ", " ) ;
}
} ;
tags _string _to _list = function ( tag _string ) {
return tag _string . split ( "," ) . map ( tag => tag . trim ( ) ) . filter ( tag => tag . length > 0 ) ;
}
tags _string _to _list = function ( tag _string ) {
return tag _string
. split ( "," )
. map ( tag => tag . trim ( ) )
. filter ( tag => tag . length > 0 ) ;
} ;
round _trip _tag _string = function ( ) {
round _trip _tag _string = function ( ) {
var element = document . getElementById ( "VideoTags" ) ;
element . value = tags _list _to _string (
tags _string _to _list (
element . value
)
) ;
}
element . value = tags _list _to _string ( tags _string _to _list ( element . value ) ) ;
} ;