2017-01-06 20:49:37 +01:00
|
|
|
import { Enum } from 'enumify';
|
|
|
|
|
2017-01-29 16:05:26 +01:00
|
|
|
import NoOp from './transformations/NoOp.jsx';
|
|
|
|
import RoundCoordinates from './transformations/RoundCoordinates.jsx';
|
|
|
|
import CombineSameY from './transformations/CombineSameY.jsx';
|
2017-02-03 12:36:56 +01:00
|
|
|
import DetectFootnotes from './transformations/DetectFootnotes.jsx'
|
2017-01-27 21:40:49 +01:00
|
|
|
import RemoveRepetitiveElements from './transformations/RemoveRepetitiveElements.jsx'
|
2017-02-05 09:58:25 +01:00
|
|
|
import HeadlineDetector from './transformations/HeadlineDetector.jsx'
|
2017-02-05 21:22:42 +01:00
|
|
|
import HeadlineToUppercase from './transformations/HeadlineToUppercase.jsx'
|
2017-01-29 16:05:26 +01:00
|
|
|
import ToTextPages from './transformations/ToTextPages.jsx';
|
|
|
|
import ToSingleTextPage from './transformations/ToSingleTextPage.jsx'
|
2017-01-07 11:38:06 +01:00
|
|
|
|
2017-01-06 20:49:37 +01:00
|
|
|
// Holds the state of the Application
|
|
|
|
export default class AppState {
|
|
|
|
|
|
|
|
constructor(options) {
|
|
|
|
this.renderFunction = options.renderFunction;
|
|
|
|
this.mainView = View.UPLOAD;
|
2017-01-09 20:08:32 +01:00
|
|
|
this.fileBuffer;
|
2017-01-06 20:49:37 +01:00
|
|
|
this.pdfPages = [];
|
2017-01-27 21:40:49 +01:00
|
|
|
this.transformations = [
|
2017-01-29 16:05:26 +01:00
|
|
|
new NoOp,
|
|
|
|
new RoundCoordinates(),
|
|
|
|
new CombineSameY(),
|
2017-02-03 12:36:56 +01:00
|
|
|
new DetectFootnotes(),
|
2017-01-27 21:40:49 +01:00
|
|
|
new RemoveRepetitiveElements(),
|
2017-02-05 09:58:25 +01:00
|
|
|
new HeadlineDetector(),
|
2017-02-05 21:22:42 +01:00
|
|
|
new HeadlineToUppercase(),
|
2017-01-29 16:05:26 +01:00
|
|
|
new ToTextPages(),
|
|
|
|
new ToSingleTextPage()];
|
2017-01-06 20:49:37 +01:00
|
|
|
|
|
|
|
//bind functions
|
|
|
|
this.render = this.render.bind(this);
|
2017-01-09 20:08:32 +01:00
|
|
|
this.storeFileBuffer = this.storeFileBuffer.bind(this);
|
|
|
|
this.storePdfPages = this.storePdfPages.bind(this);
|
2017-01-06 20:49:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
this.renderFunction(this)
|
|
|
|
}
|
|
|
|
|
2017-01-09 20:08:32 +01:00
|
|
|
// the uploaded pdf as file buffer
|
|
|
|
storeFileBuffer(fileBuffer:ArrayBuffer) {
|
|
|
|
this.fileBuffer = fileBuffer;
|
2017-01-06 20:49:37 +01:00
|
|
|
this.mainView = View.LOADING;
|
|
|
|
this.render()
|
|
|
|
}
|
|
|
|
|
2017-01-09 20:08:32 +01:00
|
|
|
storePdfPages(pdfPages) {
|
|
|
|
this.pdfPages = pdfPages;
|
|
|
|
this.fileBuffer = null;
|
2017-01-22 19:04:23 +01:00
|
|
|
this.mainView = View.DEBUG;
|
2017-01-09 20:08:32 +01:00
|
|
|
this.render();
|
2017-01-06 20:49:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export class View extends Enum {
|
|
|
|
}
|
2017-01-22 19:04:23 +01:00
|
|
|
View.initEnum(['UPLOAD', 'LOADING', 'DEBUG'])
|