-
Notifications
You must be signed in to change notification settings - Fork 0
/
syncTime.js
62 lines (54 loc) · 2.29 KB
/
syncTime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* レンダラープロセス(syncTime.html)用のJavaScriptファイル
*/
"use strict";
let locale = null;
let _ = null;
// メインプロセスから言語環境を取得し、ページに必要なテキストを表示
(async ()=>{
locale = await window.api.getConfig('locale');
console.log(`syncTime.js: ${locale}`);
//locale = 'en'; //有効化で英語UIのテスト
_ = window.api;
document.getElementById('Lbl_inputStartTime').setHTML(_.t('INPUT_START_TIME',locale));
document.getElementById('Btn_getFileCreationTime').setHTML(_.t('GET_FILE_CREATION_TIME',locale));
document.getElementById('Btn_getFileName').setHTML(_.t('GUESS_FROM_FILE_NAME',locale));
document.getElementById('Btn_convert').setHTML(_.t('CONVERT',locale));
})();
//ファイル生成時刻を取得
const getFromCreationTime = ()=>{
console.log("getFromCreationTime");
window.api.getMediaBirthDateTime().then(birthDateTime =>{
console.log(birthDateTime);
const startTime = birthDateTime.split(" ")[1].split(":");
document.getElementById("Txt_hh").value = startTime[0];
document.getElementById("Txt_mm").value = startTime[1];
document.getElementById("Txt_ss").value = startTime[2];
});
}
//ファイル名にある時刻を抽出
const GuessFromFileName = ()=>{
console.log("GuessFromFileName");
window.api.getMediaFileName().then(fname =>{
//console.log("Media File Name: "+fname);
const regex = /\b([0-9]{2}-[0-9]{2}-[0-9]{2})/;
if (regex.test(fname)) {
const startTime = fname.match(regex)[0].split("-");
document.getElementById("Txt_hh").value = startTime[0];
document.getElementById("Txt_mm").value = startTime[1];
document.getElementById("Txt_ss").value = startTime[2];
} else {
alert(_.t('GUESS_FROM_FILENAME_FAILED',locale));
}
});
}
//オフセットを計算して補正を実行
const convertTC = ()=>{
const hh = parseInt(document.getElementById("Txt_hh").value);
const mm = parseInt(document.getElementById("Txt_mm").value);
const ss = parseInt(document.getElementById("Txt_ss").value);
const offset = hh*3600 + mm*60 + ss;
//console.log("Offset:"+offset+"sec");
window.api.setTimeOffset(offset);
window.close();
}