Skip to content

Instantly share code, notes, and snippets.

@niku
Last active September 13, 2016 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niku/ec604092aeebc803c0e72d30ed16dd94 to your computer and use it in GitHub Desktop.
Save niku/ec604092aeebc803c0e72d30ed16dd94 to your computer and use it in GitHub Desktop.
Github Issueテンプレートジェネレータ
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Github Issueテンプレートジェネレータ</title>
</head>
<body>
<label for="title">title<br></label><input id="title" type="text" size="100"><br>
<label for="body">body<br></label><textarea id="body" cols="80" rows="20"></textarea><br>
<label for="result">result<br></label><textarea id="result" cols="80" rows="20" readonly></textarea><br>
<script type="text/javascript">
function generate() {
const title = document.getElementById("title").value;
const body = document.getElementById("body").value;
document.getElementById("result").value = build(title, body);
};
function build(title, body) {
let result = "";
if(title) {
result += "title=" + encodeURIComponent(title);
}
if(body) {
if(result) {
result += "&body=" + encodeURIComponent(body);
} else { // タイトルがない場合
result += "body=" + encodeURIComponent(body);
}
};
return result;
};
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("title").addEventListener("input", generate);
document.getElementById("body").addEventListener("input", generate);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment