Compare commits

...

2 Commits

Author SHA1 Message Date
2a2b24d11a Merge remote-tracking branch 'origin/main' 2025-11-17 11:00:03 +09:00
0d9f8070da initial commit 2025-11-17 10:45:52 +09:00
6 changed files with 205 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
node_modules/
npm-debug.log
package-lock.json

79
app.js Normal file
View File

@@ -0,0 +1,79 @@
/*
* Copyright (C) 2025 Watanabebashi Alpha
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { encode } from './node_modules/@toon-format/toon/dist/index.js';
const jsonInEl = document.getElementById('jsonIn');
const toonOutEl = document.getElementById('toonOut');
const convertBtn = document.getElementById('convertBtn');
const clearBtn = document.getElementById('clearBtn');
const copyBtn = document.getElementById('copyBtn');
let isError = false;
const resetCopyButton = () => {
copyBtn.textContent = 'コピー';
copyBtn.classList.remove('btn-success');
copyBtn.classList.add('btn-outline-secondary');
};
convertBtn.addEventListener('click', () => {
const text = jsonInEl.value.trim();
if (!text) {
toonOutEl.textContent = '';
isError = false;
return;
}
resetCopyButton();
try {
const parsedJson = JSON.parse(text);
const toonData = encode(parsedJson);
toonOutEl.value = toonData;
isError = false;
} catch (e) {
isError = true;
if (e instanceof SyntaxError) {
toonOutEl.value = `JSONの形式が正しくありません`;
} else {
toonOutEl.value = `変換エラー`;
}
}
});
clearBtn.addEventListener('click', () => {
jsonInEl.value = '';
toonOutEl.value = '';
isError = false;
resetCopyButton();
});
copyBtn.addEventListener('click', () => {
const textToCopy = toonOutEl.value;
if (isError || !textToCopy) {
return;
}
navigator.clipboard.writeText(textToCopy).then(() => {
copyBtn.textContent = 'コピーしました!';
copyBtn.classList.remove('btn-outline-secondary');
copyBtn.classList.add('btn-success');
}).catch(err => {
console.error('クリップボードへのコピーに失敗しました: ', err);
});
});

6
css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

102
index.html Normal file
View File

@@ -0,0 +1,102 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSON to TOON Converter</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<style>
.io-box {
height: 400px;
overflow-y: auto;
}
</style>
</head>
<body>
<div class="container mt-4">
<div class="row">
<div class="col-md-10 mx-auto">
<h1 class="mb-4">渡辺橋のJSON → TOON 変換ツール</h1>
<div class="alert alert-info" role="alert">
入力内容はブラウザ内で変換され、サーバーには一切送信されません。
</div>
<div class="mb-3">
<button id="convertBtn" class="btn btn-primary">変換</button>
<button id="clearBtn" class="btn btn-secondary">クリア</button>
</div>
<div class="row">
<div class="col-md-6">
<h3>JSON入力エリア</h3>
<textarea id="jsonIn" class="form-control io-box" placeholder="ここにJSONを入力してください"></textarea>
</div>
<div class="col-md-6">
<div class="position-relative">
<h3 class="d-inline-block">TOON出力エリア</h3>
<button id="copyBtn" class="btn btn-sm btn-outline-secondary position-absolute top-0 end-0" style="margin-top: 0.5rem;">コピー</button>
<textarea id="toonOut" class="form-control io-box" readonly></textarea>
</div>
</div>
</div>
<div class="mt-4 text-center">
<h5 class="mb-3">気に入っていただけたらぜひシェアお願いします!!</h5>
<a id="shareTwitter" href="#" class="btn btn-dark" target="_blank" rel="noopener noreferrer">X(Twitter)</a>
<a id="shareFacebook" href="#" class="btn btn-primary" target="_blank" rel="noopener noreferrer">Facebook</a>
<a id="shareLine" href="#" class="btn text-white" style="background-color: #06C755; border-color: #06C755;" target="_blank" rel="noopener noreferrer">LINE</a>
</div>
<div class="mt-5">
<p>
<a class="btn btn-outline-secondary" data-bs-toggle="collapse" href="#futureFeatures" role="button" aria-expanded="false" aria-controls="futureFeatures">
開発予定の機能
</a>
</p>
<div class="collapse" id="futureFeatures">
<div class="card card-body">
<ul class="mb-0">
<li>TOON形式からJSON形式への逆変換</li>
<li>入力されたJSON/TOONの構文ハイライト</li>
<li>CSV等の形式への対応</li>
<li>節約トークン数の表示</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer mt-5 py-3 bg-light border-top">
<div class="container text-center">
<span class="text-muted"><a href="https://git.watanabebashi.net/Watanabebashi/WB-TOONTools">source code</a> | <a href="https://policy.watanabebashi.net/privacy.html">privacy policy</a></span>
<br>
<span class="text-muted">Proudly running on <a href="https://yodogawa.watanabebashi.net">yodogawa</a></span>
<br>
<span class="text-muted">&copy; 2025 Watanabebashi Alpha, Licensed under AGPLv3</span>
</div>
</footer>
<script type="module" src="app.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const pageUrl = encodeURIComponent(window.location.href);
const pageTitle = encodeURIComponent(document.title);
const twitterShare = document.getElementById('shareTwitter');
twitterShare.href = `https://twitter.com/intent/tweet?url=${pageUrl}&text=${pageTitle}`;
const facebookShare = document.getElementById('shareFacebook');
facebookShare.href = `https://www.facebook.com/sharer/sharer.php?u=${pageUrl}`;
const lineShare = document.getElementById('shareLine');
lineShare.href = `https://social-plugins.line.me/lineit/share?url=${pageUrl}`;
});
</script>
</body>
</html>

7
js/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

8
package.json Normal file
View File

@@ -0,0 +1,8 @@
{
"dependencies": {
"@toon-format/toon": "^1.0.0"
},
"devDependencies": {
"http-server": "^14.1.1"
}
}