Reader.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  1. <template>
  2. <div class="column no-wrap">
  3. <div v-show="toolBarActive" ref="header" class="header">
  4. <div ref="buttons" class="row justify-between no-wrap">
  5. <div>
  6. <button ref="loader" v-ripple class="tool-button" :class="buttonActiveClass('loader')" @click="buttonClick('loader')">
  7. <q-icon name="la la-arrow-left" size="32px" />
  8. <q-tooltip :delay="1500" anchor="bottom right" content-style="font-size: 80%">
  9. {{ rstore.readerActions['loader'] }}
  10. </q-tooltip>
  11. </button>
  12. </div>
  13. <div>
  14. <button v-show="showToolButton['undoAction']" ref="undoAction" v-ripple class="tool-button" :class="buttonActiveClass('undoAction')" @click="buttonClick('undoAction')">
  15. <q-icon name="la la-angle-left" size="32px" />
  16. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  17. {{ rstore.readerActions['undoAction'] }}
  18. </q-tooltip>
  19. </button>
  20. <button v-show="showToolButton['redoAction']" ref="redoAction" v-ripple class="tool-button" :class="buttonActiveClass('redoAction')" @click="buttonClick('redoAction')">
  21. <q-icon name="la la-angle-right" size="32px" />
  22. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  23. {{ rstore.readerActions['redoAction'] }}
  24. </q-tooltip>
  25. </button>
  26. <div class="space"></div>
  27. <button v-show="showToolButton['fullScreen']" ref="fullScreen" v-ripple class="tool-button" :class="buttonActiveClass('fullScreen')" @click="buttonClick('fullScreen')">
  28. <q-icon :name="(fullScreenActive ? 'la la-compress-arrows-alt': 'la la-expand-arrows-alt')" size="32px" />
  29. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  30. {{ rstore.readerActions['fullScreen'] }}
  31. </q-tooltip>
  32. </button>
  33. <button v-show="showToolButton['scrolling']" ref="scrolling" v-ripple class="tool-button" :class="buttonActiveClass('scrolling')" @click="buttonClick('scrolling')">
  34. <q-icon name="la la-film" size="32px" />
  35. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  36. {{ rstore.readerActions['scrolling'] }}
  37. </q-tooltip>
  38. </button>
  39. <button v-show="showToolButton['setPosition']" ref="setPosition" v-ripple class="tool-button" :class="buttonActiveClass('setPosition')" @click="buttonClick('setPosition')">
  40. <q-icon name="la la-angle-double-right" size="32px" />
  41. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  42. {{ rstore.readerActions['setPosition'] }}
  43. </q-tooltip>
  44. </button>
  45. <button v-show="showToolButton['search']" ref="search" v-ripple class="tool-button" :class="buttonActiveClass('search')" @click="buttonClick('search')">
  46. <q-icon name="la la-search" size="32px" />
  47. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  48. {{ rstore.readerActions['search'] }}
  49. </q-tooltip>
  50. </button>
  51. <button v-show="showToolButton['copyText']" ref="copyText" v-ripple class="tool-button" :class="buttonActiveClass('copyText')" @click="buttonClick('copyText')">
  52. <q-icon name="la la-copy" size="32px" />
  53. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  54. {{ rstore.readerActions['copyText'] }}
  55. </q-tooltip>
  56. </button>
  57. <button v-show="showToolButton['convOptions']" ref="convOptions" v-ripple class="tool-button" :class="buttonActiveClass('convOptions')" @click="buttonClick('convOptions')">
  58. <q-icon name="la la-magic" size="32px" />
  59. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  60. {{ rstore.readerActions['convOptions'] }}
  61. </q-tooltip>
  62. </button>
  63. <button v-show="showToolButton['refresh']" ref="refresh" v-ripple class="tool-button" :class="buttonActiveClass('refresh')" @click="buttonClick('refresh')">
  64. <q-icon name="la la-sync" size="32px" :class="{clear: !showRefreshIcon}" />
  65. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  66. {{ rstore.readerActions['refresh'] }}
  67. </q-tooltip>
  68. </button>
  69. <div class="space"></div>
  70. <button v-show="showToolButton['contents']" ref="contents" v-ripple class="tool-button" :class="buttonActiveClass('contents')" @click="buttonClick('contents')">
  71. <q-icon name="la la-list" size="32px" />
  72. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  73. {{ rstore.readerActions['contents'] }}
  74. </q-tooltip>
  75. </button>
  76. <button v-show="mode == 'liberama.top' && showToolButton['libs']" ref="libs" v-ripple class="tool-button" :class="buttonActiveClass('libs')" @click="buttonClick('libs')">
  77. <q-icon name="la la-sitemap" size="32px" />
  78. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  79. {{ rstore.readerActions['libs'] }}
  80. </q-tooltip>
  81. </button>
  82. <button v-show="showToolButton['recentBooks']" ref="recentBooks" v-ripple class="tool-button" :class="buttonActiveClass('recentBooks')" @click="buttonClick('recentBooks')">
  83. <q-icon name="la la-book-open" size="32px" />
  84. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  85. {{ rstore.readerActions['recentBooks'] }}
  86. </q-tooltip>
  87. </button>
  88. </div>
  89. <div>
  90. <button v-show="showToolButton['offlineMode']" ref="offlineMode" v-ripple class="tool-button" :class="buttonActiveClass('offlineMode')" @click="buttonClick('offlineMode')">
  91. <q-icon name="la la-unlink" size="32px" />
  92. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  93. {{ rstore.readerActions['offlineMode'] }}
  94. </q-tooltip>
  95. </button>
  96. <button ref="settings" v-ripple class="tool-button" :class="buttonActiveClass('settings')" @click="buttonClick('settings')">
  97. <q-icon name="la la-cog" size="32px" />
  98. <q-tooltip :delay="1500" anchor="bottom left" content-style="font-size: 80%">
  99. {{ rstore.readerActions['settings'] }}
  100. </q-tooltip>
  101. </button>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="main col row relative-position">
  106. <keep-alive>
  107. <component
  108. :is="activePage"
  109. ref="page"
  110. class="col"
  111. @load-book="loadBook"
  112. @load-file="loadFile"
  113. @book-pos-changed="bookPosChanged"
  114. @do-action="doAction"
  115. ></component>
  116. </keep-alive>
  117. <SetPositionPage v-if="setPositionActive" ref="setPositionPage" @set-position-toggle="setPositionToggle" @book-pos-changed="bookPosChanged"></SetPositionPage>
  118. <SearchPage
  119. v-show="searchActive"
  120. ref="searchPage"
  121. @do-action="doAction"
  122. @book-pos-changed="bookPosChanged"
  123. @start-text-search="startTextSearch"
  124. @stop-text-search="stopTextSearch"
  125. ></SearchPage>
  126. <CopyTextPage v-if="copyTextActive" ref="copyTextPage" @do-action="doAction"></CopyTextPage>
  127. <LibsPage v-show="hidden" ref="libsPage" @load-book="loadBook" @libs-close="libsClose" @do-action="doAction"></LibsPage>
  128. <RecentBooksPage v-show="recentBooksActive" ref="recentBooksPage" @load-book="loadBook" @recent-books-close="recentBooksClose"></RecentBooksPage>
  129. <SettingsPage v-show="settingsActive" ref="settingsPage" @do-action="doAction"></SettingsPage>
  130. <HelpPage v-if="helpActive" ref="helpPage" @do-action="doAction"></HelpPage>
  131. <ClickMapPage v-show="clickMapActive" ref="clickMapPage"></ClickMapPage>
  132. <ContentsPage v-show="contentsActive" ref="contentsPage" :book-pos="bookPos" :is-visible="contentsActive" @do-action="doAction" @book-pos-changed="bookPosChanged"></ContentsPage>
  133. <ServerStorage v-show="hidden" ref="serverStorage"></ServerStorage>
  134. <ReaderDialogs ref="dialogs" @donate-toggle="donateToggle" @version-history-toggle="versionHistoryToggle"></ReaderDialogs>
  135. </div>
  136. </div>
  137. </template>
  138. <script>
  139. //-----------------------------------------------------------------------------
  140. import vueComponent from '../vueComponent.js';
  141. import _ from 'lodash';
  142. import {Buffer} from 'safe-buffer';
  143. import LoaderPage from './LoaderPage/LoaderPage.vue';
  144. import TextPage from './TextPage/TextPage.vue';
  145. import ProgressPage from './ProgressPage/ProgressPage.vue';
  146. import SetPositionPage from './SetPositionPage/SetPositionPage.vue';
  147. import SearchPage from './SearchPage/SearchPage.vue';
  148. import CopyTextPage from './CopyTextPage/CopyTextPage.vue';
  149. import LibsPage from './LibsPage/LibsPage.vue';
  150. import RecentBooksPage from './RecentBooksPage/RecentBooksPage.vue';
  151. import SettingsPage from './SettingsPage/SettingsPage.vue';
  152. import HelpPage from './HelpPage/HelpPage.vue';
  153. import ClickMapPage from './ClickMapPage/ClickMapPage.vue';
  154. import ContentsPage from './ContentsPage/ContentsPage.vue';
  155. import ServerStorage from './ServerStorage/ServerStorage.vue';
  156. import ReaderDialogs from './ReaderDialogs/ReaderDialogs.vue';
  157. import bookManager from './share/bookManager';
  158. import wallpaperStorage from './share/wallpaperStorage';
  159. import dynamicCss from '../../share/dynamicCss';
  160. import rstore from '../../store/modules/reader';
  161. import readerApi from '../../api/reader';
  162. import miscApi from '../../api/misc';
  163. import {versionHistory} from './versionHistory';
  164. import * as utils from '../../share/utils';
  165. const componentOptions = {
  166. components: {
  167. LoaderPage,
  168. TextPage,
  169. ProgressPage,
  170. SetPositionPage,
  171. SearchPage,
  172. CopyTextPage,
  173. LibsPage,
  174. RecentBooksPage,
  175. SettingsPage,
  176. HelpPage,
  177. ClickMapPage,
  178. ContentsPage,
  179. ServerStorage,
  180. ReaderDialogs,
  181. },
  182. watch: {
  183. bookPos: function(newValue) {
  184. if (newValue !== undefined && this.activePage == 'TextPage') {
  185. const textPage = this.$refs.page;
  186. if (textPage.bookPos != newValue) {
  187. textPage.bookPos = newValue;
  188. }
  189. if (!this.scrollingActive)
  190. this.debouncedSetRecentBook(newValue);
  191. else
  192. this.scrollingSetRecentBook(newValue);
  193. }
  194. },
  195. routeParamPos: function(newValue) {
  196. if (!this.paramPosIgnore && newValue !== undefined && newValue != this.bookPos) {
  197. this.bookPos = newValue;
  198. }
  199. },
  200. routeParamUrl: function(newValue) {
  201. if (newValue !== '' && newValue !== this.mostRecentBook().url) {
  202. this.loadBook({url: newValue, bookPos: this.routeParamPos});
  203. }
  204. },
  205. settings: function() {
  206. this.loadSettings();
  207. this.updateRoute();
  208. },
  209. loaderActive: function(newValue) {
  210. (async() => {
  211. const recent = this.mostRecentBook();
  212. if (!newValue && !this.loading && recent && !await bookManager.hasBookParsed(recent)) {
  213. this.loadBook(recent);
  214. }
  215. })();
  216. },
  217. dualPageMode(newValue) {
  218. if (newValue)
  219. this.stopScrolling();
  220. },
  221. },
  222. };
  223. class Reader {
  224. _options = componentOptions;
  225. rstore = {};
  226. loaderActive = false;
  227. fullScreenActive = false;
  228. setPositionActive = false;
  229. searchActive = false;
  230. copyTextActive = false;
  231. convOptionsActive = false;
  232. refreshActive = false;
  233. contentsActive = false;
  234. libsActive = false;
  235. recentBooksActive = false;
  236. offlineModeActive = false;
  237. settingsActive = false;
  238. clickMapActive = false;
  239. helpActive = false;
  240. scrollingActive = false;
  241. progressActive = false;
  242. bookPos = null;
  243. allowUrlParamBookPos = false;
  244. showRefreshIcon = true;
  245. mostRecentBookReactive = null;
  246. showToolButton = {};
  247. actionList = [];
  248. actionCur = -1;
  249. hidden = false;
  250. whatsNewVisible = false;
  251. whatsNewContent = '';
  252. donationVisible = false;
  253. dualPageMode = false;
  254. created() {
  255. this.rstore = rstore;
  256. this.loading = true;
  257. this.commit = this.$store.commit;
  258. this.reader = this.$store.state.reader;
  259. this.config = this.$store.state.config;
  260. this.$root.addEventHook('key', this.keyHook);
  261. this.lastActivePage = false;
  262. this.debouncedSetRecentBook = _.debounce(async(newValue) => {
  263. const recent = this.mostRecentBook();
  264. if (recent && (recent.bookPos != newValue || recent.bookPosSeen !== this.bookPosSeen)) {
  265. await bookManager.setRecentBook(Object.assign({}, recent, {bookPos: newValue, bookPosSeen: this.bookPosSeen}));
  266. if (this.actionCur < 0 || (this.actionCur >= 0 && this.actionList[this.actionCur] != newValue))
  267. this.addAction(newValue);
  268. this.paramPosIgnore = true;
  269. this.updateRoute();
  270. await this.$nextTick();
  271. this.paramPosIgnore = false;
  272. }
  273. }, 500, {maxWait: 5000});
  274. this.scrollingSetRecentBook = _.debounce((newValue) => {
  275. this.debouncedSetRecentBook(newValue);
  276. }, 15000, {maxWait: 20000});
  277. document.addEventListener('fullscreenchange', () => {
  278. this.fullScreenActive = (document.fullscreenElement !== null);
  279. });
  280. this.loadSettings();
  281. }
  282. mounted() {
  283. this.updateHeaderMinWidth();
  284. (async() => {
  285. await wallpaperStorage.init();
  286. await bookManager.init(this.settings);
  287. bookManager.addEventListener(this.bookManagerEvent);
  288. if (this.$root.getRootRoute() == '/reader') {
  289. if (this.routeParamUrl) {
  290. await this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos, force: this.routeParamRefresh});
  291. } else {
  292. this.loaderActive = true;
  293. }
  294. }
  295. await this.$refs.serverStorage.init();
  296. this.checkSetStorageAccessKey();
  297. this.checkActivateDonateHelpPage();
  298. this.loading = false;
  299. //проверим состояние Settings, и обновим, если надо
  300. const newSettings = rstore.addDefaultsToSettings(this.settings);
  301. if (newSettings) {
  302. this.commit('reader/setSettings', newSettings);
  303. }
  304. this.updateRoute();
  305. await this.$refs.dialogs.init();
  306. })();
  307. (async() => {
  308. this.isFirstNeedUpdateNotify = true;
  309. //вечный цикл, запрашиваем периодически конфиг для проверки выхода новой версии читалки
  310. while (true) {// eslint-disable-line no-constant-condition
  311. await this.checkNewVersionAvailable();
  312. await utils.sleep(3600*1000); //каждый час
  313. }
  314. //дальше кода нет
  315. })();
  316. }
  317. loadSettings() {
  318. const settings = this.settings;
  319. this.allowUrlParamBookPos = settings.allowUrlParamBookPos;
  320. this.copyFullText = settings.copyFullText;
  321. this.showClickMapPage = settings.showClickMapPage;
  322. this.clickControl = settings.clickControl;
  323. this.blinkCachedLoad = settings.blinkCachedLoad;
  324. this.showToolButton = settings.showToolButton;
  325. this.enableSitesFilter = settings.enableSitesFilter;
  326. this.showNeedUpdateNotify = settings.showNeedUpdateNotify;
  327. this.splitToPara = settings.splitToPara;
  328. this.djvuQuality = settings.djvuQuality;
  329. this.pdfAsText = settings.pdfAsText;
  330. this.pdfQuality = settings.pdfQuality;
  331. this.dualPageMode = settings.dualPageMode;
  332. this.userWallpapers = settings.userWallpapers;
  333. this.readerActionByKeyCode = utils.userHotKeysObjectSwap(settings.userHotKeys);
  334. this.$root.readerActionByKeyEvent = (event) => {
  335. return this.readerActionByKeyCode[utils.keyEventToCode(event)];
  336. }
  337. this.updateHeaderMinWidth();
  338. this.loadWallpapers();//no await
  339. }
  340. //wallpaper css
  341. async loadWallpapers() {
  342. const wallpaperDataLength = await wallpaperStorage.getLength();
  343. if (wallpaperDataLength !== this.wallpaperDataLength) {//оптимизация
  344. this.wallpaperDataLength = wallpaperDataLength;
  345. let newCss = '';
  346. for (const wp of this.userWallpapers) {
  347. const data = await wallpaperStorage.getData(wp.cssClass);
  348. if (!data) {
  349. //здесь будем восстанавливать данные с сервера
  350. }
  351. if (data) {
  352. newCss += `.${wp.cssClass} {background: url(${data}) center; background-size: 100% 100%;}`;
  353. }
  354. }
  355. dynamicCss.replace('wallpapers', newCss);
  356. }
  357. }
  358. async checkNewVersionAvailable() {
  359. if (!this.checkingNewVersion && this.showNeedUpdateNotify) {
  360. this.checkingNewVersion = true;
  361. try {
  362. await utils.sleep(15*1000); //подождем 15 секунд, чтобы прогрузился ServiceWorker при выходе новой версии
  363. const config = await miscApi.loadConfig();
  364. this.commit('config/setConfig', config);
  365. let againMes = '';
  366. if (this.isFirstNeedUpdateNotify) {
  367. againMes = ' еще один раз';
  368. }
  369. if (this.version != this.clientVersion)
  370. this.$root.notify.info(`Вышла новая версия (v${this.version}) читалки.<br>Пожалуйста, обновите страницу${againMes}.`, 'Обновление');
  371. } catch(e) {
  372. console.error(e);
  373. } finally {
  374. this.checkingNewVersion = false;
  375. }
  376. this.isFirstNeedUpdateNotify = false;
  377. }
  378. }
  379. updateHeaderMinWidth() {
  380. const showButtonCount = Object.values(this.showToolButton).reduce((a, b) => a + (b ? 1 : 0), 0);
  381. if (this.$refs.buttons)
  382. this.$refs.buttons.style.minWidth = 65*showButtonCount + 'px';
  383. (async() => {
  384. await utils.sleep(1000);
  385. if (this.$refs.header)
  386. this.$refs.header.style.overflowX = 'auto';
  387. })();
  388. }
  389. checkSetStorageAccessKey() {
  390. const q = this.$route.query;
  391. if (q['setStorageAccessKey']) {
  392. this.$router.replace(`/reader`);
  393. this.settingsToggle();
  394. this.$nextTick(() => {
  395. this.$refs.settingsPage.enterServerStorageKey(
  396. Buffer.from(utils.fromBase58(q['setStorageAccessKey'])).toString()
  397. );
  398. });
  399. }
  400. }
  401. checkActivateDonateHelpPage() {
  402. const q = this.$route.query;
  403. if (q['donate']) {
  404. this.$router.replace(`/reader`);
  405. this.helpToggle();
  406. this.$nextTick(() => {
  407. this.$refs.helpPage.activateDonateHelpPage();
  408. });
  409. }
  410. }
  411. checkBookPosPercent() {
  412. const q = this.$route.query;
  413. if (q['__pp']) {
  414. let pp = q['__pp'];
  415. if (pp) {
  416. pp = parseFloat(pp) || 0;
  417. const recent = this.mostRecentBook();
  418. (async() => {
  419. await utils.sleep(100);
  420. this.bookPos = Math.floor(recent.textLength*pp/100);
  421. })();
  422. }
  423. }
  424. }
  425. get routeParamPos() {
  426. let result = undefined;
  427. const q = this.$route.query;
  428. if (q['__p']) {
  429. result = q['__p'];
  430. if (Array.isArray(result))
  431. result = result[0];
  432. }
  433. return (result ? parseInt(result, 10) || 0 : result);
  434. }
  435. updateRoute(isNewRoute) {
  436. if (this.loading)
  437. return;
  438. const recent = this.mostRecentBook();
  439. const pos = (recent && recent.bookPos && this.allowUrlParamBookPos ? `__p=${recent.bookPos}&` : '');
  440. const url = (recent ? `url=${recent.url}` : '');
  441. if (isNewRoute)
  442. this.$router.push(`/reader?${pos}${url}`).catch(() => {});
  443. else
  444. this.$router.replace(`/reader?${pos}${url}`).catch(() => {});
  445. }
  446. get mode() {
  447. return this.$store.state.config.mode;
  448. }
  449. get version() {
  450. return this.$store.state.config.version;
  451. }
  452. get clientVersion() {
  453. let v = versionHistory[0].header;
  454. v = v.split(' ')[0];
  455. return v;
  456. }
  457. get routeParamUrl() {
  458. let result = '';
  459. const path = this.$route.fullPath;
  460. const i = path.indexOf('url=');
  461. if (i >= 0) {
  462. result = path.substr(i + 4);
  463. }
  464. return decodeURIComponent(result);
  465. }
  466. get routeParamRefresh() {
  467. const q = this.$route.query;
  468. return !!q['__refresh'];
  469. }
  470. bookPosChanged(event) {
  471. if (event.bookPosSeen !== undefined)
  472. this.bookPosSeen = event.bookPosSeen;
  473. this.bookPos = event.bookPos;
  474. }
  475. async bookManagerEvent(eventName, value) {
  476. if (eventName == 'set-recent' || eventName == 'recent-deleted') {
  477. const oldBook = (this.textPage ? this.textPage.lastBook : null);
  478. const oldPos = (this.textPage ? this.textPage.bookPos : null);
  479. const newBook = bookManager.mostRecentBook();
  480. if (!(oldBook && newBook && oldBook.key == newBook.key)) {
  481. this.mostRecentBook();
  482. }
  483. if (oldBook && newBook) {
  484. if (oldBook.key != newBook.key || oldBook.path != newBook.path) {
  485. this.loadingBook = true;
  486. try {
  487. await this.loadBook(newBook);
  488. } finally {
  489. this.loadingBook = false;
  490. }
  491. } else if (oldPos != newBook.bookPos) {
  492. while (this.loadingBook) await utils.sleep(100);
  493. this.bookPosChanged({bookPos: newBook.bookPos});
  494. }
  495. }
  496. }
  497. if (eventName == 'recent-changed') {
  498. if (this.recentBooksActive) {
  499. await this.$refs.recentBooksPage.updateTableData();
  500. }
  501. //сохранение в serverStorage
  502. if (value) {
  503. await utils.sleep(500);
  504. await this.$refs.serverStorage.saveRecent(value);
  505. }
  506. }
  507. }
  508. get toolBarActive() {
  509. return this.reader.toolBarActive;
  510. }
  511. mostRecentBook() {
  512. const result = bookManager.mostRecentBook();
  513. this.mostRecentBookReactive = result;
  514. return result;
  515. }
  516. get settings() {
  517. return this.$store.state.reader.settings;
  518. }
  519. addAction(pos) {
  520. let a = this.actionList;
  521. if (!a.length || a[a.length - 1] != pos) {
  522. a.push(pos);
  523. if (a.length > 20)
  524. a.shift();
  525. this.actionCur = a.length - 1;
  526. }
  527. }
  528. toolBarToggle() {
  529. this.commit('reader/setToolBarActive', !this.toolBarActive);
  530. this.$root.eventHook('resize');
  531. }
  532. fullScreenToggle() {
  533. this.fullScreenActive = !this.fullScreenActive;
  534. if (this.fullScreenActive) {
  535. this.$q.fullscreen.request();
  536. } else {
  537. this.$q.fullscreen.exit();
  538. }
  539. }
  540. closeAllWindows() {
  541. this.setPositionActive = false;
  542. this.copyTextActive = false;
  543. this.recentBooksActive = false;
  544. this.settingsActive = false;
  545. this.stopScrolling();
  546. this.stopSearch();
  547. this.helpActive = false;
  548. this.contentsActive = false;
  549. }
  550. loaderToggle() {
  551. this.loaderActive = !this.loaderActive;
  552. if (this.loaderActive) {
  553. this.closeAllWindows();
  554. }
  555. }
  556. setPositionToggle() {
  557. this.setPositionActive = !this.setPositionActive;
  558. const page = this.$refs.page;
  559. if (this.setPositionActive && this.activePage == 'TextPage' && page.parsed) {
  560. this.closeAllWindows();
  561. this.setPositionActive = true;
  562. this.$nextTick(() => {
  563. const recent = this.mostRecentBook();
  564. this.$refs.setPositionPage.init(recent.bookPos, recent.textLength - 1);
  565. });
  566. } else {
  567. this.setPositionActive = false;
  568. }
  569. }
  570. stopScrolling() {
  571. if (this.scrollingActive)
  572. this.scrollingToggle();
  573. }
  574. scrollingToggle() {
  575. this.scrollingActive = !this.scrollingActive;
  576. if (this.activePage == 'TextPage') {
  577. const page = this.$refs.page;
  578. if (this.scrollingActive) {
  579. page.startTextScrolling();
  580. } else {
  581. page.stopTextScrolling();
  582. }
  583. }
  584. if (!this.scrollingActive) {
  585. this.scrollingSetRecentBook.flush();
  586. }
  587. }
  588. stopSearch() {
  589. if (this.searchActive)
  590. this.searchToggle();
  591. }
  592. startTextSearch(opts) {
  593. if (this.activePage == 'TextPage')
  594. this.$refs.page.startSearch(opts.needle);
  595. }
  596. stopTextSearch() {
  597. if (this.activePage == 'TextPage')
  598. this.$refs.page.stopSearch();
  599. }
  600. searchToggle() {
  601. this.searchActive = !this.searchActive;
  602. const page = this.$refs.page;
  603. if (this.searchActive && this.activePage == 'TextPage' && page.parsed) {
  604. this.closeAllWindows();
  605. this.searchActive = true;
  606. this.$nextTick(() => {
  607. this.$refs.searchPage.init(page.parsed);
  608. });
  609. } else {
  610. this.stopTextSearch();
  611. this.searchActive = false;
  612. }
  613. }
  614. copyTextToggle() {
  615. this.copyTextActive = !this.copyTextActive;
  616. const page = this.$refs.page;
  617. if (this.copyTextActive && this.activePage == 'TextPage' && page.parsed) {
  618. this.closeAllWindows();
  619. this.copyTextActive = true;
  620. this.$nextTick(() => {
  621. this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed, this.copyFullText);
  622. });
  623. } else {
  624. this.copyTextActive = false;
  625. }
  626. }
  627. recentBooksClose() {
  628. this.recentBooksActive = false;
  629. }
  630. recentBooksToggle() {
  631. this.recentBooksActive = !this.recentBooksActive;
  632. if (this.recentBooksActive) {
  633. this.closeAllWindows();
  634. this.$refs.recentBooksPage.init();
  635. this.recentBooksActive = true;
  636. } else {
  637. this.recentBooksActive = false;
  638. }
  639. }
  640. contentsPageToggle() {
  641. this.contentsActive = !this.contentsActive;
  642. const page = this.$refs.page;
  643. if (this.contentsActive && this.activePage == 'TextPage' && page.parsed) {
  644. this.closeAllWindows();
  645. this.contentsActive = true;
  646. this.$nextTick(() => {
  647. this.$refs.contentsPage.init(this.mostRecentBook(), page.parsed);
  648. });
  649. } else {
  650. this.contentsActive = false;
  651. }
  652. }
  653. libsClose() {
  654. if (this.libsActive)
  655. this.libsToogle();
  656. }
  657. libsToogle() {
  658. this.libsActive = !this.libsActive;
  659. if (this.libsActive) {
  660. this.$refs.libsPage.init();
  661. } else {
  662. this.$refs.libsPage.done();
  663. }
  664. }
  665. offlineModeToggle() {
  666. this.offlineModeActive = !this.offlineModeActive;
  667. this.$refs.serverStorage.offlineModeActive = this.offlineModeActive;
  668. }
  669. settingsToggle() {
  670. this.settingsActive = !this.settingsActive;
  671. if (this.settingsActive) {
  672. this.closeAllWindows();
  673. this.settingsActive = true;
  674. this.$nextTick(() => {
  675. this.$refs.settingsPage.init();
  676. });
  677. } else {
  678. this.settingsActive = false;
  679. }
  680. }
  681. convOptionsToggle() {
  682. this.settingsToggle();
  683. if (this.settingsActive)
  684. this.$refs.settingsPage.selectedTab = 'convert';
  685. }
  686. helpToggle() {
  687. this.helpActive = !this.helpActive;
  688. if (this.helpActive) {
  689. this.closeAllWindows();
  690. this.helpActive = true;
  691. }
  692. }
  693. donateToggle() {
  694. this.helpToggle();
  695. if (this.helpActive) {
  696. this.$nextTick(() => {
  697. this.$refs.helpPage.activateDonateHelpPage();
  698. });
  699. }
  700. }
  701. versionHistoryToggle() {
  702. this.helpToggle();
  703. if (this.helpActive) {
  704. this.$nextTick(() => {
  705. this.$refs.helpPage.activateVersionHistoryHelpPage();
  706. });
  707. }
  708. }
  709. refreshBook() {
  710. const mrb = this.mostRecentBook();
  711. this.loadBook({url: mrb.url, uploadFileName: mrb.uploadFileName, force: true});
  712. }
  713. undoAction() {
  714. if (this.actionCur > 0) {
  715. this.actionCur--;
  716. this.bookPosChanged({bookPos: this.actionList[this.actionCur]});
  717. }
  718. }
  719. redoAction() {
  720. if (this.actionCur < this.actionList.length - 1) {
  721. this.actionCur++;
  722. this.bookPosChanged({bookPos: this.actionList[this.actionCur]});
  723. }
  724. }
  725. buttonClick(action) {
  726. const activeClass = this.buttonActiveClass(action);
  727. this.$refs[action].blur();
  728. if (activeClass['tool-button-disabled'])
  729. return;
  730. this.doAction({action});
  731. }
  732. buttonActiveClass(action) {
  733. const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
  734. const classDisabled = { 'tool-button-disabled': true, 'tool-button-disabled:hover': true };
  735. let classResult = {};
  736. switch (action) {
  737. case 'loader':
  738. case 'fullScreen':
  739. case 'setPosition':
  740. case 'search':
  741. case 'copyText':
  742. case 'convOptions':
  743. case 'refresh':
  744. case 'contents':
  745. case 'libs':
  746. case 'recentBooks':
  747. case 'offlineMode':
  748. case 'settings':
  749. if (this.progressActive) {
  750. classResult = classDisabled;
  751. } else if (this[`${action}Active`]) {
  752. classResult = classActive;
  753. }
  754. break;
  755. case 'scrolling':
  756. if (this.progressActive || this.dualPageMode) {
  757. classResult = classDisabled;
  758. } else if (this[`${action}Active`]) {
  759. classResult = classActive;
  760. }
  761. break;
  762. case 'undoAction':
  763. if (this.actionCur <= 0)
  764. classResult = classDisabled;
  765. break;
  766. case 'redoAction':
  767. if (this.actionCur == this.actionList.length - 1)
  768. classResult = classDisabled;
  769. break;
  770. }
  771. if (this.activePage == 'LoaderPage' || !this.mostRecentBookReactive) {
  772. switch (action) {
  773. case 'undoAction':
  774. case 'redoAction':
  775. case 'setPosition':
  776. case 'scrolling':
  777. case 'search':
  778. case 'copyText':
  779. case 'contents':
  780. classResult = classDisabled;
  781. break;
  782. case 'refresh':
  783. case 'recentBooks':
  784. if (!this.mostRecentBookReactive)
  785. classResult = classDisabled;
  786. break;
  787. }
  788. }
  789. return classResult;
  790. }
  791. async activateClickMapPage() {
  792. if (this.clickControl && this.showClickMapPage && !this.clickMapActive) {
  793. this.clickMapActive = true;
  794. await this.$refs.clickMapPage.slowDisappear();
  795. this.clickMapActive = false;
  796. }
  797. }
  798. get activePage() {
  799. let result = undefined;
  800. if (this.progressActive)
  801. result = 'ProgressPage';
  802. else if (this.loaderActive)
  803. result = 'LoaderPage';
  804. else if (this.mostRecentBookReactive)
  805. result = 'TextPage';
  806. if (!result && !this.loading) {
  807. this.loaderActive = true;
  808. result = 'LoaderPage';
  809. }
  810. if (result != 'TextPage') {
  811. this.$root.setAppTitle();
  812. }
  813. // на LoaderPage всегда показываем toolBar
  814. if (result == 'LoaderPage' && !this.toolBarActive) {
  815. this.toolBarToggle();
  816. }
  817. if (this.lastActivePage != result && result == 'TextPage') {
  818. //акивируем страницу с текстом
  819. this.$nextTick(async() => {
  820. const last = this.mostRecentBookReactive;
  821. const isParsed = await bookManager.hasBookParsed(last);
  822. if (!isParsed) {
  823. this.$root.setAppTitle();
  824. return;
  825. }
  826. this.updateRoute();
  827. const textPage = this.$refs.page;
  828. if (textPage.showBook) {
  829. this.textPage = textPage;
  830. textPage.lastBook = last;
  831. textPage.bookPos = (last.bookPos !== undefined ? last.bookPos : 0);
  832. textPage.showBook();
  833. }
  834. });
  835. }
  836. this.lastActivePage = result;
  837. return result;
  838. }
  839. async loadBook(opts) {
  840. if (!opts || !opts.url) {
  841. this.mostRecentBook();
  842. return;
  843. }
  844. this.closeAllWindows();
  845. let url = encodeURI(decodeURI(opts.url));
  846. //TODO: убрать конвертирование 'file://' после 06.2021
  847. if (url.length == 71 && url.indexOf('file://') == 0)
  848. url = url.replace(/^file/, 'disk');
  849. if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0) &&
  850. (url.indexOf('disk://') != 0))
  851. url = 'http://' + url;
  852. // уже просматривается сейчас
  853. const lastBook = (this.textPage ? this.textPage.lastBook : null);
  854. if (!opts.force && lastBook && lastBook.url == url &&
  855. (!opts.path || opts.path == lastBook.path) &&
  856. await bookManager.hasBookParsed(lastBook)) {
  857. this.loaderActive = false;
  858. return;
  859. }
  860. this.progressActive = true;
  861. await this.$nextTick();
  862. const progress = this.$refs.page;
  863. this.actionList = [];
  864. this.actionCur = -1;
  865. try {
  866. progress.show();
  867. progress.setState({state: 'parse'});
  868. // есть ли среди недавних
  869. const key = bookManager.keyFromUrl(url);
  870. let wasOpened = await bookManager.getRecentBook({key});
  871. wasOpened = (wasOpened ? wasOpened : {});
  872. const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
  873. const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
  874. const uploadFileName = (opts.uploadFileName ? opts.uploadFileName : '');
  875. let book = null;
  876. if (!opts.force) {
  877. // пытаемся загрузить и распарсить книгу в менеджере из локального кэша
  878. const bookParsed = await bookManager.getBook({url, path: opts.path}, (prog) => {
  879. progress.setState({progress: prog});
  880. });
  881. // если есть в локальном кэше
  882. if (bookParsed) {
  883. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, bookParsed));
  884. this.mostRecentBook();
  885. this.addAction(bookPos);
  886. this.loaderActive = false;
  887. progress.hide(); this.progressActive = false;
  888. this.blinkCachedLoadMessage();
  889. this.checkBookPosPercent();
  890. await this.activateClickMapPage();
  891. return;
  892. }
  893. // иначе идем на сервер
  894. // пытаемся загрузить готовый файл с сервера
  895. if (wasOpened.path) {
  896. progress.setState({totalSteps: 5});
  897. try {
  898. const resp = await readerApi.loadCachedBook(wasOpened.path, (state) => {
  899. progress.setState(state);
  900. });
  901. book = Object.assign({}, wasOpened, {data: resp.data});
  902. } catch (e) {
  903. //молчим
  904. }
  905. }
  906. }
  907. progress.setState({totalSteps: 5});
  908. // не удалось, скачиваем книгу полностью с конвертацией
  909. let loadCached = true;
  910. if (!book) {
  911. book = await readerApi.loadBook({
  912. url,
  913. uploadFileName,
  914. enableSitesFilter: this.enableSitesFilter,
  915. skipHtmlCheck: (this.splitToPara ? true : false),
  916. isText: (this.splitToPara ? true : false),
  917. djvuQuality: this.djvuQuality,
  918. pdfAsText: this.pdfAsText,
  919. pdfQuality: this.pdfQuality,
  920. },
  921. (state) => {
  922. progress.setState(state);
  923. }
  924. );
  925. loadCached = false;
  926. }
  927. // добавляем в bookManager
  928. progress.setState({state: 'parse', step: 5});
  929. const addedBook = await bookManager.addBook(book, (prog) => {
  930. progress.setState({progress: prog});
  931. });
  932. // добавляем в историю
  933. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen, uploadFileName}, addedBook));
  934. this.mostRecentBook();
  935. this.addAction(bookPos);
  936. this.updateRoute(true);
  937. this.loaderActive = false;
  938. progress.hide(); this.progressActive = false;
  939. if (loadCached) {
  940. this.blinkCachedLoadMessage();
  941. } else
  942. this.stopBlink = true;
  943. this.checkBookPosPercent();
  944. await this.activateClickMapPage();
  945. } catch (e) {
  946. progress.hide(); this.progressActive = false;
  947. this.loaderActive = true;
  948. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  949. } finally {
  950. this.checkNewVersionAvailable();
  951. }
  952. }
  953. async loadFile(opts) {
  954. this.progressActive = true;
  955. await this.$nextTick();
  956. const progress = this.$refs.page;
  957. try {
  958. progress.show();
  959. progress.setState({state: 'upload'});
  960. const url = await readerApi.uploadFile(opts.file, this.config.maxUploadFileSize, (state) => {
  961. progress.setState(state);
  962. });
  963. progress.hide(); this.progressActive = false;
  964. await this.loadBook({url, uploadFileName: opts.file.name, force: true});
  965. } catch (e) {
  966. progress.hide(); this.progressActive = false;
  967. this.loaderActive = true;
  968. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  969. }
  970. }
  971. blinkCachedLoadMessage() {
  972. if (!this.blinkCachedLoad)
  973. return;
  974. this.blinkCount = 30;
  975. if (!this.inBlink) {
  976. this.inBlink = true;
  977. this.stopBlink = false;
  978. this.$nextTick(async() => {
  979. let page = this.$refs.page;
  980. while (this.blinkCount) {
  981. this.showRefreshIcon = !this.showRefreshIcon;
  982. if (page && page.blinkCachedLoadMessage)
  983. page.blinkCachedLoadMessage(this.showRefreshIcon);
  984. await utils.sleep(500);
  985. if (this.stopBlink)
  986. break;
  987. this.blinkCount--;
  988. page = this.$refs.page;
  989. }
  990. this.showRefreshIcon = true;
  991. this.inBlink = false;
  992. if (page && page.blinkCachedLoadMessage)
  993. page.blinkCachedLoadMessage('finish');
  994. });
  995. }
  996. }
  997. doAction(opts) {
  998. let result = true;
  999. let {action = '', event = false} = opts;
  1000. switch (action) {
  1001. case 'loader':
  1002. this.loaderToggle();
  1003. break;
  1004. case 'help':
  1005. this.helpToggle();
  1006. break;
  1007. case 'undoAction':
  1008. this.undoAction();
  1009. break;
  1010. case 'redoAction':
  1011. this.redoAction();
  1012. break;
  1013. case 'fullScreen':
  1014. this.fullScreenToggle();
  1015. break;
  1016. case 'scrolling':
  1017. this.scrollingToggle();
  1018. break;
  1019. case 'stopScrolling':
  1020. this.stopScrolling();
  1021. break;
  1022. case 'setPosition':
  1023. this.setPositionToggle();
  1024. break;
  1025. case 'search':
  1026. this.searchToggle();
  1027. break;
  1028. case 'copyText':
  1029. this.copyTextToggle();
  1030. break;
  1031. case 'convOptions':
  1032. this.convOptionsToggle();
  1033. break;
  1034. case 'refresh':
  1035. this.refreshBook();
  1036. break;
  1037. case 'contents':
  1038. this.contentsPageToggle();
  1039. break;
  1040. case 'libs':
  1041. this.libsToogle();
  1042. break;
  1043. case 'recentBooks':
  1044. this.recentBooksToggle();
  1045. break;
  1046. case 'offlineMode':
  1047. this.offlineModeToggle();
  1048. break;
  1049. case 'settings':
  1050. this.settingsToggle();
  1051. break;
  1052. case 'switchToolbar':
  1053. this.toolBarToggle();
  1054. break;
  1055. case 'donate':
  1056. this.donateToggle();
  1057. break;
  1058. default:
  1059. result = false;
  1060. break;
  1061. }
  1062. if (!result && this.activePage == 'TextPage' && this.$refs.page) {
  1063. result = true;
  1064. const textPage = this.$refs.page;
  1065. switch (action) {
  1066. case 'bookBegin':
  1067. textPage.doHome();
  1068. break;
  1069. case 'bookEnd':
  1070. textPage.doEnd();
  1071. break;
  1072. case 'pageBack':
  1073. textPage.doPageUp();
  1074. break;
  1075. case 'pageForward':
  1076. textPage.doPageDown();
  1077. break;
  1078. case 'lineBack':
  1079. textPage.doUp();
  1080. break;
  1081. case 'lineForward':
  1082. textPage.doDown();
  1083. break;
  1084. case 'incFontSize':
  1085. textPage.doFontSizeInc();
  1086. break;
  1087. case 'decFontSize':
  1088. textPage.doFontSizeDec();
  1089. break;
  1090. case 'scrollingSpeedUp':
  1091. textPage.doScrollingSpeedUp();
  1092. break;
  1093. case 'scrollingSpeedDown':
  1094. textPage.doScrollingSpeedDown();
  1095. break;
  1096. default:
  1097. result = false;
  1098. break;
  1099. }
  1100. }
  1101. if (result && event) {
  1102. event.preventDefault();
  1103. event.stopPropagation();
  1104. }
  1105. return result;
  1106. }
  1107. keyHook(event) {
  1108. let result = false;
  1109. if (this.$root.getRootRoute() == '/reader') {
  1110. if (this.$root.stdDialog.active)
  1111. return result;
  1112. if (!result)
  1113. result = this.$refs.dialogs.keyHook(event);
  1114. if (!result && this.helpActive)
  1115. result = this.$refs.helpPage.keyHook(event);
  1116. if (!result && this.settingsActive)
  1117. result = this.$refs.settingsPage.keyHook(event);
  1118. if (!result && this.recentBooksActive)
  1119. result = this.$refs.recentBooksPage.keyHook(event);
  1120. if (!result && this.setPositionActive)
  1121. result = this.$refs.setPositionPage.keyHook(event);
  1122. if (!result && this.searchActive)
  1123. result = this.$refs.searchPage.keyHook(event);
  1124. if (!result && this.copyTextActive)
  1125. result = this.$refs.copyTextPage.keyHook(event);
  1126. if (!result && this.contentsActive)
  1127. result = this.$refs.contentsPage.keyHook(event);
  1128. if (!result && this.$refs.page && this.$refs.page.keyHook)
  1129. result = this.$refs.page.keyHook(event);
  1130. if (!result && event.type == 'keydown') {
  1131. const action = this.$root.readerActionByKeyEvent(event);
  1132. if (action == 'loader') {
  1133. result = this.doAction({action, event});
  1134. }
  1135. if (!result && this.activePage == 'TextPage') {
  1136. result = this.doAction({action, event});
  1137. }
  1138. }
  1139. }
  1140. return result;
  1141. }
  1142. }
  1143. export default vueComponent(Reader);
  1144. //-----------------------------------------------------------------------------
  1145. </script>
  1146. <style scoped>
  1147. .header {
  1148. padding-left: 5px;
  1149. padding-right: 5px;
  1150. background-color: #1B695F;
  1151. color: #000;
  1152. overflow: hidden;
  1153. height: 50px;
  1154. }
  1155. .main {
  1156. background-color: #EBE2C9;
  1157. color: #000;
  1158. }
  1159. .tool-button {
  1160. margin: 0px 2px 0 2px;
  1161. padding: 0;
  1162. color: #3E843E;
  1163. background-color: #E6EDF4;
  1164. margin-top: 5px;
  1165. height: 38px;
  1166. width: 38px;
  1167. border: 0;
  1168. border-radius: 6px;
  1169. box-shadow: 3px 3px 5px black;
  1170. outline: 0;
  1171. }
  1172. .tool-button:hover {
  1173. background-color: white;
  1174. cursor: pointer;
  1175. }
  1176. .tool-button-active {
  1177. box-shadow: 0 0 0;
  1178. color: white;
  1179. background-color: #8AB45F;
  1180. position: relative;
  1181. top: 1px;
  1182. left: 1px;
  1183. }
  1184. .tool-button-active:hover {
  1185. color: white;
  1186. background-color: #81C581;
  1187. cursor: pointer;
  1188. }
  1189. .tool-button-disabled {
  1190. color: lightgray;
  1191. background-color: gray;
  1192. cursor: default;
  1193. }
  1194. .tool-button-disabled:hover {
  1195. color: lightgray;
  1196. background-color: gray;
  1197. cursor: default;
  1198. }
  1199. .space {
  1200. width: 10px;
  1201. display: inline-block;
  1202. }
  1203. .clear {
  1204. color: rgba(0,0,0,0);
  1205. }
  1206. </style>