forked from zonuexe/aozora-ruby-parser.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
113 lines (99 loc) · 4.58 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>青空文庫ルビ→pixiv 変換器</title>
<meta name="twitter:card" content="summary">
<meta name="og:title" content="青空文庫ルビ→pixiv 変換器">
<meta name="og:description" content="青空文庫形式のルビをpixiv小説形式に変換">
<meta name="og:image:src" content="http://zonuexe.github.io/aozora-ruby-parser.js/screenshot.png">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style>
textarea { width: 100%; height: 5em; }
#upload-pixiv strong { font-size: x-large }
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.6/ZeroClipboard.min.js"></script>
<script src="./src/aozora-ruby-parser.js"></script>
<script src="./src/aozora-ruby-pixiv.js"></script>
<script src="./src/aozora-ruby-html.js"></script>
<script type="application/javascript">
$(function() {
"use strict";
var clip = new ZeroClipboard(document.getElementById("copy-pixiv"));
var $up = $("#upload-pixiv");
var $pixiv = $("#pixiv-textarea");
var $aozora = $("#aozora-textarea");
var $preview = $("#preview-text");
var pixiv_converter = new AozoraRuby_pixivConverter;
var html_converter = new AozoraRubyHTMLConverter('(', ')');
var preview_empty = $preview.html();
var p = "<ruby><rb>$1</rb><rp>$2</rp><rt>$3</rt><rp>$4</rp></ruby>";
var unescape_ruby = new RegExp(
p.replace(/\$\d/g, "([^<>]+)")
.replace(/</g, "<")
.replace(/>/g, ">"), "g");
var escapeHTML =function(src) {
var escaped = $("<div>").text(src).html();
return escaped.replace(unescape_ruby, p).
replace(/<hr>/g, "<hr>").
replace(/\n/g, "<br>");
};
var updateAozora = function() {
var parser = new AozoraRubyParser($aozora[0].value);
parser.parse();
$pixiv[0].value = parser.render(pixiv_converter);
$preview.html(escapeHTML(parser.render(html_converter)) || preview_empty);
};
var touch_upload = "http://touch.pixiv.net/novel/upload.php";
if ((/Android|iPhone|iPad/g).test(window.navigator.userAgent)) {
$("#upload-pixiv-href").attr("href", touch_upload);
}
if ((/Firefox/.test(window.navigator.userAgent))) {
$('head link:last').after($('<link rel="stylesheet" type="text/css" href="sim2ruby.css">'));
}
updateAozora();
$aozora.on("keyup", updateAozora);
$aozora.focus(function(){ $up.hide(); });
$aozora.focusout(updateAozora);
$pixiv.focus(function(){ $(this).select(); } );
$pixiv.on("click", function(){ $aozora[0].value && $up.show(); });
clip.on("ready", function(){
$("#copy-pixiv").show();
clip.on("copy", function(){ $aozora[0].value && $up.show(); });
});
});</script>
<section>
<div class="page-header">
<h1>青空文庫→pixiv変換 <br><small>青空の<ruby>ルビ<rp>(</rp><rt>ふりがな</rt><rp>)</rp></ruby>をpixiv形式に</small></h1>
</div>
<div class="panel panel-info">
<div class="panel-heading">青空</div>
<div class="panel-body">
<fieldset id="aozora" class="input-group">
<textarea id="aozora-textarea" placeholder="ここに小説を貼り付けてください"></textarea>
</fieldset>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">pixiv</div>
<div class="panel-body">
<fieldset id="pixiv" class="input-group">
<textarea id="pixiv-textarea" placeholder="ここにpixiv記法に変換された小説が表示されます"></textarea>
<button id="copy-pixiv" data-clipboard-target="pixiv-textarea" style="display: none">クリップボードにコピー</button>
</fieldset>
</div>
</div>
</section>
<a href="http://www.pixiv.net/novel/upload.php" id="upload-pixiv-href"><div class="well well-lg" id="upload-pixiv" style="display: none;">
<p><strong>pixiv小説に投稿する</strong></p>
</div></a>
<div class="panel panel-success">
<div class="panel-heading">プレビュー</div>
<div class="panel-body">
<p id="preview-text"><span style="color: #999">ここに<ruby><rb>実際</rb><rp>(</rp><rt>じっさい</rt><rp>)</rp></ruby>の<ruby><rb>表示</rb><rp>(</rp><rt>ひょうじ</rt><rp>)</rp></ruby>がでます</span></p>
</div>
</div>
</section>
<footer>
<p>Fork me! <a href="https://github.com/zonuexe/aozora-ruby-parser.js">zonuexe/aozora-ruby-parser.js</a></p>
</footer>