NarouRefiner

「小説家になろう」を読みやすく設定

当前为 2016-07-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NarouRefiner
  3. // @namespace https://greasyfork.org/ja/users/52455-aosanori8
  4. // @version 0.8
  5. // @description 「小説家になろう」を読みやすく設定
  6. // @author aosanori8
  7. // @require https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.js
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.js
  9. // @match http://ncode.syosetu.com/*
  10. // @match http://novel18.syosetu.com/*
  11. // @license MIT
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15.  
  16. /******/ (function(modules) { // webpackBootstrap
  17. /******/ // The module cache
  18. /******/ var installedModules = {};
  19.  
  20. /******/ // The require function
  21. /******/ function __webpack_require__(moduleId) {
  22.  
  23. /******/ // Check if module is in cache
  24. /******/ if(installedModules[moduleId])
  25. /******/ return installedModules[moduleId].exports;
  26.  
  27. /******/ // Create a new module (and put it into the cache)
  28. /******/ var module = installedModules[moduleId] = {
  29. /******/ exports: {},
  30. /******/ id: moduleId,
  31. /******/ loaded: false
  32. /******/ };
  33.  
  34. /******/ // Execute the module function
  35. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36.  
  37. /******/ // Flag the module as loaded
  38. /******/ module.loaded = true;
  39.  
  40. /******/ // Return the exports of the module
  41. /******/ return module.exports;
  42. /******/ }
  43.  
  44.  
  45. /******/ // expose the modules object (__webpack_modules__)
  46. /******/ __webpack_require__.m = modules;
  47.  
  48. /******/ // expose the module cache
  49. /******/ __webpack_require__.c = installedModules;
  50.  
  51. /******/ // __webpack_public_path__
  52. /******/ __webpack_require__.p = "";
  53.  
  54. /******/ // Load entry module and return exports
  55. /******/ return __webpack_require__(0);
  56. /******/ })
  57. /************************************************************************/
  58. /******/ ([
  59. /* 0 */
  60. /***/ function(module, exports, __webpack_require__) {
  61.  
  62. /// <reference path="./../typings/index.d.ts" />
  63. /// <reference path="./NovelView.d.ts" />
  64. "use strict";
  65. var __extends = (this && this.__extends) || function (d, b) {
  66. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  67. function __() { this.constructor = d; }
  68. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  69. };
  70. var NovelViewWrapper_1 = __webpack_require__(1);
  71. var IndexBoxWrapper_1 = __webpack_require__(4);
  72. var InputSize_1 = __webpack_require__(5);
  73. var InputNumber_1 = __webpack_require__(6);
  74. var FontSelector_1 = __webpack_require__(7);
  75. var WordDirectionSelector_1 = __webpack_require__(9);
  76. var ColorPicker_1 = __webpack_require__(11);
  77. var ExpandableItem_1 = __webpack_require__(12);
  78. var SideMenu_1 = __webpack_require__(13);
  79. var Context_1 = __webpack_require__(14);
  80. var Utils_1 = __webpack_require__(10);
  81. var Constants_1 = __webpack_require__(16);
  82. var pathParts = location.pathname.split("/").filter(Boolean);
  83. if (pathParts.length >= 1) {
  84. var novelCode = pathParts[0], articleNum = pathParts[1];
  85. //////////////////////////////////////////////////////////////////
  86. // LocalStorageからグローバル設定、作品設定を読み込む
  87. //////////////////////////////////////////////////////////////////
  88. var context_1 = new Context_1.default(novelCode, Constants_1.DEFAULT_GLOBAL_SETTINGS, Constants_1.DEFAULT_NOVEL_SETTINGS);
  89. // 標準で用意された全てのカスタムレイアウトを解除する
  90. var $body = $("body");
  91. var $novelColor = $("#novel_color");
  92. var $novelContents = $("#novel_contents");
  93. var $novelSubList = $("dl.novel_sublist2");
  94. for (var _i = 0, _a = Utils_1.range(1, 8); _i < _a.length; _i++) {
  95. var i = _a[_i];
  96. var className = "customlayout" + i;
  97. if ($body.hasClass(className)) {
  98. $body.removeClass(className);
  99. }
  100. if ($novelColor.hasClass(className)) {
  101. $novelColor.removeClass(className);
  102. }
  103. if ($novelContents.hasClass(className)) {
  104. $novelContents.removeClass(className);
  105. }
  106. if ($novelSubList.hasClass(className)) {
  107. $novelSubList.removeClass(className);
  108. }
  109. }
  110. // ナビゲーションのスタイルを変更
  111. $(".novelview_navi").css({
  112. backgroundColor: "#363E44",
  113. color: "#EEE"
  114. });
  115. var Label2 = (function (_super) {
  116. __extends(Label2, _super);
  117. function Label2() {
  118. _super.apply(this, arguments);
  119. }
  120. Label2.prototype.render = function () {
  121. return (React.createElement("div", {style: {
  122. padding: "0 5px",
  123. fontWeight: "bold",
  124. backgroundColor: "#868E94",
  125. color: "#E0E0E0",
  126. marginBottom: "5px"
  127. }}, this.props.children));
  128. };
  129. return Label2;
  130. }(React.Component));
  131. var Spacing = (function (_super) {
  132. __extends(Spacing, _super);
  133. function Spacing() {
  134. _super.apply(this, arguments);
  135. }
  136. Spacing.prototype.render = function () { return (React.createElement("div", {style: { height: this.props.size }})); };
  137. return Spacing;
  138. }(React.Component));
  139. var Spacing1 = (function (_super) {
  140. __extends(Spacing1, _super);
  141. function Spacing1() {
  142. _super.apply(this, arguments);
  143. }
  144. Spacing1.prototype.render = function () { return (React.createElement(Spacing, {size: "10px"})); };
  145. return Spacing1;
  146. }(React.Component));
  147. var Spacing2 = (function (_super) {
  148. __extends(Spacing2, _super);
  149. function Spacing2() {
  150. _super.apply(this, arguments);
  151. }
  152. Spacing2.prototype.render = function () { return (React.createElement(Spacing, {size: "5px"})); };
  153. return Spacing2;
  154. }(React.Component));
  155. if ($("#novel_ex").length > 0) {
  156. //////////////////////////////////////////////////////////////////
  157. // 目次ページ
  158. //////////////////////////////////////////////////////////////////
  159. var indexBoxWrapper_1 = new IndexBoxWrapper_1.default(document.body);
  160. // ==== 設定値の読み込み
  161. var globalSettings = context_1.getGlobalSettings();
  162. var isExpandNaviColor = globalSettings[Constants_1.SETTING_KEY.EXPAND_NAVI.COLOR];
  163. var textColor_1 = globalSettings[Constants_1.SETTING_KEY.TEXT_COLOR];
  164. var backgroundColor_1 = globalSettings[Constants_1.SETTING_KEY.BACKGROUND_COLOR];
  165. // TODO: 次のバージョンで直す
  166. $(document.body).find("#novel_color").css({ "color": textColor_1 });
  167. $(document.body).css({ "background-color": backgroundColor_1 });
  168. // ==== ナビゲーターの構築
  169. var customNavi = document.createElement("div");
  170. ReactDOM.render(React.createElement(ExpandableItem_1.default, {label: "カラー", expand: isExpandNaviColor, onToggle: function (expand) { return context_1.saveGlobalSetting(Constants_1.SETTING_KEY.EXPAND_NAVI.COLOR, expand); }}, React.createElement(Label2, null, "文字色"), React.createElement(ColorPicker_1.default, {color: textColor_1, onChange: function (color) { return $("#novel_color").css({ "color": color }); }, onChangeComplete: function (color) {
  171. indexBoxWrapper_1.changeNovelLayout(color, backgroundColor_1);
  172. // TODO: 次のバージョンで直す
  173. $(document.body).find("#novel_color").css({ "color": textColor_1 });
  174. textColor_1 = color;
  175. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.TEXT_COLOR, color);
  176. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "背景色"), React.createElement(ColorPicker_1.default, {color: backgroundColor_1, onChange: function (color) { return $("body").css({ "background-color": color }); }, onChangeComplete: function (color) {
  177. indexBoxWrapper_1.changeNovelLayout(textColor_1, color);
  178. // TODO: 次のバージョンで直す
  179. $(document.body).css({ "background-color": backgroundColor_1 });
  180. backgroundColor_1 = color;
  181. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.BACKGROUND_COLOR, color);
  182. }})), customNavi);
  183. $(".novelview_navi").prepend(customNavi);
  184. indexBoxWrapper_1.reconstructIndex(context_1);
  185. indexBoxWrapper_1.applyAlreadyReadOnIndex(context_1, backgroundColor_1);
  186. indexBoxWrapper_1.changeNovelLayout(textColor_1, backgroundColor_1);
  187. }
  188. else if ($("#novel_honbun").length > 0) {
  189. //////////////////////////////////////////////////////////////////
  190. // 本文ページ
  191. //////////////////////////////////////////////////////////////////
  192. var novelSubtitle = document.querySelector(".novel_subtitle");
  193. var novelP = document.querySelector("#novel_p");
  194. var novelHonbun = document.querySelector("#novel_honbun");
  195. var novelA = document.querySelector("#novel_a");
  196. var novelViews_1 = [new NovelViewWrapper_1.default(document.body, novelSubtitle, novelP, novelHonbun, novelA)];
  197. // 既読を記録
  198. context_1.saveReadSetting(articleNum, new Date().toString());
  199. // ページの横幅を操作しやすいように設定しておく
  200. $("#container")
  201. .find("#novel_contents, #novel_p, #novel_color")
  202. .css({ "width": "auto" });
  203. // ==== 設定値の読み込み
  204. var globalSettings = context_1.getGlobalSettings();
  205. var isExpandNaviColor = globalSettings[Constants_1.SETTING_KEY.EXPAND_NAVI.COLOR];
  206. var isExpandNaviLayout = globalSettings[Constants_1.SETTING_KEY.EXPAND_NAVI.LAYOUT];
  207. var isExpandNaviFont = globalSettings[Constants_1.SETTING_KEY.EXPAND_NAVI.FONT];
  208. var isExpandNaviTypeSetting = globalSettings[Constants_1.SETTING_KEY.EXPAND_NAVI.TYPESETTING];
  209. var isExpandNaviProportion = globalSettings[Constants_1.SETTING_KEY.EXPAND_NAVI.PROPORTION];
  210. var textColor_2 = globalSettings[Constants_1.SETTING_KEY.TEXT_COLOR];
  211. var backgroundColor_2 = globalSettings[Constants_1.SETTING_KEY.BACKGROUND_COLOR];
  212. var wordDirection_1 = globalSettings[Constants_1.SETTING_KEY.WORD_DIRECTION];
  213. var novelWidth_1 = globalSettings[Constants_1.SETTING_KEY.NOVEL_WIDTH];
  214. var novelHeight_1 = globalSettings[Constants_1.SETTING_KEY.NOVEL_HEIGHT];
  215. var font_1 = globalSettings[Constants_1.SETTING_KEY.FONT];
  216. var fontList = globalSettings[Constants_1.SETTING_KEY.FONT_LIST];
  217. var fontSize_1 = globalSettings[Constants_1.SETTING_KEY.FONT_SIZE];
  218. var fontWeight_1 = globalSettings[Constants_1.SETTING_KEY.FONT_WEIGHT];
  219. var letterSpacing_1 = globalSettings[Constants_1.SETTING_KEY.LETTER_SPACING];
  220. var lineHeight_1 = globalSettings[Constants_1.SETTING_KEY.LINE_HEIGHT];
  221. // let wordSpacing: string = globalSettings[SETTING_KEY.WORD_SPACING];
  222. var kanjiMargin_1 = globalSettings[Constants_1.SETTING_KEY.KANJI_SPACING];
  223. var kanjiSize_1 = globalSettings[Constants_1.SETTING_KEY.KANJI_SIZE];
  224. var katakanaMargin_1 = globalSettings[Constants_1.SETTING_KEY.KATAKANA_SPACING];
  225. var katakanaSize_1 = globalSettings[Constants_1.SETTING_KEY.KATAKANA_SIZE];
  226. var serifMargin_1 = globalSettings[Constants_1.SETTING_KEY.SERIF_SPACING];
  227. var serifSize_1 = globalSettings[Constants_1.SETTING_KEY.SERIF_SIZE];
  228. // サイドメニュー構築
  229. var allowedAddresses = ["ncode.syosetu.com", "novel18.syosetu.com"];
  230. var sideMenu_1;
  231. if (allowedAddresses.indexOf(location.host) >= 0) {
  232. var sideAddress = location.protocol + "//" + location.host + "/" + novelCode;
  233. sideMenu_1 = new SideMenu_1.default(context_1, sideAddress);
  234. document.addEventListener("mousemove", function (event) {
  235. if (event.pageX < 10 && !sideMenu_1.isSideMenuOpened) {
  236. sideMenu_1.showSideMenu(textColor_2, backgroundColor_2);
  237. }
  238. else if (event.pageX > SideMenu_1.default.MENU_SIZE && sideMenu_1.isSideMenuOpened) {
  239. sideMenu_1.closeSideMenu();
  240. }
  241. });
  242. }
  243. // ==== ナビゲーターの構築
  244. var customRelatedNovelContainer = document.createElement("div");
  245. ReactDOM.render(React.createElement("div", null, React.createElement(ExpandableItem_1.default, {label: "カラー", expand: isExpandNaviColor, onToggle: function (expand) { return context_1.saveGlobalSetting(Constants_1.SETTING_KEY.EXPAND_NAVI.COLOR, expand); }}, React.createElement(Label2, null, "文字色"), React.createElement(ColorPicker_1.default, {color: textColor_2, onChange: function (color) {
  246. for (var _i = 0, novelViews_2 = novelViews_1; _i < novelViews_2.length; _i++) {
  247. var novelView = novelViews_2[_i];
  248. novelView.changeNovelLayout(color, backgroundColor_2);
  249. }
  250. }, onChangeComplete: function (color) {
  251. for (var _i = 0, novelViews_3 = novelViews_1; _i < novelViews_3.length; _i++) {
  252. var novelView = novelViews_3[_i];
  253. novelView.changeNovelLayout(color, backgroundColor_2);
  254. }
  255. if (sideMenu_1) {
  256. sideMenu_1.changeNovelLayout(color, backgroundColor_2);
  257. }
  258. textColor_2 = color;
  259. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.TEXT_COLOR, color);
  260. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "背景色"), React.createElement(ColorPicker_1.default, {color: backgroundColor_2, onChange: function (color) {
  261. for (var _i = 0, novelViews_4 = novelViews_1; _i < novelViews_4.length; _i++) {
  262. var novelView = novelViews_4[_i];
  263. novelView.changeNovelLayout(textColor_2, color);
  264. }
  265. }, onChangeComplete: function (color) {
  266. for (var _i = 0, novelViews_5 = novelViews_1; _i < novelViews_5.length; _i++) {
  267. var novelView = novelViews_5[_i];
  268. novelView.changeNovelLayout(textColor_2, color);
  269. }
  270. if (sideMenu_1) {
  271. sideMenu_1.changeNovelLayout(color, backgroundColor_2);
  272. }
  273. backgroundColor_2 = color;
  274. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.BACKGROUND_COLOR, color);
  275. }})), React.createElement(Spacing1, null), React.createElement(ExpandableItem_1.default, {label: "レイアウト", expand: isExpandNaviLayout, onToggle: function (expand) { return context_1.saveGlobalSetting(Constants_1.SETTING_KEY.EXPAND_NAVI.LAYOUT, expand); }}, React.createElement(Label2, null, "字送り・行送り"), React.createElement(WordDirectionSelector_1.default, {wordDirection: wordDirection_1, onChangeWordDirection: function (_wordDirection) {
  276. for (var _i = 0, novelViews_6 = novelViews_1; _i < novelViews_6.length; _i++) {
  277. var novelView = novelViews_6[_i];
  278. novelView.changeWritingMode(_wordDirection, novelHeight_1);
  279. }
  280. wordDirection_1 = _wordDirection;
  281. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.WORD_DIRECTION, _wordDirection);
  282. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "ページ横幅"), React.createElement(InputSize_1.default, {value: novelWidth_1, onChange: function (sizeValue) {
  283. for (var _i = 0, novelViews_7 = novelViews_1; _i < novelViews_7.length; _i++) {
  284. var novelView = novelViews_7[_i];
  285. novelView.changeWidth(sizeValue);
  286. }
  287. novelWidth_1 = sizeValue;
  288. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.NOVEL_WIDTH, sizeValue);
  289. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "ページ縦幅"), React.createElement(InputSize_1.default, {value: novelHeight_1, onChange: function (sizeValue) {
  290. for (var _i = 0, novelViews_8 = novelViews_1; _i < novelViews_8.length; _i++) {
  291. var novelView = novelViews_8[_i];
  292. if ((wordDirection_1).indexOf("vertical") === 0) {
  293. novelView.changeHeight(sizeValue);
  294. }
  295. else {
  296. novelView.changeHeight("auto");
  297. }
  298. }
  299. novelHeight_1 = sizeValue;
  300. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.NOVEL_HEIGHT, sizeValue);
  301. }})), React.createElement(Spacing1, null), React.createElement(ExpandableItem_1.default, {label: "フォント", expand: isExpandNaviFont, onToggle: function (expand) { return context_1.saveGlobalSetting(Constants_1.SETTING_KEY.EXPAND_NAVI.FONT, expand); }}, React.createElement(Label2, null, "書体"), React.createElement(FontSelector_1.default, {font: font_1, fontList: fontList, onChangeFontListener: function (selectedFont) {
  302. for (var _i = 0, novelViews_9 = novelViews_1; _i < novelViews_9.length; _i++) {
  303. var novelView = novelViews_9[_i];
  304. novelView.changeFont(selectedFont);
  305. }
  306. font_1 = selectedFont;
  307. context_1.saveGlobalSetting("font", selectedFont);
  308. }, onChangeFontListListener: function (fontList) {
  309. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.FONT_LIST, fontList);
  310. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "文字サイズ"), React.createElement(InputSize_1.default, {value: fontSize_1, onChange: function (sizeValue) {
  311. for (var _i = 0, novelViews_10 = novelViews_1; _i < novelViews_10.length; _i++) {
  312. var novelView = novelViews_10[_i];
  313. novelView.changeFontSize(sizeValue);
  314. }
  315. fontSize_1 = sizeValue;
  316. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.FONT_SIZE, sizeValue);
  317. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "文字ウェイト"), React.createElement(InputNumber_1.default, {min: 100, max: 1000, step: 100, value: fontWeight_1, onChange: function (sizeValue) {
  318. for (var _i = 0, novelViews_11 = novelViews_1; _i < novelViews_11.length; _i++) {
  319. var novelView = novelViews_11[_i];
  320. novelView.changeFontWeight("" + sizeValue);
  321. }
  322. fontWeight_1 = sizeValue;
  323. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.FONT_WEIGHT, sizeValue);
  324. }})), React.createElement(Spacing1, null), React.createElement(ExpandableItem_1.default, {label: "文字組み", expand: isExpandNaviTypeSetting, onToggle: function (expand) { return context_1.saveGlobalSetting(Constants_1.SETTING_KEY.EXPAND_NAVI.TYPESETTING, expand); }}, React.createElement(Label2, null, "文字間隔"), React.createElement(InputSize_1.default, {value: letterSpacing_1, onChange: function (sizeValue) {
  325. for (var _i = 0, novelViews_12 = novelViews_1; _i < novelViews_12.length; _i++) {
  326. var novelView = novelViews_12[_i];
  327. novelView.changeLetterSpacing(sizeValue);
  328. }
  329. letterSpacing_1 = sizeValue;
  330. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.LETTER_SPACING, sizeValue);
  331. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "行間隔"), React.createElement(InputSize_1.default, {min: 0, max: 500, step: 1, value: lineHeight_1, onChange: function (sizeValue) {
  332. for (var _i = 0, novelViews_13 = novelViews_1; _i < novelViews_13.length; _i++) {
  333. var novelView = novelViews_13[_i];
  334. novelView.changeLineHeight(sizeValue);
  335. }
  336. lineHeight_1 = sizeValue;
  337. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.LINE_HEIGHT, sizeValue);
  338. }})), React.createElement(Spacing1, null), React.createElement(ExpandableItem_1.default, {label: "プロポーション", expand: isExpandNaviProportion, onToggle: function (expand) { return context_1.saveGlobalSetting(Constants_1.SETTING_KEY.EXPAND_NAVI.PROPORTION, expand); }}, React.createElement(Label2, null, "漢字マージン"), React.createElement(InputSize_1.default, {min: 0, max: 200, step: 1, value: kanjiMargin_1, onChange: function (sizeValue) {
  339. for (var _i = 0, novelViews_14 = novelViews_1; _i < novelViews_14.length; _i++) {
  340. var novelView = novelViews_14[_i];
  341. novelView.changeKanjiMargin(sizeValue);
  342. }
  343. kanjiMargin_1 = sizeValue;
  344. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.KANJI_SPACING, sizeValue);
  345. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "漢字サイズ"), React.createElement(InputSize_1.default, {min: 0, max: 200, step: 1, value: kanjiSize_1, onChange: function (sizeValue) {
  346. for (var _i = 0, novelViews_15 = novelViews_1; _i < novelViews_15.length; _i++) {
  347. var novelView = novelViews_15[_i];
  348. novelView.changeKanjiSize(sizeValue);
  349. }
  350. kanjiSize_1 = sizeValue;
  351. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.KANJI_SIZE, sizeValue);
  352. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "カタカナマージン"), React.createElement(InputSize_1.default, {min: 0, max: 200, step: 1, value: katakanaMargin_1, onChange: function (sizeValue) {
  353. for (var _i = 0, novelViews_16 = novelViews_1; _i < novelViews_16.length; _i++) {
  354. var novelView = novelViews_16[_i];
  355. novelView.changeKatakanaMargin(sizeValue);
  356. }
  357. katakanaMargin_1 = sizeValue;
  358. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.KATAKANA_SPACING, sizeValue);
  359. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "カタカナサイズ"), React.createElement(InputSize_1.default, {min: 0, max: 200, step: 1, value: katakanaSize_1, onChange: function (sizeValue) {
  360. for (var _i = 0, novelViews_17 = novelViews_1; _i < novelViews_17.length; _i++) {
  361. var novelView = novelViews_17[_i];
  362. novelView.changeKatakanaSize(sizeValue);
  363. }
  364. katakanaSize_1 = sizeValue;
  365. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.KATAKANA_SIZE, sizeValue);
  366. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "セリフマージン"), React.createElement(InputSize_1.default, {min: 0, max: 200, step: 1, value: serifMargin_1, onChange: function (sizeValue) {
  367. for (var _i = 0, novelViews_18 = novelViews_1; _i < novelViews_18.length; _i++) {
  368. var novelView = novelViews_18[_i];
  369. novelView.changeSerifMargin(sizeValue);
  370. }
  371. serifMargin_1 = sizeValue;
  372. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.SERIF_SPACING, sizeValue);
  373. }}), React.createElement(Spacing2, null), React.createElement(Label2, null, "セリフサイズ"), React.createElement(InputSize_1.default, {min: 0, max: 200, step: 1, value: serifSize_1, onChange: function (sizeValue) {
  374. for (var _i = 0, novelViews_19 = novelViews_1; _i < novelViews_19.length; _i++) {
  375. var novelView = novelViews_19[_i];
  376. novelView.changeSerifSize(sizeValue);
  377. }
  378. serifSize_1 = sizeValue;
  379. context_1.saveGlobalSetting(Constants_1.SETTING_KEY.SERIF_SIZE, sizeValue);
  380. }}))), customRelatedNovelContainer);
  381. $(".novelview_navi").prepend(customRelatedNovelContainer);
  382. // ==== 文字詰め
  383. // ---- 未実装
  384. //////////////////////////////////////////////////////////////////
  385. // 画面レイアウトを一括で変更するための関数
  386. //////////////////////////////////////////////////////////////////
  387. var applyStyle_1 = function (novelView) {
  388. novelView.changeWritingMode(wordDirection_1, novelHeight_1);
  389. novelView.changeWidth(novelWidth_1);
  390. if (wordDirection_1.indexOf("vertical") === 0) {
  391. novelView.changeHeight(novelHeight_1);
  392. }
  393. else {
  394. novelView.changeHeight("auto");
  395. }
  396. novelView.changeFont(font_1);
  397. novelView.changeFontSize(fontSize_1);
  398. novelView.changeFontWeight("" + fontWeight_1);
  399. novelView.changeLetterSpacing(letterSpacing_1);
  400. novelView.changeLineHeight(lineHeight_1);
  401. novelView.changeKanjiMargin(kanjiMargin_1);
  402. novelView.changeKanjiSize(kanjiSize_1);
  403. novelView.changeKatakanaMargin(katakanaMargin_1);
  404. novelView.changeKatakanaSize(katakanaSize_1);
  405. novelView.changeSerifMargin(serifMargin_1);
  406. novelView.changeSerifSize(serifSize_1);
  407. novelView.changeNovelLayout(textColor_2, backgroundColor_2);
  408. };
  409. //////////////////////////////////////////////////////////////////
  410. // 画面レイアウトを適用
  411. //////////////////////////////////////////////////////////////////
  412. for (var _b = 0, novelViews_20 = novelViews_1; _b < novelViews_20.length; _b++) {
  413. var novelView = novelViews_20[_b];
  414. applyStyle_1(novelView);
  415. }
  416. //////////////////////////////////////////////////////////////////
  417. // AutoPagerizeによるページロード時の動作
  418. //////////////////////////////////////////////////////////////////
  419. /**
  420. * AutoPagerizeにより読み込まれるページ
  421. *
  422. * 1. div.novel_bn : 先頭のページ送り
  423. * 2. p.novel_subtitle : タイトル
  424. * 3. div#novel_p.novel_view (optional) : 作者コメント欄
  425. * 4. div#novel_honbun.novel_view : 本文
  426. * 5. div#novel_a.novel_view (optional) : 作者コメント欄
  427. * 6. div.novel_bn : 末尾のページ送り
  428. */
  429. var parseUrl_1 = function (address) {
  430. var urlPaser = document.createElement("a");
  431. urlPaser.href = address;
  432. return urlPaser;
  433. };
  434. var loadedPages_1 = {};
  435. document.body.addEventListener("AutoPagerize_DOMNodeInserted", function (event) {
  436. var targetElement = event.target;
  437. var loadedPageAddress = event.newValue;
  438. var _a = parseUrl_1(loadedPageAddress).pathname.split("/").filter(Boolean), loadedArticleNum = _a[1];
  439. if (!(loadedArticleNum in loadedPages_1)) {
  440. loadedPages_1 = {}; // reset
  441. loadedPages_1[loadedArticleNum] = {};
  442. }
  443. var KEY_TITLE = "novel_subtitle";
  444. var KEY_COMMENT_PREVIOUS = "novel_p";
  445. var KEY_HONBUN = "novel_honbun";
  446. var KEY_COMMENT_AFTER = "novel_a";
  447. var KEY_FEED_PAGE = "novel_bn";
  448. // console.log("Element", event.target, "RequestURL", (event as any).newValue, "ParentNode", (event as any).relatedNode);
  449. if (targetElement.id) {
  450. switch (targetElement.id) {
  451. case KEY_COMMENT_PREVIOUS:
  452. loadedPages_1[loadedArticleNum][KEY_COMMENT_PREVIOUS] = targetElement;
  453. break;
  454. case KEY_HONBUN:
  455. context_1.saveReadSetting(loadedArticleNum, new Date().toString());
  456. loadedPages_1[loadedArticleNum][KEY_HONBUN] = targetElement;
  457. break;
  458. case KEY_COMMENT_AFTER:
  459. loadedPages_1[loadedArticleNum][KEY_COMMENT_AFTER] = targetElement;
  460. break;
  461. }
  462. }
  463. else if (targetElement.className) {
  464. switch (targetElement.className) {
  465. case KEY_TITLE:
  466. loadedPages_1[loadedArticleNum][KEY_TITLE] = targetElement;
  467. break;
  468. case KEY_FEED_PAGE:
  469. var hasLoadedNovelBn = KEY_FEED_PAGE in loadedPages_1[loadedArticleNum];
  470. if (hasLoadedNovelBn) {
  471. var novelSubtitle_1 = loadedPages_1[loadedArticleNum][KEY_TITLE];
  472. var novelP_1 = loadedPages_1[loadedArticleNum][KEY_COMMENT_PREVIOUS];
  473. var novelHonbun_1 = loadedPages_1[loadedArticleNum][KEY_HONBUN];
  474. var novelA_1 = loadedPages_1[loadedArticleNum][KEY_COMMENT_AFTER];
  475. var novelView = new NovelViewWrapper_1.default(document.body, novelSubtitle_1, novelP_1, novelHonbun_1, novelA_1);
  476. novelViews_1.push(novelView);
  477. applyStyle_1(novelView);
  478. }
  479. else {
  480. loadedPages_1[loadedArticleNum][KEY_FEED_PAGE] = targetElement;
  481. }
  482. break;
  483. }
  484. }
  485. }, false);
  486. }
  487. }
  488.  
  489.  
  490. /***/ },
  491. /* 1 */
  492. /***/ function(module, exports, __webpack_require__) {
  493.  
  494. /// <reference path="./../typings/index.d.ts" />
  495. "use strict";
  496. var __extends = (this && this.__extends) || function (d, b) {
  497. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  498. function __() { this.constructor = d; }
  499. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  500. };
  501. var NarouPage_1 = __webpack_require__(2);
  502. /**
  503. * 作品の1話分を包むクラス
  504. *
  505. * 各種レイアウトの操作を受け持つ
  506. */
  507. var NovelViewWrapper = (function (_super) {
  508. __extends(NovelViewWrapper, _super);
  509. function NovelViewWrapper(body, novelSubTitle, novelP, novelView, novelA) {
  510. _super.call(this, body);
  511. this.$novelSubTitle = $(novelSubTitle);
  512. this.$novelP = $(novelP);
  513. this.$novelView = $(novelView);
  514. this.$novelA = $(novelA);
  515. this.$novelP.css({ "margin": "0px", "width": "auto" });
  516. this.$novelView.css({ "margin": "0px", "width": "auto" });
  517. this.$novelA.css({ "margin": "0px", "width": "auto" });
  518. this.$oneNovel = $("<div style=\"margin: 30px auto 50px auto\" />");
  519. this.$novelSubTitle.before(this.$oneNovel);
  520. this.$oneNovel.append(this.$novelSubTitle);
  521. if (this.$novelP.length > 0) {
  522. this.$oneNovel.append(this.$novelP);
  523. }
  524. this.$oneNovel.append(this.$novelView);
  525. if (this.$novelA.length > 0) {
  526. this.$oneNovel.append(this.$novelA);
  527. }
  528. this.isCreatedKanjiContainers = false;
  529. this.isCreatedKatakanaContainers = false;
  530. this.isCreatedSerifContainers = false;
  531. }
  532. NovelViewWrapper.prototype.createStyleSheet = function () {
  533. var styleElement = document.createElement("style");
  534. document.head.appendChild(styleElement);
  535. return styleElement.sheet;
  536. };
  537. NovelViewWrapper.prototype.setupKanjiContainers = function () {
  538. this.isCreatedKanjiContainers = true;
  539. var replacedHtml = "";
  540. this.$novelView.contents().each(function (index, element) {
  541. if (element.nodeName === "#text") {
  542. replacedHtml += element.textContent.replace(NovelViewWrapper.KANJI_PATTERN, "<span class=\"kanji\">$1</span>");
  543. }
  544. else {
  545. replacedHtml += element.outerHTML;
  546. }
  547. });
  548. this.$novelView.html(replacedHtml);
  549. this.kanjiMarginCss = this.createStyleSheet();
  550. this.kanjiSizeCss = this.createStyleSheet();
  551. };
  552. NovelViewWrapper.prototype.setupKatakanaContainers = function () {
  553. this.isCreatedKatakanaContainers = true;
  554. var replacedHtml = "";
  555. this.$novelView.contents().each(function (index, element) {
  556. if (element.nodeName === "#text") {
  557. replacedHtml += element.textContent.replace(NovelViewWrapper.KATAKANA_PATTERN, "<span class=\"katakana\">$1</span>");
  558. }
  559. else {
  560. replacedHtml += element.outerHTML;
  561. }
  562. });
  563. this.$novelView.html(replacedHtml);
  564. this.katakanaMarginCss = this.createStyleSheet();
  565. this.katakanaSizeCss = this.createStyleSheet();
  566. };
  567. NovelViewWrapper.prototype.setupSerifContainers = function () {
  568. this.isCreatedSerifContainers = true;
  569. var replacedHtml = "";
  570. this.$novelView.contents().each(function (index, element) {
  571. if (element.nodeName === "#text") {
  572. replacedHtml += element.textContent.replace(NovelViewWrapper.SERIF_PATTERN, "<span class=\"serif\">$1</span>");
  573. }
  574. else {
  575. replacedHtml += element.outerHTML;
  576. }
  577. });
  578. this.$novelView.html(replacedHtml);
  579. this.serifMarginCss = this.createStyleSheet();
  580. this.serifSizeCss = this.createStyleSheet();
  581. };
  582. NovelViewWrapper.prototype.changeFont = function (font) {
  583. this.$novelSubTitle.css({ "font-family": font });
  584. this.$novelView.css({ "font-family": font });
  585. };
  586. // 文字サイズを変更
  587. NovelViewWrapper.prototype.changeFontSize = function (size) {
  588. this.$novelSubTitle.css({ "font-size": size });
  589. this.$novelP.css({ "font-size": size });
  590. this.$novelView.css({ "font-size": size });
  591. this.$novelA.css({ "font-size": size });
  592. };
  593. NovelViewWrapper.prototype.changeFontWeight = function (weight) {
  594. this.$novelSubTitle.css({ "font-weight": weight });
  595. this.$novelP.css({ "font-weight": weight });
  596. this.$novelView.css({ "font-weight": weight });
  597. this.$novelA.css({ "font-weight": weight });
  598. };
  599. // 行間を変更
  600. NovelViewWrapper.prototype.changeLineHeight = function (height) {
  601. this.$novelSubTitle.css({ "line-height": height });
  602. this.$novelP.css({ "line-height": height });
  603. this.$novelView.css({ "line-height": height });
  604. this.$novelA.css({ "line-height": height });
  605. };
  606. // 字間を変更
  607. NovelViewWrapper.prototype.changeLetterSpacing = function (spacing) {
  608. this.$novelSubTitle.css({ "letter-spacing": spacing });
  609. this.$novelP.css({ "letter-spacing": spacing });
  610. this.$novelView.css({ "letter-spacing": spacing });
  611. this.$novelA.css({ "letter-spacing": spacing });
  612. };
  613. // 単語の間隔を変更
  614. NovelViewWrapper.prototype.changeWordSpacing = function (spacing) {
  615. this.$novelView.css({ "word-spacing": spacing });
  616. this.$novelP.css({ "word-spacing": spacing });
  617. this.$novelSubTitle.css({ "word-spacing": spacing });
  618. this.$novelA.css({ "word-spacing": spacing });
  619. };
  620. // 横幅を変更
  621. NovelViewWrapper.prototype.changeWidth = function (width) {
  622. this.$oneNovel.css({ "width": width });
  623. };
  624. // 縦幅を変更
  625. NovelViewWrapper.prototype.changeHeight = function (height) {
  626. this.$oneNovel.css({ "height": height });
  627. };
  628. NovelViewWrapper.prototype.changeWritingMode = function (wordDirection, novelHeight) {
  629. switch (wordDirection) {
  630. case "horizontal-tb":
  631. {
  632. this.$oneNovel.css({ "writing-mode": wordDirection, "overflow-x": "auto", height: "auto" });
  633. this.$novelP.css({ "writing-mode": wordDirection, "float": "none", "text-align": "bottom", "width": "auto",
  634. "border-bottom": "3px double #999999", "border-right": "none", "border-left": "none" });
  635. this.$novelSubTitle.css({ "writing-mode": wordDirection, "float": "none" });
  636. this.$novelView.css({ "writing-mode": wordDirection, "float": "none" });
  637. this.$novelA.css({ "writing-mode": wordDirection, "float": "none", "text-align": "bottom", "width": "auto",
  638. "border-top": "3px double #999999", "border-right": "none", "border-left": "none" });
  639. }
  640. break;
  641. case "vertical-rl":
  642. {
  643. this.$oneNovel.css({ "writing-mode": wordDirection, "overflow-x": "scroll", height: novelHeight });
  644. this.$novelP.css({ "writing-mode": wordDirection, "float": "right", "text-align": "bottom", "width": "auto",
  645. "border-bottom": "none", "border-right": "none", "border-left": "3px double #999999" });
  646. this.$novelSubTitle.css({ "writing-mode": wordDirection, "float": "right", "text-align": "center" });
  647. this.$novelView.css({ "writing-mode": wordDirection, "float": "right" });
  648. this.$novelA.css({ "writing-mode": wordDirection, "float": "right", "text-align": "bottom", "width": "auto",
  649. "border-top": "none", "border-right": "3px double #999999", "border-left": "none" });
  650. }
  651. break;
  652. case "vertical-lr":
  653. {
  654. this.$oneNovel.css({ "writing-mode": wordDirection, "overflow-x": "scroll", height: novelHeight });
  655. this.$novelP.css({ "writing-mode": wordDirection, "float": "left", "text-align": "bottom", "width": "auto",
  656. "border-bottom": "none", "border-right": "3px double #999999", "border-left": "none" });
  657. this.$novelSubTitle.css({ "writing-mode": wordDirection, "float": "left", "text-align": "center" });
  658. this.$novelView.css({ "writing-mode": wordDirection, "float": "left" });
  659. this.$novelA.css({ "writing-mode": wordDirection, "float": "left", "text-align": "bottom", "width": "auto",
  660. "border-top": "none", "border-right": "none", "border-left": "3px double #999999" });
  661. }
  662. break;
  663. }
  664. };
  665. NovelViewWrapper.prototype.changeKanjiMargin = function (size) {
  666. if (size !== "0px" && !this.isCreatedKanjiContainers) {
  667. this.setupKanjiContainers();
  668. }
  669. if (this.isCreatedKanjiContainers) {
  670. if (this.kanjiMarginCss.rules.length > 0) {
  671. this.kanjiMarginCss.removeRule(this.kanjiMarginCss.rules.length - 1);
  672. }
  673. this.kanjiMarginCss.insertRule(".kanji { margin: " + size + " }", 0);
  674. }
  675. };
  676. NovelViewWrapper.prototype.changeKanjiSize = function (size) {
  677. if (size !== "100%" && !this.isCreatedKanjiContainers) {
  678. this.setupKanjiContainers();
  679. }
  680. if (this.isCreatedKanjiContainers) {
  681. if (this.kanjiSizeCss.rules.length > 0) {
  682. this.kanjiSizeCss.removeRule(this.kanjiSizeCss.rules.length - 1);
  683. }
  684. this.kanjiSizeCss.insertRule(".kanji { font-size: " + size + " }", 0);
  685. }
  686. };
  687. NovelViewWrapper.prototype.changeKatakanaMargin = function (size) {
  688. if (size !== "0px" && !this.isCreatedKatakanaContainers) {
  689. this.setupKatakanaContainers();
  690. }
  691. if (this.isCreatedKatakanaContainers) {
  692. if (this.katakanaMarginCss.rules.length > 0) {
  693. this.katakanaMarginCss.removeRule(this.katakanaMarginCss.rules.length - 1);
  694. }
  695. this.katakanaMarginCss.insertRule(".katakana { margin: " + size + " }", 0);
  696. }
  697. };
  698. NovelViewWrapper.prototype.changeKatakanaSize = function (size) {
  699. if (size !== "100%" && !this.isCreatedKatakanaContainers) {
  700. this.setupKatakanaContainers();
  701. }
  702. if (this.isCreatedKatakanaContainers) {
  703. if (this.katakanaSizeCss.rules.length > 0) {
  704. this.katakanaSizeCss.removeRule(this.katakanaSizeCss.rules.length - 1);
  705. }
  706. this.katakanaSizeCss.insertRule(".katakana { font-size: " + size + " }", 0);
  707. }
  708. };
  709. NovelViewWrapper.prototype.changeSerifMargin = function (size) {
  710. if (size !== "0px" && !this.isCreatedSerifContainers) {
  711. this.setupSerifContainers();
  712. }
  713. if (this.isCreatedSerifContainers) {
  714. if (this.serifMarginCss.rules.length > 0) {
  715. this.serifMarginCss.removeRule(this.serifMarginCss.rules.length - 1);
  716. }
  717. this.serifMarginCss.insertRule(".serif { margin: " + size + " }", 0);
  718. }
  719. };
  720. NovelViewWrapper.prototype.changeSerifSize = function (size) {
  721. if (size !== "100%" && !this.isCreatedSerifContainers) {
  722. this.setupSerifContainers();
  723. }
  724. if (this.isCreatedSerifContainers) {
  725. if (this.serifSizeCss.rules.length > 0) {
  726. this.serifSizeCss.removeRule(this.serifSizeCss.rules.length - 1);
  727. }
  728. this.serifSizeCss.insertRule(".serif { font-size: " + size + " }", 0);
  729. }
  730. };
  731. NovelViewWrapper.prototype.changeNovelLayout = function (textColor, backgroundColor) {
  732. _super.prototype.changeNovelLayout.call(this, textColor, backgroundColor);
  733. $(this.body).find("#novel_color").css({ "color": textColor });
  734. };
  735. NovelViewWrapper.KANJI_PATTERN = /((?:[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DB5\u4E00-\u9FCC\uF900-\uFA6D\uFA70-\uFAD9]|[\uD840-\uD868][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|[\uD86A-\uD86C][\uDC00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D])+)/g;
  736. NovelViewWrapper.SERIF_PATTERN = /(「[^」]{1,1000}」)/g;
  737. NovelViewWrapper.KATAKANA_PATTERN = /([ァ-ンヷヸヹヺヵヶ]+)/g;
  738. return NovelViewWrapper;
  739. }(NarouPage_1.default));
  740. Object.defineProperty(exports, "__esModule", { value: true });
  741. exports.default = NovelViewWrapper;
  742.  
  743.  
  744. /***/ },
  745. /* 2 */
  746. /***/ function(module, exports, __webpack_require__) {
  747.  
  748. "use strict";
  749. var Color_1 = __webpack_require__(3);
  750. var NarouPage = (function () {
  751. function NarouPage(body) {
  752. this.body = body;
  753. }
  754. NarouPage.prototype.changeNovelLayout = function (textColor, backgroundColor) {
  755. var $body = $(this.body);
  756. $body.css({ "background-color": backgroundColor });
  757. $body.css({ "color": textColor });
  758. var hoverColorHSV = Color_1.RGB.fromString(textColor).toHSV().applyContrasts(40);
  759. var hoverColor = hoverColorHSV.toRGB().getColorCode();
  760. $("a")
  761. .css({ color: textColor, textCecoration: "none", outline: "none" })
  762. .hover(function (event) { return $(event.target).css({ color: hoverColor, textCecoration: "none" }); }, function (event) { return $(event.target).css({ color: textColor }); });
  763. };
  764. return NarouPage;
  765. }());
  766. Object.defineProperty(exports, "__esModule", { value: true });
  767. exports.default = NarouPage;
  768.  
  769.  
  770. /***/ },
  771. /* 3 */
  772. /***/ function(module, exports) {
  773.  
  774. /// <reference path="./../typings/index.d.ts" />
  775. "use strict";
  776. var RGB = (function () {
  777. function RGB(red, green, blue) {
  778. this.red = red;
  779. this.green = green;
  780. this.blue = blue;
  781. }
  782. RGB.prototype.toHSV = function () {
  783. var max = Math.max(this.red, this.green, this.blue);
  784. var min = Math.min(this.red, this.green, this.blue);
  785. var h;
  786. if (this.red === this.green && this.green === this.blue) {
  787. h = 0;
  788. }
  789. else if (max === this.red) {
  790. h = HSV.H1 * ((this.green - this.blue) / (max - min));
  791. }
  792. else if (max === this.green) {
  793. h = HSV.H1 * ((this.blue - this.red) / (max - min)) + HSV.H2;
  794. }
  795. else if (max === this.blue) {
  796. h = HSV.H1 * ((this.red - this.green) / (max - min)) + HSV.H4;
  797. }
  798. else {
  799. throw new Error("Internal error.");
  800. }
  801. h %= HSV.H_MAX;
  802. if (h < 0) {
  803. h += HSV.H_MAX;
  804. }
  805. return new HSV(h, (max - min) / max * HSV.SV_MAX, max / RGB.MAX * HSV.SV_MAX);
  806. };
  807. RGB.fromString = function (str) {
  808. if (/^#?[a-f\d]{3,8}$/i.exec(str)) {
  809. if (str.indexOf("#") === 0) {
  810. str = str.substring(1);
  811. }
  812. switch (str.length) {
  813. case 3: {
  814. var r = str.substring(0, 1);
  815. var g = str.substring(1, 2);
  816. var b = str.substring(2, 3);
  817. return new RGB(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16));
  818. }
  819. /* falls through */
  820. case 6: {
  821. var r = str.substring(0, 2);
  822. var g = str.substring(2, 4);
  823. var b = str.substring(4, 6);
  824. return new RGB(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16));
  825. }
  826. /* falls through */
  827. default:
  828. throw new Error("Not supported color code type.");
  829. }
  830. }
  831. else {
  832. return RGB.fromString(RGB.colourNameToHex(str));
  833. }
  834. };
  835. RGB.colourNameToHex = function (colour) {
  836. var colours = {
  837. "aliceblue": "#f0f8ff", "antiquewhite": "#faebd7", "aqua": "#00ffff", "aquamarine": "#7fffd4", "azure": "#f0ffff", "beige": "#f5f5dc",
  838. "bisque": "#ffe4c4", "black": "#000000", "blanchedalmond": "#ffebcd", "blue": "#0000ff", "blueviolet": "#8a2be2", "brown": "#a52a2a",
  839. "burlywood": "#deb887", "cadetblue": "#5f9ea0", "chartreuse": "#7fff00", "chocolate": "#d2691e", "coral": "#ff7f50",
  840. "cornflowerblue": "#6495ed", "cornsilk": "#fff8dc", "crimson": "#dc143c", "cyan": "#00ffff", "darkblue": "#00008b",
  841. "darkcyan": "#008b8b", "darkgoldenrod": "#b8860b", "darkgray": "#a9a9a9", "darkgreen": "#006400", "darkkhaki": "#bdb76b",
  842. "darkmagenta": "#8b008b", "darkolivegreen": "#556b2f", "darkorange": "#ff8c00", "darkorchid": "#9932cc", "darkred": "#8b0000",
  843. "darksalmon": "#e9967a", "darkseagreen": "#8fbc8f", "darkslateblue": "#483d8b", "darkslategray": "#2f4f4f",
  844. "darkturquoise": "#00ced1", "darkviolet": "#9400d3", "deeppink": "#ff1493", "deepskyblue": "#00bfff", "dimgray": "#696969",
  845. "dodgerblue": "#1e90ff", "firebrick": "#b22222", "floralwhite": "#fffaf0", "forestgreen": "#228b22", "fuchsia": "#ff00ff",
  846. "gainsboro": "#dcdcdc", "ghostwhite": "#f8f8ff", "gold": "#ffd700", "goldenrod": "#daa520", "gray": "#808080", "green": "#008000",
  847. "greenyellow": "#adff2f", "honeydew": "#f0fff0", "hotpink": "#ff69b4", "indianred ": "#cd5c5c", "indigo": "#4b0082",
  848. "ivory": "#fffff0", "khaki": "#f0e68c", "lavender": "#e6e6fa", "lavenderblush": "#fff0f5", "lawngreen": "#7cfc00",
  849. "lemonchiffon": "#fffacd", "lightblue": "#add8e6", "lightcoral": "#f08080", "lightcyan": "#e0ffff", "lightgoldenrodyellow": "#fafad2",
  850. "lightgrey": "#d3d3d3", "lightgreen": "#90ee90", "lightpink": "#ffb6c1", "lightsalmon": "#ffa07a", "lightseagreen": "#20b2aa",
  851. "lightskyblue": "#87cefa", "lightslategray": "#778899", "lightsteelblue": "#b0c4de", "lightyellow": "#ffffe0", "lime": "#00ff00",
  852. "limegreen": "#32cd32", "linen": "#faf0e6", "magenta": "#ff00ff", "maroon": "#800000", "mediumaquamarine": "#66cdaa",
  853. "mediumblue": "#0000cd", "mediumorchid": "#ba55d3", "mediumpurple": "#9370d8", "mediumseagreen": "#3cb371",
  854. "mediumslateblue": "#7b68ee", "mediumspringgreen": "#00fa9a", "mediumturquoise": "#48d1cc", "mediumvioletred": "#c71585",
  855. "midnightblue": "#191970", "mintcream": "#f5fffa", "mistyrose": "#ffe4e1", "moccasin": "#ffe4b5", "navajowhite": "#ffdead",
  856. "navy": "#000080", "oldlace": "#fdf5e6", "olive": "#808000", "olivedrab": "#6b8e23", "orange": "#ffa500", "orangered": "#ff4500",
  857. "orchid": "#da70d6", "palegoldenrod": "#eee8aa", "palegreen": "#98fb98", "paleturquoise": "#afeeee", "palevioletred": "#d87093",
  858. "papayawhip": "#ffefd5", "peachpuff": "#ffdab9", "peru": "#cd853f", "pink": "#ffc0cb", "plum": "#dda0dd", "powderblue": "#b0e0e6",
  859. "purple": "#800080", "red": "#ff0000", "rosybrown": "#bc8f8f", "royalblue": "#4169e1", "saddlebrown": "#8b4513", "salmon": "#fa8072",
  860. "sandybrown": "#f4a460", "seagreen": "#2e8b57", "seashell": "#fff5ee", "sienna": "#a0522d", "silver": "#c0c0c0", "skyblue": "#87ceeb",
  861. "slateblue": "#6a5acd", "slategray": "#708090", "snow": "#fffafa", "springgreen": "#00ff7f", "steelblue": "#4682b4", "tan": "#d2b48c",
  862. "teal": "#008080", "thistle": "#d8bfd8", "tomato": "#ff6347", "turquoise": "#40e0d0", "violet": "#ee82ee", "wheat": "#f5deb3",
  863. "white": "#ffffff", "whitesmoke": "#f5f5f5", "yellow": "#ffff00", "yellowgreen": "#9acd32"
  864. };
  865. if (typeof colours[colour.toLowerCase()] !== undefined) {
  866. return colours[colour.toLowerCase()];
  867. }
  868. return false;
  869. };
  870. RGB.prototype.getColorCode = function () {
  871. var r = Math.round(this.red).toString(16);
  872. var g = Math.round(this.green).toString(16);
  873. var b = Math.round(this.blue).toString(16);
  874. switch (r.length) {
  875. case 0:
  876. r = "00";
  877. break;
  878. case 1:
  879. r = "0" + r;
  880. break;
  881. case 2: break;
  882. case 3:
  883. r = "FF";
  884. break;
  885. default: throw new Error("Number format error.");
  886. }
  887. switch (g.length) {
  888. case 0:
  889. g = "00";
  890. break;
  891. case 1:
  892. g = "0" + g;
  893. break;
  894. case 2: break;
  895. case 3:
  896. g = "FF";
  897. break;
  898. default: throw new Error("Number format error.");
  899. }
  900. switch (b.length) {
  901. case 0:
  902. b = "00";
  903. break;
  904. case 1:
  905. b = "0" + b;
  906. break;
  907. case 2: break;
  908. case 3:
  909. b = "FF";
  910. break;
  911. default: throw new Error("Number format error.");
  912. }
  913. return "#" + r + g + b;
  914. };
  915. RGB.prototype.toString = function () {
  916. return "rgb(" + Math.round(this.red) + ", " + Math.round(this.green) + ", " + Math.round(this.blue) + ")";
  917. };
  918. RGB.MIN = 0;
  919. RGB.MAX = 255;
  920. return RGB;
  921. }());
  922. exports.RGB = RGB;
  923. var HSV = (function () {
  924. function HSV(hue, saturation, value) {
  925. this.hue = hue;
  926. this.saturation = saturation;
  927. this.value = value;
  928. }
  929. HSV.prototype.applyContrasts = function (constract) {
  930. if (this.saturation > (HSV.SV_MAX / 2)) {
  931. this.saturation -= constract;
  932. }
  933. else {
  934. this.saturation += constract;
  935. }
  936. if (this.value > (HSV.SV_MAX / 2)) {
  937. this.value -= constract;
  938. }
  939. else {
  940. this.value += constract;
  941. }
  942. return this;
  943. };
  944. HSV.prototype.toRGB = function () {
  945. var hue = this.hue;
  946. var hue2 = hue / (HSV.H_MAX / 6);
  947. var hue3 = Math.floor(hue2);
  948. var max = this.value;
  949. var min = max - ((this.saturation / HSV.SV_MAX) * max);
  950. if (hue3 < 0 || 5 < hue3) {
  951. throw new Error();
  952. }
  953. switch (hue3) {
  954. case 0:
  955. return new RGB(max, (hue / HSV.H1) * (max - min) + min, min);
  956. case 1:
  957. return new RGB(((HSV.H2 - hue) / HSV.H1) * (max - min) + min, max, min);
  958. case 2:
  959. return new RGB(min, max, ((hue - HSV.H2) / HSV.H1) * (max - min) + min);
  960. case 3:
  961. return new RGB(min, ((HSV.H4 - hue) / HSV.H1) * (max - min) + min, max);
  962. case 4:
  963. return new RGB(((hue - HSV.H4) / HSV.H1) * (max - min) + min, min, max);
  964. case 5:
  965. return new RGB(max, min, ((HSV.H6 - hue) / HSV.H1) * (max - min) + min);
  966. }
  967. };
  968. HSV.prototype.toString = function () {
  969. return "hsv(" + Math.round(this.hue) + ", " + Math.round(this.saturation) + ", " + Math.round(this.value) + ")";
  970. };
  971. HSV.H_MAX = 360;
  972. /* 60 */ HSV.H1 = HSV.H_MAX / 6;
  973. /* 120 */ HSV.H2 = HSV.H1 * 2;
  974. /* 240 */ HSV.H4 = HSV.H1 * 4;
  975. /* 360 */ HSV.H6 = HSV.H1 * 6;
  976. HSV.SV_MAX = 255;
  977. return HSV;
  978. }());
  979. exports.HSV = HSV;
  980.  
  981.  
  982. /***/ },
  983. /* 4 */
  984. /***/ function(module, exports, __webpack_require__) {
  985.  
  986. /// <reference path="./../typings/index.d.ts" />
  987. "use strict";
  988. var __extends = (this && this.__extends) || function (d, b) {
  989. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  990. function __() { this.constructor = d; }
  991. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  992. };
  993. var NarouPage_1 = __webpack_require__(2);
  994. var Color_1 = __webpack_require__(3);
  995. var IndexBoxWrapper = (function (_super) {
  996. __extends(IndexBoxWrapper, _super);
  997. function IndexBoxWrapper(body) {
  998. _super.call(this, body.querySelector(".index_box"));
  999. }
  1000. /// 作品の投稿日付をDateにパースする関数
  1001. // static parseDate(dateString: string): Date {
  1002. // const ds = dateString.trim();
  1003. // const yi = ds.indexOf("年");
  1004. // const mi = ds.indexOf("月");
  1005. // const di = ds.indexOf("日");
  1006. // const year = parseInt(ds.substring(0, yi).trim());
  1007. // const month = parseInt(ds.substring(yi + 1, mi).trim()) - 1; // January is zero
  1008. // const day = parseInt(ds.substring(mi + 1, di).trim());
  1009. // return new Date(year, month, day);
  1010. // };
  1011. /// インデックスを折りたためるよう再構築
  1012. IndexBoxWrapper.prototype.reconstructIndex = function (context) {
  1013. var $titleElements = $(this.body).find("div.chapter_title");
  1014. var novelSettings = context.getNovelSettings();
  1015. $titleElements.each(function (index, titleElement) {
  1016. $(titleElement)
  1017. .click(function (event) {
  1018. var $container = $(event.target).next();
  1019. $container.slideToggle(function () {
  1020. novelSettings[index] = ($container.css("display") === "block");
  1021. context.saveNovelSetting();
  1022. });
  1023. });
  1024. // Rearrange the dom structure
  1025. var $articles = $(titleElement).nextUntil("div");
  1026. var $createdContainer = $("<div />", { class: "chapter_container" }).insertAfter(titleElement);
  1027. $articles.appendTo($createdContainer);
  1028. // Remember the states
  1029. $createdContainer.toggle(novelSettings[index]);
  1030. });
  1031. };
  1032. /// 既読の色を変える
  1033. IndexBoxWrapper.prototype.applyAlreadyReadOnIndex = function (context, backgroundColor) {
  1034. var alreadyReadColorHSV = Color_1.RGB.fromString(backgroundColor).toHSV().applyContrasts(10);
  1035. var alreadyReadColor = alreadyReadColorHSV.toRGB().getColorCode();
  1036. var $allNovelIndex = $(this.body).find("dl.novel_sublist2");
  1037. $allNovelIndex.css({ border: "none", "margin": "0px" });
  1038. $allNovelIndex.find("dd.subtitle").css({ padding: "7px 12px 6px 12px", width: "auto" });
  1039. var readSettings = context.getReadSettings();
  1040. // const nowDate = Date.now();
  1041. $allNovelIndex.each(function (index, element) {
  1042. var anchor = $(element).find("dd > a")[0];
  1043. var _a = anchor.pathname.split("/").filter(Boolean), articleNum = _a[1];
  1044. if (articleNum in readSettings) {
  1045. // const lastReadDateString = readSettings[articleNum];
  1046. // ---- 最後に読んだ日より後に更新があった時の処理
  1047. // const articleUpdateDate = parseDate($(element).find("dt.long_update").text());
  1048. // const recentReadDate = new Date(lastReadDateString);
  1049. // recentReadDate.setHours(0);
  1050. // recentReadDate.setMinutes(0);
  1051. // recentReadDate.setSeconds(0);
  1052. // recentReadDate.setMilliseconds(0);
  1053. // if (recentReadDate.getTime() === articleUpdateDate.getTime()) { // 読んだ日と更新日が同じ
  1054. // } else
  1055. // if (recentReadDate.getTime() < articleUpdateDate.getTime()) {
  1056. // }
  1057. $(element).css({ "background-color": alreadyReadColor });
  1058. }
  1059. else {
  1060. $(element).css({ "font-weight": "bold" });
  1061. }
  1062. });
  1063. };
  1064. IndexBoxWrapper.prototype.changeNovelLayout = function (textColor, backgroundColor) {
  1065. _super.prototype.changeNovelLayout.call(this, textColor, backgroundColor);
  1066. var chapterTitleColor = Color_1.RGB.fromString(backgroundColor).toHSV().applyContrasts(20).toRGB().getColorCode();
  1067. var chapterTitleHoverColor = Color_1.RGB.fromString(chapterTitleColor).toHSV().applyContrasts(20).toRGB().getColorCode();
  1068. var $chapterTitles = $(this.body).find("div.chapter_title");
  1069. $chapterTitles.css({
  1070. backgroundColor: chapterTitleColor,
  1071. cursor: "pointer",
  1072. margin: "10px 0 5px 0",
  1073. padding: "18px 13px 13px 13px" });
  1074. $chapterTitles.hover(function (event) { return $(event.target).css({ backgroundColor: chapterTitleHoverColor }); }, function (event) { return $(event.target).css({ backgroundColor: chapterTitleColor }); });
  1075. };
  1076. IndexBoxWrapper.prototype.stretchIndexBoxesForSideMenu = function () {
  1077. // メニュー表示用にスタイルを変更
  1078. $(this.body).css({ width: "auto" });
  1079. var sublist2 = $(this.body).find("dl.novel_sublist2");
  1080. sublist2.css({ margin: "5px 10px" });
  1081. sublist2.find("dd").css({ width: "auto" });
  1082. sublist2.find("dt").css({ width: "auto", display: "none" });
  1083. };
  1084. return IndexBoxWrapper;
  1085. }(NarouPage_1.default));
  1086. Object.defineProperty(exports, "__esModule", { value: true });
  1087. exports.default = IndexBoxWrapper;
  1088.  
  1089.  
  1090. /***/ },
  1091. /* 5 */
  1092. /***/ function(module, exports) {
  1093.  
  1094. /// <reference path="./../../typings/index.d.ts" />
  1095. "use strict";
  1096. var __extends = (this && this.__extends) || function (d, b) {
  1097. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1098. function __() { this.constructor = d; }
  1099. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1100. };
  1101. var sizeUnit = ["%", "px", "pt", "in", "mm", "cm", "em", "rem"];
  1102. var InputSize = (function (_super) {
  1103. __extends(InputSize, _super);
  1104. function InputSize() {
  1105. _super.apply(this, arguments);
  1106. this.defaultProps = {
  1107. min: 0,
  1108. max: 200,
  1109. step: 1,
  1110. value: "",
  1111. unit: "px"
  1112. };
  1113. this.state = {
  1114. sizeValueMin: this.props.min || 1,
  1115. sizeValueMax: this.props.max || 200,
  1116. sizeValueStep: this.props.step || 1,
  1117. sizeValue: this.parseSizeValue(this.props.value),
  1118. sizeUnit: (this.props.unit || this.parseSizeUnit(this.props.value))
  1119. };
  1120. }
  1121. InputSize.prototype.parseSizeValue = function (sizeString) {
  1122. if (typeof sizeString === "number") {
  1123. return sizeString;
  1124. }
  1125. else if (typeof sizeString === "string") {
  1126. var numString = sizeString;
  1127. if (sizeString) {
  1128. for (var _i = 0, sizeUnit_1 = sizeUnit; _i < sizeUnit_1.length; _i++) {
  1129. var unit = sizeUnit_1[_i];
  1130. var index = sizeString.lastIndexOf(unit);
  1131. if (index >= 0) {
  1132. numString = sizeString.substring(0, index);
  1133. }
  1134. }
  1135. }
  1136. return parseFloat(numString) || 0;
  1137. }
  1138. else {
  1139. return 0;
  1140. }
  1141. };
  1142. InputSize.prototype.parseSizeUnit = function (sizeString) {
  1143. if (typeof sizeString === "string") {
  1144. var numString = null;
  1145. if (sizeString) {
  1146. for (var _i = 0, sizeUnit_2 = sizeUnit; _i < sizeUnit_2.length; _i++) {
  1147. var unit = sizeUnit_2[_i];
  1148. var index = sizeString.lastIndexOf(unit);
  1149. if (index >= 0) {
  1150. numString = sizeString.substring(index);
  1151. }
  1152. }
  1153. }
  1154. return (numString || "px");
  1155. }
  1156. else {
  1157. return "px";
  1158. }
  1159. };
  1160. InputSize.prototype.onChangeValue = function (event) {
  1161. var value = parseFloat(event.target.value);
  1162. if (this.props.onChange && value && this.state.sizeUnit) {
  1163. this.props.onChange("" + value + this.state.sizeUnit);
  1164. }
  1165. this.setState({ sizeValue: value });
  1166. };
  1167. InputSize.prototype.onChangeUnit = function (event) {
  1168. var unit = event.target.value;
  1169. if (this.props.onChange && this.state.sizeValue && unit) {
  1170. this.props.onChange("" + this.state.sizeValue + unit);
  1171. }
  1172. this.setState({ sizeUnit: unit });
  1173. };
  1174. InputSize.prototype.createOptionItem = function (unit, index) {
  1175. return (React.createElement("option", {key: index, value: unit}, unit));
  1176. };
  1177. InputSize.prototype.render = function () {
  1178. return (React.createElement("div", null, React.createElement("div", {style: { display: "flex", flexWrap: "nowrap" }}, React.createElement("div", {style: { flex: 1 }}, React.createElement("input", {type: "number", style: { width: "100%" }, min: this.state.sizeValueMin, max: this.state.sizeValueMax, step: this.state.sizeValueStep, onChange: this.onChangeValue.bind(this), value: this.state.sizeValue})), React.createElement("div", {style: { marginLeft: "5px" }}, React.createElement("select", {defaultValue: this.state.sizeUnit, onChange: this.onChangeUnit.bind(this)}, sizeUnit.map(this.createOptionItem)))), React.createElement("input", {type: "range", style: { width: "100%" }, min: this.state.sizeValueMin, max: "" + this.state.sizeValueMax, step: this.state.sizeValueStep, onChange: this.onChangeValue.bind(this), value: this.state.sizeValue})));
  1179. };
  1180. return InputSize;
  1181. }(React.Component));
  1182. Object.defineProperty(exports, "__esModule", { value: true });
  1183. exports.default = InputSize;
  1184.  
  1185.  
  1186. /***/ },
  1187. /* 6 */
  1188. /***/ function(module, exports) {
  1189.  
  1190. /// <reference path="./../../typings/index.d.ts" />
  1191. "use strict";
  1192. var __extends = (this && this.__extends) || function (d, b) {
  1193. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1194. function __() { this.constructor = d; }
  1195. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1196. };
  1197. var InputNumber = (function (_super) {
  1198. __extends(InputNumber, _super);
  1199. function InputNumber() {
  1200. _super.apply(this, arguments);
  1201. this.defaultProps = {
  1202. min: 1,
  1203. max: 200,
  1204. step: 1,
  1205. value: ""
  1206. };
  1207. this.state = {
  1208. sizeValueMin: this.props.min,
  1209. sizeValueMax: this.props.max,
  1210. sizeValueStep: this.props.step,
  1211. sizeValue: this.props.value,
  1212. };
  1213. }
  1214. InputNumber.prototype.onChangeValue = function (event) {
  1215. var value = parseFloat(event.target.value);
  1216. if (this.props.onChange && value) {
  1217. this.props.onChange(value);
  1218. }
  1219. this.setState({ sizeValue: value });
  1220. };
  1221. InputNumber.prototype.render = function () {
  1222. return (React.createElement("div", null, React.createElement("div", {style: { display: "flex", width: "100%" }}, React.createElement("div", {style: { flex: 1 }}, React.createElement("input", {type: "number", style: { width: "100%" }, min: this.state.sizeValueMin, max: this.state.sizeValueMax, step: this.state.sizeValueStep, onChange: this.onChangeValue.bind(this), value: this.state.sizeValue}))), React.createElement("input", {type: "range", style: { width: "100%" }, min: this.state.sizeValueMin, max: this.state.sizeValueMax, step: this.state.sizeValueStep, onChange: this.onChangeValue.bind(this), value: this.state.sizeValue})));
  1223. };
  1224. return InputNumber;
  1225. }(React.Component));
  1226. Object.defineProperty(exports, "__esModule", { value: true });
  1227. exports.default = InputNumber;
  1228.  
  1229.  
  1230. /***/ },
  1231. /* 7 */
  1232. /***/ function(module, exports, __webpack_require__) {
  1233.  
  1234. /// <reference path="./../../typings/index.d.ts" />
  1235. "use strict";
  1236. var __extends = (this && this.__extends) || function (d, b) {
  1237. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1238. function __() { this.constructor = d; }
  1239. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1240. };
  1241. var FontDetector_1 = __webpack_require__(8);
  1242. var FontSelector = (function (_super) {
  1243. __extends(FontSelector, _super);
  1244. function FontSelector(props) {
  1245. _super.call(this, props);
  1246. this.state = {
  1247. inputFont: "",
  1248. selectedFont: this.props.font,
  1249. fontList: this.props.fontList
  1250. };
  1251. this.fontDetector = new FontDetector_1.default(document.body);
  1252. }
  1253. FontSelector.prototype.addFont = function (fontName) {
  1254. var fontList = (this.state.fontList) ? this.state.fontList.concat(fontName) : [fontName];
  1255. this.setState({
  1256. selectedFont: fontName,
  1257. fontList: fontList
  1258. });
  1259. if (this.props.onChangeFontListener) {
  1260. this.props.onChangeFontListener(fontName);
  1261. }
  1262. if (this.props.onChangeFontListListener) {
  1263. this.props.onChangeFontListListener(fontList);
  1264. }
  1265. };
  1266. FontSelector.prototype.onKeyPress = function (event) {
  1267. if (event.which === 13 || event.keyCode === 13) {
  1268. var inputFont = event.target;
  1269. var font = inputFont.value;
  1270. if (this.fontDetector.detect(font)) {
  1271. this.addFont(font);
  1272. this.setState({ inputFont: "" });
  1273. inputFont.value = "";
  1274. return false;
  1275. }
  1276. else {
  1277. return true;
  1278. }
  1279. }
  1280. else {
  1281. return true;
  1282. }
  1283. };
  1284. FontSelector.prototype.onClickAdd = function (event) {
  1285. this.addFont(this.state.selectedFont);
  1286. };
  1287. FontSelector.prototype.onClickRemove = function (event) {
  1288. var _this = this;
  1289. this.setState({
  1290. selectedFont: "",
  1291. fontList: this.state.fontList.filter(function (f) { return f !== _this.state.selectedFont; })
  1292. });
  1293. if (this.props.onChangeFontListener) {
  1294. this.props.onChangeFontListener(this.state.selectedFont);
  1295. }
  1296. if (this.props.onChangeFontListListener) {
  1297. this.props.onChangeFontListListener(this.state.fontList);
  1298. }
  1299. };
  1300. FontSelector.prototype.onInput = function (event) {
  1301. var inputFont = event.target;
  1302. var font = inputFont.value;
  1303. this.setState({ inputFont: font });
  1304. if (this.fontDetector.detect(font)) {
  1305. if (this.props.onChangeFontListener) {
  1306. this.props.onChangeFontListener(font);
  1307. }
  1308. }
  1309. };
  1310. FontSelector.prototype.onChangeSelectFont = function (event) {
  1311. var option = event.target;
  1312. var font = option.value;
  1313. this.setState({ selectedFont: font });
  1314. if (this.props.onChangeFontListener) {
  1315. this.props.onChangeFontListener(font);
  1316. }
  1317. };
  1318. FontSelector.prototype.createOptionItem = function (fontName, index) {
  1319. var isFontEnabled = this.fontDetector.detect(fontName);
  1320. return (React.createElement("option", {key: index, value: fontName, style: {
  1321. paddingLeft: "5px",
  1322. backgroundColor: isFontEnabled ? "#FFD540" : "lightgray",
  1323. fontFamily: fontName
  1324. }}, fontName));
  1325. };
  1326. FontSelector.prototype.render = function () {
  1327. var selectedFont = this.state.selectedFont;
  1328. var isInputFontEnabled = this.fontDetector.detect(this.state.inputFont);
  1329. var isFontSelected = (this.state.fontList.indexOf(selectedFont) >= 0);
  1330. var inputStyle = {
  1331. width: "100%", marginBottom: "3px",
  1332. backgroundColor: (isInputFontEnabled ? "#FFD540" : "white")
  1333. };
  1334. return (React.createElement("div", null, React.createElement("input", {placeholder: this.state.selectedFont, style: inputStyle, onKeyPress: this.onKeyPress.bind(this), onInput: this.onInput.bind(this)}), React.createElement("div", {style: { display: "flex", width: "100%" }}, React.createElement("button", {style: { flex: 1 }, disabled: !isInputFontEnabled, onClick: this.onClickAdd.bind(this)}, "追加"), React.createElement("button", {style: { flex: 1 }, disabled: !isFontSelected, onClick: this.onClickRemove.bind(this)}, "削除")), React.createElement("select", {style: { width: "100%", marginTop: "3px" }, defaultValue: selectedFont, size: "5", onChange: this.onChangeSelectFont.bind(this)}, this.state.fontList.map(this.createOptionItem.bind(this)))));
  1335. };
  1336. return FontSelector;
  1337. }(React.Component));
  1338. Object.defineProperty(exports, "__esModule", { value: true });
  1339. exports.default = FontSelector;
  1340.  
  1341.  
  1342. /***/ },
  1343. /* 8 */
  1344. /***/ function(module, exports) {
  1345.  
  1346. "use strict";
  1347. var FontDetector = (function () {
  1348. function FontDetector(testField) {
  1349. this.testField = testField;
  1350. this.container = document.createElement("span");
  1351. this.container.style.fontSize = FontDetector.testSize;
  1352. this.container.innerHTML = FontDetector.testString;
  1353. this.defaultWidth = {};
  1354. this.defaultHeight = {};
  1355. for (var _i = 0, _a = FontDetector.baseFonts; _i < _a.length; _i++) {
  1356. var font = _a[_i];
  1357. this.container.style.fontFamily = font;
  1358. this.testField.appendChild(this.container);
  1359. this.defaultWidth[font] = this.container.offsetWidth;
  1360. this.defaultHeight[font] = this.container.offsetHeight;
  1361. this.testField.removeChild(this.container);
  1362. }
  1363. }
  1364. /// フォントが有効か確認する
  1365. FontDetector.prototype.detect = function (font) {
  1366. font = font.trim();
  1367. if (!font) {
  1368. return false;
  1369. }
  1370. var detected = false;
  1371. for (var _i = 0, _a = FontDetector.baseFonts; _i < _a.length; _i++) {
  1372. var baseFont = _a[_i];
  1373. this.container.style.fontFamily = font + "," + baseFont;
  1374. this.testField.appendChild(this.container);
  1375. var matched = (this.container.offsetWidth !== this.defaultWidth[baseFont] ||
  1376. this.container.offsetHeight !== this.defaultHeight[baseFont]);
  1377. this.testField.removeChild(this.container);
  1378. detected = detected || matched;
  1379. }
  1380. return detected;
  1381. };
  1382. FontDetector.baseFonts = ["monospace", "sans-serif", "serif"];
  1383. FontDetector.testString = "mmmmmmmmmmlli";
  1384. FontDetector.testSize = "72px";
  1385. return FontDetector;
  1386. }());
  1387. Object.defineProperty(exports, "__esModule", { value: true });
  1388. exports.default = FontDetector;
  1389.  
  1390.  
  1391. /***/ },
  1392. /* 9 */
  1393. /***/ function(module, exports, __webpack_require__) {
  1394.  
  1395. /// <reference path="./../../typings/index.d.ts" />
  1396. "use strict";
  1397. var __extends = (this && this.__extends) || function (d, b) {
  1398. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1399. function __() { this.constructor = d; }
  1400. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1401. };
  1402. var Utils_1 = __webpack_require__(10);
  1403. var HTB = "horizontal-tb";
  1404. var VRL = "vertical-rl";
  1405. var VLR = "vertical-lr";
  1406. var COLOR_SELECTED = "#FFD540";
  1407. var COLOR_HOVERED = "lightgray";
  1408. var COLOR_TRANSPARENT = "rgba(0, 0, 0, 0)";
  1409. var COLOR_NONE = "white";
  1410. var SIZE = 30;
  1411. /// 字送り・行送りを選択するためのコンポーネント
  1412. var WordDirectionSelector = (function (_super) {
  1413. __extends(WordDirectionSelector, _super);
  1414. function WordDirectionSelector() {
  1415. _super.apply(this, arguments);
  1416. this.state = {
  1417. wordDirection: this.props.wordDirection,
  1418. hovered: null
  1419. };
  1420. }
  1421. WordDirectionSelector.prototype.onChangeWordDirection = function (event) {
  1422. var wordDirection = event.target.value;
  1423. this.setState({ wordDirection: wordDirection });
  1424. this.props.onChangeWordDirection(wordDirection);
  1425. };
  1426. WordDirectionSelector.prototype.render = function () {
  1427. var _this = this;
  1428. return (React.createElement("div", null, React.createElement("input", {id: "htb", ref: "htb", type: "radio", style: { display: "none" }, name: "wordDirection", value: HTB, onClick: this.onChangeWordDirection.bind(this)}), React.createElement("label", {htmlFor: "htb", onMouseEnter: function () { _this.setState({ hovered: HTB }); }, onMouseLeave: function () { _this.setState({ hovered: null }); }}, React.createElement("span", {style: {
  1429. width: SIZE + "px", height: SIZE + "px", display: "inline-block",
  1430. backgroundColor: (this.state.wordDirection === HTB) ? COLOR_SELECTED :
  1431. (this.state.hovered && this.state.hovered === HTB) ? COLOR_HOVERED :
  1432. COLOR_NONE
  1433. }}, React.createElement("svg", {width: SIZE, height: SIZE, viewbox: "0 0 " + SIZE + " " + SIZE}, React.createElement("defs", null, React.createElement("path", {id: "line1", d: "M 3 0 h 24"})), React.createElement("g", {style: { stroke: "black", fill: COLOR_TRANSPARENT }}, React.createElement("rect", {width: SIZE, height: SIZE}), Utils_1.range(5, 29, +4).map(function (i) { return React.createElement("use", {xlinkHref: "#line1", y: i, key: i}); }))))), React.createElement("input", {id: "vrl", ref: "vrl", type: "radio", style: { display: "none" }, name: "wordDirection", value: VRL, onClick: this.onChangeWordDirection.bind(this)}), React.createElement("label", {htmlFor: "vrl", onMouseEnter: function () { _this.setState({ hovered: VRL }); }, onMouseLeave: function () { _this.setState({ hovered: null }); }}, React.createElement("span", {style: {
  1434. width: SIZE + "px", height: SIZE + "px", display: "inline-block", marginLeft: "5px",
  1435. backgroundColor: (this.state.wordDirection === VRL) ? COLOR_SELECTED :
  1436. (this.state.hovered && this.state.hovered === VRL) ? COLOR_HOVERED :
  1437. COLOR_NONE
  1438. }}, React.createElement("svg", {width: SIZE, height: SIZE, viewbox: "0 0 " + SIZE + " " + SIZE}, React.createElement("defs", null, React.createElement("path", {id: "line2", d: "M 0 3 v 17"})), React.createElement("g", {style: { stroke: "black", fill: COLOR_TRANSPARENT }}, React.createElement("rect", {width: SIZE, height: SIZE}), Utils_1.range(5, 29, +4).map(function (i) { return React.createElement("use", {xlinkHref: "#line2", x: i, key: i}); }), React.createElement("path", {d: "M 3 24 l 3 3 v -6 l -3 3 h 24"}))))), React.createElement("input", {id: "vlr", ref: "vlr", type: "radio", style: { display: "none" }, name: "wordDirection", value: VLR, onClick: this.onChangeWordDirection.bind(this)}), React.createElement("label", {htmlFor: "vlr", onMouseEnter: function () { _this.setState({ hovered: VLR }); }, onMouseLeave: function () { _this.setState({ hovered: null }); }}, React.createElement("span", {style: {
  1439. width: SIZE + "px", height: SIZE + "px", display: "inline-block", marginLeft: "5px",
  1440. backgroundColor: (this.state.wordDirection === VLR) ? COLOR_SELECTED :
  1441. (this.state.hovered && this.state.hovered === VLR) ? COLOR_HOVERED :
  1442. COLOR_NONE
  1443. }}, React.createElement("svg", {width: SIZE, height: SIZE, viewbox: "0 0 " + SIZE + " " + SIZE}, React.createElement("defs", null, React.createElement("path", {id: "line3", d: "M 0 3 v 17"})), React.createElement("g", {style: { stroke: "black", fill: COLOR_TRANSPARENT }}, React.createElement("rect", {width: SIZE, height: SIZE}), Utils_1.range(5, 29, +4).map(function (i) { return React.createElement("use", {xlinkHref: "#line3", x: i, key: i}); }), React.createElement("path", {d: "M 27 24 l -3 3 v -6 l 3 3 h -24"})))))));
  1444. };
  1445. return WordDirectionSelector;
  1446. }(React.Component));
  1447. Object.defineProperty(exports, "__esModule", { value: true });
  1448. exports.default = WordDirectionSelector;
  1449.  
  1450.  
  1451. /***/ },
  1452. /* 10 */
  1453. /***/ function(module, exports) {
  1454.  
  1455. /// <reference path="./../typings/index.d.ts" />
  1456. "use strict";
  1457. /// Array[]を生成
  1458. function range(from, to, by) {
  1459. var array = [];
  1460. switch (arguments.length) {
  1461. case 1:
  1462. to = from;
  1463. from = 0;
  1464. break;
  1465. case 2:
  1466. if (from < to) {
  1467. by = 1;
  1468. }
  1469. else {
  1470. by = -1;
  1471. }
  1472. break;
  1473. }
  1474. if (by > 0) {
  1475. for (var n = from; n < to; n += by) {
  1476. array.push(n);
  1477. }
  1478. }
  1479. else {
  1480. for (var n = from; n > to; n += by) {
  1481. array.push(n);
  1482. }
  1483. }
  1484. return array;
  1485. }
  1486. exports.range = range;
  1487. ;
  1488.  
  1489.  
  1490. /***/ },
  1491. /* 11 */
  1492. /***/ function(module, exports, __webpack_require__) {
  1493.  
  1494. /// <reference path="./../../typings/index.d.ts" />
  1495. "use strict";
  1496. var __extends = (this && this.__extends) || function (d, b) {
  1497. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1498. function __() { this.constructor = d; }
  1499. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1500. };
  1501. var Color_1 = __webpack_require__(3);
  1502. var ColorPicker = (function (_super) {
  1503. __extends(ColorPicker, _super);
  1504. function ColorPicker(props) {
  1505. _super.call(this, props);
  1506. if (this.props.color) {
  1507. var rgb = Color_1.RGB.fromString(this.props.color);
  1508. var hsv = rgb.toHSV();
  1509. console.log(this.props.color);
  1510. console.log(rgb.toString());
  1511. console.log(hsv.toString());
  1512. this.state = {
  1513. pressH: false,
  1514. pressSV: false,
  1515. color: this.props.color,
  1516. saturation: hsv.saturation,
  1517. value: hsv.value,
  1518. hue: hsv.hue
  1519. };
  1520. }
  1521. else if (this.props.defaultColor) {
  1522. var rgb = Color_1.RGB.fromString(this.props.defaultColor);
  1523. var hsv = rgb.toHSV();
  1524. this.state = {
  1525. pressH: false,
  1526. pressSV: false,
  1527. color: this.props.defaultColor,
  1528. saturation: hsv.saturation,
  1529. value: hsv.value,
  1530. hue: hsv.hue
  1531. };
  1532. }
  1533. else {
  1534. this.state = {
  1535. pressH: false,
  1536. pressSV: false,
  1537. color: this.props.color,
  1538. saturation: 0,
  1539. value: 0,
  1540. hue: 0
  1541. };
  1542. }
  1543. }
  1544. // constructor(props) {
  1545. // super(props);
  1546. // relMouseCoords(event: MouseEvent){
  1547. // var totalOffsetX = 0;
  1548. // var totalOffsetY = 0;
  1549. // var canvasX = 0;
  1550. // var canvasY = 0;
  1551. // var currentElement = this;
  1552. // do{
  1553. // totalOffsetX += currentElement.offsetLeft - currentElement.scrollLeft;
  1554. // totalOffsetY += currentElement.offsetTop - currentElement.scrollTop;
  1555. // }
  1556. // while(currentElement = currentElement.offsetParent)
  1557. // canvasX = event.pageX - totalOffsetX;
  1558. // canvasY = event.pageY - totalOffsetY;
  1559. // return {x:canvasX, y:canvasY}
  1560. // }
  1561. // }
  1562. ColorPicker.prototype.onMouseDownH = function (event) {
  1563. var $div = $(event.target);
  1564. // const offsetX = $div.offset().left;
  1565. var offsetY = $div.offset().top;
  1566. var hue = ((event.pageY - offsetY) / ColorPicker.H_HEIGHT) * Color_1.HSV.H_MAX;
  1567. if (this.props.onChange) {
  1568. var hsv = new Color_1.HSV(hue, this.state.saturation, this.state.value);
  1569. var rgb = hsv.toRGB();
  1570. var colorCode = rgb.getColorCode();
  1571. this.props.onChange(colorCode);
  1572. }
  1573. this.setState({
  1574. pressH: true,
  1575. hue: hue
  1576. });
  1577. };
  1578. ColorPicker.prototype.onMouseMoveH = function (event) {
  1579. if (this.state.pressH) {
  1580. var $div = $(event.target);
  1581. // const offsetX = $div.offset().left;
  1582. var offsetY = $div.offset().top;
  1583. var hue = ((event.pageY - offsetY) / ColorPicker.H_HEIGHT) * Color_1.HSV.H_MAX;
  1584. if (this.props.onChange) {
  1585. var hsv = new Color_1.HSV(hue, this.state.saturation, this.state.value);
  1586. var rgb = hsv.toRGB();
  1587. var colorCode = rgb.getColorCode();
  1588. this.props.onChange(colorCode);
  1589. }
  1590. this.setState({
  1591. hue: hue
  1592. });
  1593. }
  1594. };
  1595. ColorPicker.prototype.onMouseUpH = function (event) {
  1596. var $div = $(event.target);
  1597. // const offsetX = $div.offset().left;
  1598. var offsetY = $div.offset().top;
  1599. var hue = ((event.pageY - offsetY) / ColorPicker.H_HEIGHT) * Color_1.HSV.H_MAX;
  1600. var hsv = new Color_1.HSV(hue, this.state.saturation, this.state.value);
  1601. var rgb = hsv.toRGB();
  1602. var colorCode = rgb.getColorCode();
  1603. if (this.props.onChange) {
  1604. this.props.onChange(colorCode);
  1605. }
  1606. if (this.props.onChangeComplete) {
  1607. this.props.onChangeComplete(colorCode);
  1608. }
  1609. this.setState({
  1610. pressH: false,
  1611. hue: hue
  1612. });
  1613. };
  1614. ColorPicker.prototype.onMouseDownSV = function (event) {
  1615. var $div = $(event.target);
  1616. var offsetX = $div.offset().left;
  1617. var offsetY = $div.offset().top;
  1618. var saturation = ((event.pageX - offsetX) / ColorPicker.SV_HEIGHT) * Color_1.HSV.SV_MAX;
  1619. var value = Color_1.HSV.SV_MAX - ((event.pageY - offsetY) / ColorPicker.SV_HEIGHT) * Color_1.HSV.SV_MAX;
  1620. if (this.props.onChange) {
  1621. var hsv = new Color_1.HSV(this.state.hue, saturation, value);
  1622. var rgb = hsv.toRGB();
  1623. this.props.onChange(rgb.getColorCode());
  1624. }
  1625. this.setState({
  1626. pressSV: true,
  1627. saturation: saturation,
  1628. value: value
  1629. });
  1630. };
  1631. ColorPicker.prototype.onMouseMoveSV = function (event) {
  1632. if (this.state.pressSV) {
  1633. var $div = $(event.target);
  1634. var offsetX = $div.offset().left;
  1635. var offsetY = $div.offset().top;
  1636. var saturation = ((event.pageX - offsetX) / ColorPicker.SV_HEIGHT) * Color_1.HSV.SV_MAX;
  1637. var value = Color_1.HSV.SV_MAX - ((event.pageY - offsetY) / ColorPicker.SV_HEIGHT) * Color_1.HSV.SV_MAX;
  1638. if (this.props.onChange) {
  1639. var hsv = new Color_1.HSV(this.state.hue, saturation, value);
  1640. var rgb = hsv.toRGB();
  1641. this.props.onChange(rgb.getColorCode());
  1642. }
  1643. this.setState({
  1644. saturation: saturation,
  1645. value: value
  1646. });
  1647. }
  1648. };
  1649. ColorPicker.prototype.onMouseUpSV = function (event) {
  1650. var $div = $(event.target);
  1651. var offsetX = $div.offset().left;
  1652. var offsetY = $div.offset().top;
  1653. var saturation = ((event.pageX - offsetX) / ColorPicker.SV_HEIGHT) * Color_1.HSV.SV_MAX;
  1654. var value = Color_1.HSV.SV_MAX - ((event.pageY - offsetY) / ColorPicker.SV_HEIGHT) * Color_1.HSV.SV_MAX;
  1655. var hsv = new Color_1.HSV(this.state.hue, saturation, value);
  1656. var rgb = hsv.toRGB();
  1657. var colorCode = rgb.getColorCode();
  1658. if (this.props.onChange) {
  1659. this.props.onChange(colorCode);
  1660. }
  1661. if (this.props.onChangeComplete) {
  1662. this.props.onChangeComplete(colorCode);
  1663. }
  1664. this.setState({
  1665. pressSV: false,
  1666. saturation: saturation,
  1667. value: value
  1668. });
  1669. };
  1670. ColorPicker.prototype.render = function () {
  1671. var toRightColor = new Color_1.HSV(this.state.hue, Color_1.HSV.SV_MAX, Color_1.HSV.SV_MAX).toRGB().getColorCode();
  1672. return (React.createElement("div", {style: { height: "150px" }}, React.createElement("div", {ref: "colorSelector", style: {
  1673. float: "left", position: "relative",
  1674. width: "" + ColorPicker.SV_WIDTH + "px",
  1675. height: "" + ColorPicker.H_HEIGHT + "px"
  1676. }}, React.createElement("div", {style: {
  1677. position: "absolute",
  1678. width: "100%", height: "100%",
  1679. border: "1px solid gray",
  1680. background: "linear-gradient(to right, #FFF 0%, " + toRightColor + " 100%)"
  1681. }}, React.createElement("div", {style: {
  1682. width: "100%", height: "100%",
  1683. background: "linear-gradient(to top, #000 0%, rgba(255,255,255,0) 100%)"
  1684. }, onMouseDown: this.onMouseDownSV.bind(this), onMouseUp: this.onMouseUpSV.bind(this), onMouseMove: this.onMouseMoveSV.bind(this)})), React.createElement("div", {style: {
  1685. pointerEvents: "none",
  1686. position: "relative",
  1687. left: "" + ((ColorPicker.SV_HEIGHT * (this.state.saturation / Color_1.HSV.SV_MAX)) - 5) + "px",
  1688. top: "" + ((ColorPicker.SV_HEIGHT * ((Color_1.HSV.SV_MAX - this.state.value) / Color_1.HSV.SV_MAX)) - 5) + "px"
  1689. }}, React.createElement("svg", {width: "10", height: "10", viewBox: "0 0 10 10"}, React.createElement("circle", {style: { stroke: "gray", strokeWidth: "2", fill: "rgba(0, 0, 0, 0)" }, cx: "5", cy: "5", r: "3"}), React.createElement("circle", {style: { stroke: "white", strokeWidth: "1", fill: "rgba(0, 0, 0, 0)" }, cx: "5", cy: "5", r: "3"})))), React.createElement("div", {style: {
  1690. position: "relative",
  1691. float: "left",
  1692. marginLeft: "5px",
  1693. width: "15px",
  1694. height: ColorPicker.SV_HEIGHT + "px"
  1695. }, onMouseDown: this.onMouseDownH.bind(this), onMouseUp: this.onMouseUpH.bind(this), onMouseMove: this.onMouseMoveH.bind(this)}, React.createElement("div", {style: {
  1696. position: "absolute",
  1697. width: "15px",
  1698. height: ColorPicker.SV_HEIGHT + "px",
  1699. background: "linear-gradient(to bottom, #f00 0%, #ff0 17%, #0f0 34%, #0ff 50%, #00f 67%, #f0f 84%, #f00 100%)",
  1700. border: "1px solid gray"
  1701. }}), React.createElement("div", {style: {
  1702. pointerEvents: "none",
  1703. position: "absolute",
  1704. backgroundColor: "white",
  1705. borderBottom: "1px solid #000",
  1706. left: "0px",
  1707. top: ((ColorPicker.H_HEIGHT * (this.state.hue / Color_1.HSV.H_MAX)) - 1) + "px",
  1708. width: "15px",
  1709. height: "2px"
  1710. }}))));
  1711. };
  1712. ColorPicker.SV_HEIGHT = 150;
  1713. ColorPicker.SV_WIDTH = 150;
  1714. ColorPicker.H_HEIGHT = 150;
  1715. return ColorPicker;
  1716. }(React.Component));
  1717. Object.defineProperty(exports, "__esModule", { value: true });
  1718. exports.default = ColorPicker;
  1719.  
  1720.  
  1721. /***/ },
  1722. /* 12 */
  1723. /***/ function(module, exports) {
  1724.  
  1725. /// <reference path="./../../typings/index.d.ts" />
  1726. "use strict";
  1727. var __extends = (this && this.__extends) || function (d, b) {
  1728. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1729. function __() { this.constructor = d; }
  1730. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1731. };
  1732. var ExpandableItem = (function (_super) {
  1733. __extends(ExpandableItem, _super);
  1734. function ExpandableItem() {
  1735. _super.apply(this, arguments);
  1736. this.state = {
  1737. expand: this.props.expand,
  1738. containerHeight: this.props.expand ? "auto" : "0px",
  1739. hover: false
  1740. };
  1741. }
  1742. ExpandableItem.prototype.componentDidUpdate = function (prevProps, prevState) {
  1743. // 拡縮対象の縦幅をStateへ記憶している
  1744. // ※ CSS Transition が auto → ?px へのアニメーションに対応していないため
  1745. // componentDidMount() で計測できないのでラベルにカーソルを合わせたタイミングで計測している
  1746. // TODO: 正しい位置で計測がしたい
  1747. if (this.state.hover !== prevState.hover) {
  1748. var measure = ReactDOM.findDOMNode(this.refs.measure);
  1749. this.setState({ containerHeight: measure.clientHeight + "px" });
  1750. }
  1751. };
  1752. ExpandableItem.prototype.onClickLabel = function () {
  1753. var expandNext = !this.state.expand;
  1754. this.setState({ expand: expandNext });
  1755. if (this.props.onToggle) {
  1756. this.props.onToggle(expandNext);
  1757. }
  1758. };
  1759. ExpandableItem.prototype.render = function () {
  1760. var _this = this;
  1761. var labelElement = (React.createElement("div", {className: "navi_label1", onClick: this.onClickLabel.bind(this), onMouseEnter: function () { return _this.setState({ hover: true }); }, onMouseLeave: function () { return _this.setState({ hover: false }); }, style: {
  1762. cursor: "pointer", fontWeight: "bold", padding: "3px 8px",
  1763. color: "#E0E0E0", backgroundColor: this.state.hover ? "#868E94" : "#666E74"
  1764. }}, React.createElement("div", {style: {
  1765. transition: ".3s", float: "left",
  1766. transform: this.state.expand ? "rotate(0deg)" : "rotate(-91deg)"
  1767. }}, "▼"), React.createElement("div", {style: { marginLeft: "20px" }}, this.props.label)));
  1768. var containerElement = (React.createElement("div", {style: {
  1769. backgroundColor: "#C6CED4",
  1770. transition: ".3s",
  1771. overflow: "hidden",
  1772. height: this.state.expand ? this.state.containerHeight : "0px"
  1773. }}, React.createElement("div", {ref: "measure", style: { padding: "5px" }}, this.props.children)));
  1774. return (React.createElement("div", null, labelElement, containerElement));
  1775. };
  1776. return ExpandableItem;
  1777. }(React.Component));
  1778. Object.defineProperty(exports, "__esModule", { value: true });
  1779. exports.default = ExpandableItem;
  1780.  
  1781.  
  1782. /***/ },
  1783. /* 13 */
  1784. /***/ function(module, exports, __webpack_require__) {
  1785.  
  1786. /// <reference path="./../typings/index.d.ts" />
  1787. "use strict";
  1788. var IndexBoxWrapper_1 = __webpack_require__(4);
  1789. var Color_1 = __webpack_require__(3);
  1790. var SideMenu = (function () {
  1791. function SideMenu(context, address) {
  1792. var _this = this;
  1793. this.address = address;
  1794. this.$sideMenu = $("#side_menu");
  1795. if (this.$sideMenu.length <= 0) {
  1796. var menuPosition = "position: fixed; top: 0px; left: -" + SideMenu.MENU_SIZE + "px; width: " + SideMenu.MENU_SIZE + "px;";
  1797. this.$sideMenu = $("\n <div id=\"side_menu\"\n style=\"" + menuPosition + " z-index: 5; overflow-y: scroll\">\n </div>\n ");
  1798. var windowHeight = $(window).height();
  1799. this.$sideMenu.height(windowHeight);
  1800. $(window).resize(function () {
  1801. var windowHeight = $(window).height();
  1802. _this.$sideMenu.height(windowHeight);
  1803. });
  1804. $(document.body).append(this.$sideMenu);
  1805. }
  1806. this.context = context;
  1807. this.isSideMenuOpened = false;
  1808. this.isSidePageLoaded = false;
  1809. }
  1810. SideMenu.prototype.loadSidePage = function (context, textColor, backgroundColor) {
  1811. var _this = this;
  1812. this.isSidePageLoaded = true;
  1813. // const targetUrl = location.protocol + "//" + location.host + "/" + novelCode;
  1814. console.log("Loading menu", this.address);
  1815. var requestMenu = new XMLHttpRequest();
  1816. // requestMenu.onreadystatechange
  1817. requestMenu.addEventListener("load", function (event) {
  1818. var loadPage = requestMenu.responseXML;
  1819. var body = loadPage.querySelector("body");
  1820. _this.indexBoxWrapper = new IndexBoxWrapper_1.default(body);
  1821. _this.$sideMenu.append($(body).find(".index_box"));
  1822. // 標準で用意された全てのカスタムレイアウトを解除する
  1823. // const $body = $(body);
  1824. // const $novelColor = $body.find("#novel_color");
  1825. // const $novelContents = $body.find("#novel_contents");
  1826. // const $novelSubList = $body.find("dl.novel_sublist2");
  1827. // for (const i of range(1, 8)) {
  1828. // const className = "customlayout" + i;
  1829. // if ($body.hasClass(className)) { $body.removeClass(className); }
  1830. // if ($novelColor.hasClass(className)) { $novelColor.removeClass(className); }
  1831. // if ($novelContents.hasClass(className)) { $novelContents.removeClass(className); }
  1832. // if ($novelSubList.hasClass(className)) { $novelSubList.removeClass(className); }
  1833. // }
  1834. _this.indexBoxWrapper.reconstructIndex(context);
  1835. _this.indexBoxWrapper.applyAlreadyReadOnIndex(context, backgroundColor);
  1836. _this.indexBoxWrapper.changeNovelLayout(textColor, backgroundColor);
  1837. _this.indexBoxWrapper.stretchIndexBoxesForSideMenu();
  1838. var sideMenuBorderColor = Color_1.RGB.fromString(backgroundColor).toHSV().applyContrasts(40).toRGB().getColorCode();
  1839. _this.$sideMenu.css({ color: textColor, backgroundColor: backgroundColor, borderRight: "2px solid " + sideMenuBorderColor });
  1840. });
  1841. requestMenu.open("GET", this.address, true);
  1842. requestMenu.responseType = "document";
  1843. requestMenu.send();
  1844. };
  1845. SideMenu.prototype.showSideMenu = function (textColor, backgroundColor) {
  1846. this.isSideMenuOpened = true;
  1847. console.log("SideMenu", textColor, backgroundColor);
  1848. if (!this.isSidePageLoaded) {
  1849. this.loadSidePage(this.context, textColor, backgroundColor);
  1850. }
  1851. else {
  1852. if (this.indexBoxWrapper) {
  1853. this.indexBoxWrapper.applyAlreadyReadOnIndex(this.context, backgroundColor);
  1854. this.indexBoxWrapper.changeNovelLayout(textColor, backgroundColor);
  1855. }
  1856. }
  1857. console.log("Open menu");
  1858. this.$sideMenu.stop().animate({ left: "0" }, SideMenu.MENU_SPEED).addClass("active");
  1859. };
  1860. SideMenu.prototype.closeSideMenu = function () {
  1861. this.isSideMenuOpened = false;
  1862. this.$sideMenu.stop().animate({ left: "-" + SideMenu.MENU_SIZE + "px" }, SideMenu.MENU_SPEED).removeClass("active");
  1863. };
  1864. SideMenu.prototype.changeNovelLayout = function (textColor, backgroundColor) {
  1865. if (this.indexBoxWrapper) {
  1866. this.indexBoxWrapper.applyAlreadyReadOnIndex(this.context, backgroundColor);
  1867. this.indexBoxWrapper.changeNovelLayout(textColor, backgroundColor);
  1868. }
  1869. };
  1870. SideMenu.MENU_SIZE = 350;
  1871. SideMenu.MENU_SPEED = 300;
  1872. return SideMenu;
  1873. }());
  1874. Object.defineProperty(exports, "__esModule", { value: true });
  1875. exports.default = SideMenu;
  1876.  
  1877.  
  1878. /***/ },
  1879. /* 14 */
  1880. /***/ function(module, exports, __webpack_require__) {
  1881.  
  1882. /// <reference path="./../typings/index.d.ts" />
  1883. "use strict";
  1884. var SettingManager_1 = __webpack_require__(15);
  1885. var Context = (function () {
  1886. function Context(novelCode, defaultGlobalSettings, defaultNovelSettings) {
  1887. this.isLoadedGlobalSettings = false;
  1888. this.isLoadedNovelSettings = false;
  1889. this.isLoadedReadSettings = false;
  1890. this.globalSettingManager = new SettingManager_1.default("narou_refiner", defaultGlobalSettings);
  1891. this.novelSettingManager = new SettingManager_1.default("narou_refiner_" + novelCode, defaultNovelSettings);
  1892. this.readSettingManager = new SettingManager_1.default("narou_refiner_read_" + novelCode);
  1893. }
  1894. Context.prototype.getGlobalSettings = function () {
  1895. if (!this.isLoadedGlobalSettings) {
  1896. this.globalSettings = this.globalSettingManager.load();
  1897. }
  1898. return this.globalSettings;
  1899. };
  1900. Context.prototype.readGlobalSetting = function (key) {
  1901. if (!this.isLoadedGlobalSettings) {
  1902. this.globalSettings = this.globalSettingManager.load();
  1903. }
  1904. return this.globalSettings[key];
  1905. };
  1906. Context.prototype.putGlobalSetting = function (key, value) {
  1907. if (!this.isLoadedGlobalSettings) {
  1908. this.globalSettings = this.globalSettingManager.load();
  1909. }
  1910. this.globalSettings[key] = value;
  1911. };
  1912. Context.prototype.saveGlobalSetting = function (key, value) {
  1913. if (arguments.length === 2 && (typeof key === "string" || typeof key === "number")) {
  1914. if (!this.isLoadedGlobalSettings) {
  1915. this.globalSettings = this.globalSettingManager.load();
  1916. }
  1917. this.globalSettings[key] = value;
  1918. this.globalSettingManager.save(this.globalSettings);
  1919. }
  1920. else if (arguments.length === 1 && typeof key === "object") {
  1921. if (!this.isLoadedGlobalSettings) {
  1922. this.globalSettings = this.globalSettingManager.load();
  1923. }
  1924. this.globalSettings = $.extend(true, this.globalSettings, key);
  1925. this.globalSettingManager.save(this.globalSettings);
  1926. }
  1927. else if (arguments.length === 0) {
  1928. if (this.globalSettings) {
  1929. this.globalSettingManager.save(this.globalSettings);
  1930. }
  1931. }
  1932. };
  1933. Context.prototype.getNovelSettings = function () {
  1934. if (!this.isLoadedNovelSettings) {
  1935. this.novelSettings = this.novelSettingManager.load();
  1936. }
  1937. return this.novelSettings;
  1938. };
  1939. Context.prototype.readNovelSetting = function (key) {
  1940. if (!this.isLoadedNovelSettings) {
  1941. this.novelSettings = this.novelSettingManager.load();
  1942. }
  1943. return this.novelSettings[key];
  1944. };
  1945. Context.prototype.putNovelSetting = function (key, value) {
  1946. if (!this.isLoadedNovelSettings) {
  1947. this.novelSettings = this.novelSettingManager.load();
  1948. }
  1949. this.novelSettings[key] = value;
  1950. };
  1951. Context.prototype.saveNovelSetting = function (key, value) {
  1952. if (arguments.length === 2 && (typeof key === "string" || typeof key === "number")) {
  1953. if (!this.isLoadedNovelSettings) {
  1954. this.novelSettings = this.novelSettingManager.load();
  1955. }
  1956. this.novelSettings[key] = value;
  1957. this.novelSettingManager.save(this.novelSettings);
  1958. }
  1959. else if (arguments.length === 1 && typeof key === "object") {
  1960. if (!this.isLoadedNovelSettings) {
  1961. this.novelSettings = this.novelSettingManager.load();
  1962. }
  1963. this.novelSettings = $.extend(true, this.novelSettings, key);
  1964. this.novelSettingManager.save(this.novelSettings);
  1965. }
  1966. else if (arguments.length === 0) {
  1967. if (this.novelSettings) {
  1968. this.novelSettingManager.save(this.novelSettings);
  1969. }
  1970. }
  1971. };
  1972. Context.prototype.getReadSettings = function () {
  1973. if (!this.isLoadedReadSettings) {
  1974. this.readSettings = this.readSettingManager.load();
  1975. }
  1976. return this.readSettings;
  1977. };
  1978. Context.prototype.readReadSetting = function (key) {
  1979. if (!this.isLoadedReadSettings) {
  1980. this.readSettings = this.readSettingManager.load();
  1981. }
  1982. return this.readSettings[key];
  1983. };
  1984. Context.prototype.putReadSetting = function (key, value) {
  1985. if (!this.isLoadedReadSettings) {
  1986. this.readSettings = this.readSettingManager.load();
  1987. }
  1988. this.readSettings[key] = value;
  1989. };
  1990. Context.prototype.saveReadSetting = function (key, value) {
  1991. if (arguments.length === 2 && (typeof key === "string" || typeof key === "number")) {
  1992. if (!this.isLoadedNovelSettings) {
  1993. this.readSettings = this.readSettingManager.load();
  1994. }
  1995. this.readSettings[key] = value;
  1996. this.readSettingManager.save(this.readSettings);
  1997. }
  1998. else if (arguments.length === 1 && typeof key === "object") {
  1999. if (!this.isLoadedNovelSettings) {
  2000. this.readSettings = this.readSettingManager.load();
  2001. }
  2002. this.readSettings = $.extend(true, this.readSettings, key);
  2003. this.readSettingManager.save(this.readSettings);
  2004. }
  2005. else if (arguments.length === 0) {
  2006. if (this.readSettings) {
  2007. this.readSettingManager.save(this.readSettings);
  2008. }
  2009. }
  2010. };
  2011. return Context;
  2012. }());
  2013. Object.defineProperty(exports, "__esModule", { value: true });
  2014. exports.default = Context;
  2015.  
  2016.  
  2017. /***/ },
  2018. /* 15 */
  2019. /***/ function(module, exports) {
  2020.  
  2021. /// <reference path="./../typings/index.d.ts" />
  2022. "use strict";
  2023. /// LocalStorage
  2024. var SettingManager = (function () {
  2025. function SettingManager(key, defaultSettings) {
  2026. if (defaultSettings === void 0) { defaultSettings = {}; }
  2027. this.key = key;
  2028. this.settings = defaultSettings;
  2029. }
  2030. SettingManager.prototype.load = function () {
  2031. return $.extend(true, this.settings, JSON.parse(localStorage.getItem(this.key)));
  2032. };
  2033. SettingManager.prototype.save = function (settings) {
  2034. localStorage.setItem(this.key, JSON.stringify(settings));
  2035. };
  2036. return SettingManager;
  2037. }());
  2038. Object.defineProperty(exports, "__esModule", { value: true });
  2039. exports.default = SettingManager;
  2040.  
  2041.  
  2042. /***/ },
  2043. /* 16 */
  2044. /***/ function(module, exports) {
  2045.  
  2046. "use strict";
  2047. exports.SETTING_KEY = {
  2048. /// ナビゲーションの拡縮
  2049. EXPAND_NAVI: {
  2050. COLOR: "expandNaviColor",
  2051. LAYOUT: "expandNaviLayout",
  2052. FONT: "expandNaviFont",
  2053. TYPESETTING: "expandNaviTypeSetting",
  2054. PROPORTION: "expandNaviProportion"
  2055. },
  2056. /// 基本文字色
  2057. TEXT_COLOR: "textColor",
  2058. /// 基本背景色
  2059. BACKGROUND_COLOR: "backgroundColor",
  2060. /// 字送り・行送り
  2061. WORD_DIRECTION: "wordDirection",
  2062. /// 作品画面の横幅
  2063. NOVEL_WIDTH: "novelWidth",
  2064. /// 作品画面の縦幅
  2065. NOVEL_HEIGHT: "novelHeight",
  2066. /// 表示用のフォント
  2067. FONT: "font",
  2068. /// 選択可能なフォント一覧
  2069. FONT_LIST: "fontList",
  2070. /// フォントサイズ
  2071. FONT_SIZE: "fontSize",
  2072. /// フォントウェイト
  2073. FONT_WEIGHT: "fontWeight",
  2074. /// 文字間隔
  2075. LETTER_SPACING: "letterSpacing",
  2076. /// 行間隔
  2077. LINE_HEIGHT: "lineHeight",
  2078. /// 単語間隔
  2079. WORD_SPACING: "wordSpacing",
  2080. /// 漢字周辺の余白
  2081. KANJI_SPACING: "kanjiSpacing",
  2082. /// 漢字サイズ
  2083. KANJI_SIZE: "kanjiSize",
  2084. /// カタカナ周辺の余白
  2085. KATAKANA_SPACING: "katakanaSpacing",
  2086. /// カタカナサイズ
  2087. KATAKANA_SIZE: "katakanaSize",
  2088. /// セリフ周辺の余白
  2089. SERIF_SPACING: "serifSpacing",
  2090. /// セリフサイズ
  2091. SERIF_SIZE: "serifSize"
  2092. };
  2093. exports.DEFAULT_GLOBAL_SETTINGS = (_a = {},
  2094. _a[exports.SETTING_KEY.EXPAND_NAVI.COLOR] = true,
  2095. _a[exports.SETTING_KEY.EXPAND_NAVI.LAYOUT] = true,
  2096. _a[exports.SETTING_KEY.EXPAND_NAVI.FONT] = true,
  2097. _a[exports.SETTING_KEY.EXPAND_NAVI.TYPESETTING] = false,
  2098. _a[exports.SETTING_KEY.EXPAND_NAVI.PROPORTION] = false,
  2099. _a[exports.SETTING_KEY.TEXT_COLOR] = "#000",
  2100. _a[exports.SETTING_KEY.BACKGROUND_COLOR] = "#FFF",
  2101. _a[exports.SETTING_KEY.WORD_DIRECTION] = "horizontal-tb",
  2102. _a[exports.SETTING_KEY.NOVEL_WIDTH] = "95%",
  2103. _a[exports.SETTING_KEY.NOVEL_HEIGHT] = "100%",
  2104. _a[exports.SETTING_KEY.FONT] = null,
  2105. _a[exports.SETTING_KEY.FONT_LIST] = [],
  2106. _a[exports.SETTING_KEY.FONT_SIZE] = "12px",
  2107. _a[exports.SETTING_KEY.FONT_WEIGHT] = 500,
  2108. _a[exports.SETTING_KEY.LETTER_SPACING] = "",
  2109. // [SETTING_KEY.WORD_SPACING]: "",
  2110. _a[exports.SETTING_KEY.LINE_HEIGHT] = "",
  2111. _a[exports.SETTING_KEY.KANJI_SPACING] = "0px",
  2112. _a[exports.SETTING_KEY.KANJI_SIZE] = "100%",
  2113. _a[exports.SETTING_KEY.KATAKANA_SPACING] = "0px",
  2114. _a[exports.SETTING_KEY.KATAKANA_SIZE] = "100%",
  2115. _a[exports.SETTING_KEY.SERIF_SPACING] = "0px",
  2116. _a[exports.SETTING_KEY.SERIF_SIZE] = "100%",
  2117. _a
  2118. );
  2119. exports.DEFAULT_NOVEL_SETTINGS = {
  2120. toggles: []
  2121. };
  2122. var _a;
  2123.  
  2124.  
  2125. /***/ }
  2126. /******/ ]);