...
Code Block |
---|
|
function time2sec(dateTime) {
let ms = dateTime.split(',')[1]
let hh = dateTime.split(':')[0]
let mm = dateTime.split(':')[1]
let ss = dateTime.split(':')[2].split(',')[0]
let ts = (parseInt(hh) * 3600) + (parseInt(mm) * 60) + parseInt(ss) + (parseInt(ms) / 1000)
return ts
}
let finalValues = []
let inputArray = inputValues["TEXT"].split(/\n\s*\n/)
let i=0
while(i < inputArray.length) {
i = i + 1
if(inputArray[i]) {
let startTime = time2sec(inputArray[i].split('\n')[1].split('-->')[0])
let endTime = time2sec(inputArray[i].split('\n')[1].split('-->')[1])
finalValues.push( {
"id": i,
"curTime": 0,
"endTime": endTime,
"startTime": startTime ,
"UIstartTime": startTime,
"UIendTime": endTime,
"split": 0,
"audiourl": "",
"pos": 0,
"transliterationData": inputArray[i].split('\n')[2].split(" ").map(w => ({
"word": w,
"tags": [],
"languageTag": "",
"editedText": ""
}))
})
}
}
let x = JSON.stringify(finalValues)
this.updateAnnotations(x) |
12. On load custom code to convert gdrive sharing urls to viewing url.
Code Block |
---|
|
function getIdFromUrl(url) { return url.match(/[-\w]{25,}/); }
let inputUrl = getIdFromUrl(inputValues["image"])[0]
this.changeInputValue("image", "https://drive.google.com/uc?export=view&id="+inputUrl) |