Skip to content

Commit

Permalink
make external title sync
Browse files Browse the repository at this point in the history
  • Loading branch information
RoderickQiu committed Aug 25, 2021
1 parent 3922e30 commit ed48766
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
8 changes: 6 additions & 2 deletions external-title.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
ipc.send("external-title-resize", largerSpanW + 16);
} else turnSmallerResizer();
titleNode.parentNode.removeChild(n);
titleNode.style.width = spanW + 'px'
titleNode.style.width = spanW + 'px';

ipc.send("sync-timer-win-title", { title: titleNode.value, notes: notesNode.value })
}

let notesNode = document.getElementById("notes");
Expand All @@ -75,7 +77,9 @@
ipc.send("external-title-resize", largerSpanW + 16);
} else turnSmallerResizer();
notesNode.parentNode.removeChild(n);
notesNode.style.width = spanW + 'px'
notesNode.style.width = spanW + 'px';

ipc.send("sync-timer-win-title", { title: titleNode.value, notes: notesNode.value })
}

function turnSmallerResizer() {
Expand Down
17 changes: 17 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1849,6 +1849,23 @@ ipcMain.on("open-external-title-win", function (event, message) {
externalTitle(title, notes);
})

ipcMain.on("modify-external-title-win", function (event, message) {
if (externalTitleWin != null)
externalTitleWin.webContents.send('send-title', {
title: message.title,
notes: message.notes
});
})

ipcMain.on("sync-timer-win-title", function (event, message) {
if (win != null && isTimerWin) {
win.webContents.send('sync-title', {
title: message.title,
notes: message.notes
})
}
})

ipcMain.on("external-title-resize", function (event, message) {
if (externalTitleWin != null) {
externalTitleWin.setSize(Math.floor(Number(message)), 84);
Expand Down
16 changes: 14 additions & 2 deletions timer.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,28 @@
</div>
<div id="timer" class="justify-content-center align-content-center text-center">
<input type="text" id="title" class="text-center h4" maxlength="14"
style="transform: translateX(5px); font-size: 0.4rem" />
style="transform: translateX(5px); font-size: 0.4rem" oninput="modifyExternalTitleWin()" />
<a href="javascript:openExternalTitleWin()" id="external" class="work"><i
class="iconfont icon-external-link"></i></a><br />
<input type="text" id="notes" class="text-center small text-muted" maxlength="39"
style="font-size: 0.4rem" /><br id="notes-space" />
style="font-size: 0.4rem" oninput="modifyExternalTitleWin()" /><br id="notes-space" />
<script>
function openExternalTitleWin() {
ipc.send("open-external-title-win", { title: $("#title").val(), notes: $("#notes").val() });
}

function modifyExternalTitleWin() {
ipc.send("modify-external-title-win", { title: $("#title").val(), notes: $("#notes").val() });
}

ipc.on("sync-title", function (event, message) {
$("#title").val(message.title);
$("#notes").val(message.notes);

titleNodeResizer();
notesNodeResizer();
});

$("#external").attr('title', i18n.__('external-title'));
$("#title").attr('title', i18n.__('title-edit-msg'));
$("#notes").attr('title', i18n.__('notes-edit-msg'));
Expand Down

0 comments on commit ed48766

Please sign in to comment.