1Writer カレンダー v3 remotely-save版
作成日: 2025/08/27
code:js
const html = `<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>デイリーノート選択</title>
<style>
body{font-family:sans-serif;display:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;margin:0}
input,button{font-size:18px;padding:10px;margin:10px}
button{cursor:pointer}
</style>
</head>
<body>
<h2>デイリーノートを開く</h2>
<input type="date" id="datePicker" />
<button id="openBtn">開く</button>
<script>
document.addEventListener('DOMContentLoaded', () => {
const dateInput = document.getElementById('datePicker');
const btn = document.getElementById('openBtn');
const today = new Date(Date.now() + 9 * 60 * 60 * 1000).toISOString().split('T')0; dateInput.value = today;
btn.addEventListener('click', openDailyNote);
dateInput.addEventListener('change', openDailyNote);
});
function openDailyNote() {
const date = document.getElementById('datePicker').value;
if (!date) { alert('日付を選択してください'); return; }
// ストレージは相対パス(先頭/なし)、中間フォルダは事前作成しておく
const dir = 'Dropbox/アプリ/remotely-save/private/notes/';
const filePath = dir + date + '.md';
const openURL =
'onewriter://x-callback-url/open?path=' + encodeURIComponent(filePath);
const appendURL =
'onewriter://x-callback-url/append?path=' + encodeURIComponent(filePath) +
'&text=' + encodeURIComponent('') +
'&x-success=' + encodeURIComponent(openURL);
// まず append(なければ作成)、成功後に open へ
window.location.href = appendURL;
}
</script>
</body>
</html>`;
webBrowser.loadHTML(html);