Skip to content

Commit 8ecb2e1

Browse files
committed
make custom local notify sound
1 parent c6e0561 commit 8ecb2e1

File tree

5 files changed

+110
-41
lines changed

5 files changed

+110
-41
lines changed

locales/en.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,13 @@
381381
"theme-color-positive" : "Stopwatch (default green): ",
382382
"autostarttask" : "Auto start default task",
383383
"autostarttask-tip" : "When a default task is set and this setting is on, wnr will automatically start the default task every time this app is opened. ",
384-
"withdraw-timing": "Withdraw timing",
385-
"fail-to-withdraw": "You cannot withdraw timing currently. ",
386-
"statistics-enter": "Enter statistics",
387-
"today-total": "Today ",
388-
"can-redo-title": "You've been pausing long",
389-
"can-redo-msg": "Does that mean you want to restart this period of timing? "
384+
"withdraw-timing" : "Withdraw timing",
385+
"fail-to-withdraw" : "You cannot withdraw timing currently. ",
386+
"statistics-enter" : "Enter statistics",
387+
"today-total" : "Today ",
388+
"can-redo-title" : "You've been pausing long",
389+
"can-redo-msg" : "Does that mean you want to restart this period of timing? ",
390+
"custom" : "custom",
391+
"custom-notify-sound" : "Custom notify sound: ",
392+
"input-url" : "Input file url"
390393
}

locales/zh-CN.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,13 @@
376376
"theme-color-positive" : "正计时(默认绿色):",
377377
"autostarttask" : "自动开始默认预设",
378378
"autostarttask-tip" : "当设置了默认预设且开启了此选项后,将在每次打开 wnr 软件时自动开始默认预设的计时,以提升强力水平。",
379-
"withdraw-timing": "提前退出计时",
380-
"fail-to-withdraw": "当前不能提前退出。",
381-
"statistics-enter": "进入统计界面",
382-
"today-total": "今日 ",
383-
"can-redo-title": "你已经暂停了很久",
384-
"can-redo-msg": "是否需要对当前段时间进行重新计时?"
379+
"withdraw-timing" : "提前退出计时",
380+
"fail-to-withdraw" : "当前不能提前退出。",
381+
"statistics-enter" : "进入统计界面",
382+
"today-total" : "今日 ",
383+
"can-redo-title" : "你已经暂停了很久",
384+
"can-redo-msg" : "是否需要对当前段时间进行重新计时?",
385+
"custom" : "自定义",
386+
"custom-notify-sound" : "自定义提示音",
387+
"input-url" : "输入路径"
385388
}

locales/zh-TW.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,12 @@
377377
"autostarttask" : "自動開始默認預設",
378378
"autostarttask-tip" : "當設置了默認預設且開啟了此選項後,將在每次打開 wnr 軟件時自動開始默認預設的計時,以提升強力水平。",
379379
"withdraw-timing": "提前退出計時",
380-
"fail-to-withdraw": "當前不能提前退出。",
381-
"statistics-enter": "進入統計界面",
382-
"today-total": "今日 ",
383-
"can-redo-title": "你已經暫停了很久",
384-
"can-redo-msg": "是否需要對當前段時間進行重新計時?"
380+
"fail-to-withdraw" : "當前不能提前退出。",
381+
"statistics-enter" : "進入統計界面",
382+
"today-total" : "今日 ",
383+
"can-redo-title" : "你已經暫停了很久",
384+
"can-redo-msg" : "是否需要對當前段時間進行重新計時?",
385+
"custom" : "自定義",
386+
"custom-notify-sound" : "自定義提示音",
387+
"input-url" : "輸入路徑"
385388
}

preferences-renderer.js

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,17 @@ function domString(type) {
384384
</div>
385385
</div><br/>
386386
</div>
387+
<div class="col-5 custom-notify-sound-work-time-end">
388+
<label>
389+
${ i18n.__("custom-notify-sound") }
390+
</label>
391+
</div>
392+
<div class="col-7 text-right custom-notify-sound-work-time-end">
393+
<input id="custom-notify-sound-work-time-end" name="custom-notify-sound-work-time-end"
394+
type="text" class="hotkey-set-input extreme-small text-right"
395+
placeholder="${ i18n.__('input-url') }"
396+
onkeyup="store.set('custom-work-time-end-sound',$('#custom-notify-sound-work-time-end').val());" />
397+
</div><br/>
387398
<div class="col-7">
388399
<label>
389400
${ i18n.__("personalization-notify-sound-msg-all-end") }
@@ -400,6 +411,17 @@ function domString(type) {
400411
</div>
401412
</div><br/>
402413
</div>
414+
<div class="col-5 custom-notify-sound-all-time-end">
415+
<label>
416+
${ i18n.__("custom-notify-sound") }
417+
</label>
418+
</div>
419+
<div class="col-7 text-right custom-notify-sound-all-time-end">
420+
<input id="custom-notify-sound-all-time-end" name="custom-notify-sound-all-time-end" type="text"
421+
class="hotkey-set-input extreme-small text-right"
422+
placeholder="${ i18n.__('input-url') }"
423+
onkeyup="store.set('custom-all-time-end-sound',$('#custom-notify-sound-all-time-end').val());"/>
424+
</div><br/>
403425
</div><br/>`;
404426
break;
405427
case "i18n":
@@ -760,47 +782,67 @@ function personalizedNotification() {
760782

761783
//personalization sound
762784
function personalizationSoundInitializer() {
785+
if (store.has("custom-work-time-end-sound"))
786+
$("#custom-notify-sound-work-time-end").val(store.get("custom-work-time-end-sound"));
787+
if (store.has("custom-all-time-end-sound"))
788+
$("#custom-notify-sound-all-time-end").val(store.get("custom-work-all-end-sound"));
763789
let player = document.createElement("audio");//alert player
764-
let soundList = ['alarming', 'beep', 'clock', 'tick', 'trumpet', 'whistle', 'horns', 'magic', 'piano'];
790+
let soundList = ['alarming', 'beep', 'clock', 'tick', 'trumpet', 'whistle', 'horns', 'magic', 'piano', i18n.__('custom')];
765791
for (let i in soundList) {
766792
$("#work-time-end-sound-select").append("\
767793
<a class='dropdown-item' href='javascript:workTimeEndSoundSetting(\"" + soundList[i] + "\")'>"
768794
+ soundList[i] + "</a>");
769795
}
770796
$("#work-time-end-sound-dropdown-button").text(store.has("time-end-sound") ? store.get("time-end-sound") : "tick");
797+
if (store.get("time-end-sound") === i18n.__('custom'))
798+
$(".custom-notify-sound-work-time-end").css("display", "inline-block");
799+
else
800+
$(".custom-notify-sound-work-time-end").css("display", "none");
771801

772802
for (let i in soundList) {
773803
$("#all-time-end-sound-select").append("\
774804
<a class='dropdown-item' href='javascript:allTimeEndSoundSetting(\"" + soundList[i] + "\")'>"
775805
+ soundList[i] + "</a>");
776806
}
777807
$("#all-time-end-sound-dropdown-button").text(store.has("all-end-sound") ? store.get("all-end-sound") : "piano");
808+
if (store.get("all-end-sound") === i18n.__('custom'))
809+
$(".custom-notify-sound-all-time-end").css("display", "inline-block");
810+
else
811+
$(".custom-notify-sound-all-time-end").css("display", "none");
778812
}
779813

780814
function workTimeEndSoundSetting(val) {
781-
try {
782-
let player = document.createElement("audio");//alert player
783-
store.set("time-end-sound", val);
784-
$("#work-time-end-sound-dropdown-button").text(val);
785-
player.src = path.join(__dirname, "\\res\\sound\\" + val + ".mp3");
786-
player.loop = false;
787-
player.play();
788-
} catch (e) {
789-
console.log(e);
790-
}
815+
store.set("time-end-sound", val);
816+
$("#work-time-end-sound-dropdown-button").text(val);
817+
if (val !== i18n.__('custom'))
818+
try {
819+
$(".custom-notify-sound-work-time-end").css("display", "none");
820+
let player = document.createElement("audio");//alert player
821+
player.src = path.join(__dirname, "\\res\\sound\\" + val + ".mp3");
822+
player.loop = false;
823+
player.play();
824+
} catch (e) {
825+
console.log(e);
826+
}
827+
else
828+
$(".custom-notify-sound-work-time-end").css("display", "inline-block");
791829
}
792830

793831
function allTimeEndSoundSetting(val) {
794-
try {
795-
let player = document.createElement("audio");//alert player
796-
store.set("all-end-sound", val);
797-
$("#all-time-end-sound-dropdown-button").text(val);
798-
player.src = path.join(__dirname, "\\res\\sound\\" + val + ".mp3");
799-
player.loop = false;
800-
player.play();
801-
} catch (e) {
802-
console.log(e);
803-
}
832+
store.set("all-end-sound", val);
833+
$("#all-time-end-sound-dropdown-button").text(val);
834+
if (val !== i18n.__('custom'))
835+
try {
836+
$(".custom-notify-sound-all-time-end").css("display", "none");
837+
let player = document.createElement("audio");//alert player
838+
player.src = path.join(__dirname, "\\res\\sound\\" + val + ".mp3");
839+
player.loop = false;
840+
player.play();
841+
} catch (e) {
842+
console.log(e);
843+
}
844+
else
845+
$(".custom-notify-sound-all-time-end").css("display", "inline-block");
804846
}
805847

806848
//language settings

timer.html

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,21 @@ <h3>
713713
let player = document.createElement('audio');
714714
amplifyMedia(player, amplifierList[store.get("sound")]);
715715
if (isend !== 0) {
716-
player.src = path.join(__dirname, "\\res\\sound\\" + (store.has("time-end-sound") ? store.get("time-end-sound") : "tick") + ".mp3");
716+
if (store.get("time-end-sound") !== i18n.__("custom"))
717+
player.src = path.join(__dirname, "\\res\\sound\\" + (store.has("time-end-sound") ? store.get("time-end-sound") : "tick") + ".mp3");
718+
else if ((!store.has("custom-work-time-end-sound") || store.get("custom-work-time-end-sound") === "")
719+
&& store.get("time-end-sound") === i18n.__("custom"))
720+
player.src = path.join(__dirname, "\\res\\sound\\tick.mp3");
721+
else
722+
player.src = store.get("custom-work-time-end-sound");
717723
} else {
718-
player.src = path.join(__dirname, "\\res\\sound\\" + (store.has("all-end-sound") ? store.get("all-end-sound") : "piano") + ".mp3");
724+
if (store.get("all-end-sound") !== i18n.__("custom"))
725+
player.src = path.join(__dirname, "\\res\\sound\\" + (store.has("all-end-sound") ? store.get("all-end-sound") : "piano") + ".mp3");
726+
else if ((!store.has("custom-all-time-end-sound") || store.get("custom-all-time-end-sound") === "")
727+
&& store.get("all-end-sound") === i18n.__("custom"))
728+
player.src = path.join(__dirname, "\\res\\sound\\piano.mp3");
729+
else
730+
player.src = store.get("custom-all-time-end-sound");
719731
}
720732
player.loop = true;
721733
player.play();
@@ -931,7 +943,13 @@ <h3>
931943
//if continueloop then only play once and no other thing
932944
let player = document.createElement('audio');
933945
amplifyMedia(player, amplifierList[store.get("sound")]);
934-
player.src = path.join(__dirname, "\\res\\sound\\" + (store.has("time-end-sound") ? store.get("time-end-sound") : "tick") + ".mp3");
946+
if (store.get("time-end-sound") !== i18n.__("custom"))
947+
player.src = path.join(__dirname, "\\res\\sound\\" + (store.has("time-end-sound") ? store.get("time-end-sound") : "tick") + ".mp3");
948+
else if ((!store.has("custom-work-time-end-sound") || store.get("custom-work-time-end-sound") === "")
949+
&& store.get("time-end-sound") === i18n.__("custom"))
950+
player.src = path.join(__dirname, "\\res\\sound\\tick.mp3");
951+
else
952+
player.src = store.get("custom-work-time-end-sound");
935953
player.loop = false;
936954
player.play();
937955
} else {

0 commit comments

Comments
 (0)