Commit 7d033267 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

fixed regex in the ShowText page which caused firefox to break (no...

fixed regex in the ShowText page which caused firefox to break (no lookahead/lookbehind allowed in firefox regex)
parent 2578c2e4
{
"name": "mc_frontend",
"version": "0.9.5",
"version": "0.9.6",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
......
......@@ -25,7 +25,6 @@ export class AppComponent {
this.splashScreen.hide();
});
this.initTranslate();
this.helperService.initConfig().then();
}
initTranslate() {
......
......@@ -57,16 +57,16 @@ export class CorpusService {
public helperService: HelperService,
) {
this.translate.get('ERROR_CORPORA_UNAVAILABLE').subscribe(value => this.corporaUnavailableString = value);
this.helperService.initConfig().then(() => {
HelperService.waitForConfig().then(() => {
this.checkForUpdates();
this.checkAnnisResponse().then(() => {
if (HelperService.mostRecentSetup) {
this.restoreLastCorpus().then();
}
});
});
this.initPhenomenonMap();
this.getTranslations();
this.checkAnnisResponse().then(() => {
if (HelperService.mostRecentSetup) {
this.restoreLastCorpus().then();
}
});
}
adjustQueryValue(query: QueryMC) {
......
......@@ -98,6 +98,7 @@ export class HelperService {
constructor(public http: HttpClient,
private storage: Storage,
) {
this.initConfig().then();
}
// The translate loader needs to know where to load i18n files in Ionic's static asset pipeline.
......@@ -181,6 +182,17 @@ export class HelperService {
return array;
}
static waitForConfig() {
return new Promise(async (resolve) => {
while (!HelperService.config) {
await new Promise((resolveWait) => {
setTimeout(resolveWait, 50);
});
}
resolve();
});
}
initConfig() {
return new Promise((resolve) => {
this.http.get('assets/config.json').subscribe((config: object) => {
......@@ -195,7 +207,7 @@ export class HelperService {
}
loadMostRecentSetup() {
return new Promise((resolve) => {
return new Promise(async (resolve) => {
this.storage.get(HelperService.config['localStorageKeyMostRecentSetup']).then((mrs: string) => {
HelperService.mostRecentSetup = JSON.parse(mrs);
resolve();
......@@ -211,5 +223,4 @@ export class HelperService {
});
});
}
}
......@@ -38,9 +38,11 @@ export class PreviewPage implements OnDestroy {
if (!HelperService.isVocabularyCheck) {
this.exerciseService.excludeOOV = false;
}
this.corpusService.checkAnnisResponse().then(() => {
this.processAnnisResponse(this.corpusService.annisResponse);
this.initH5P();
HelperService.waitForConfig().then(() => {
this.corpusService.checkAnnisResponse().then(() => {
this.processAnnisResponse(this.corpusService.annisResponse);
this.initH5P();
});
});
}
......
......@@ -2,9 +2,7 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {Routes, RouterModule} from '@angular/router';
import {IonicModule} from '@ionic/angular';
import {RankingPage} from './ranking.page';
import {TranslateModule} from '@ngx-translate/core';
......
......@@ -7,8 +7,7 @@ import {ExerciseService} from 'src/app/exercise.service';
import {HelperService} from 'src/app/helper.service';
import {TranslateService} from '@ngx-translate/core';
import {FileType} from '../models/enum';
import {AnnisResponse} from 'src/app/models/annisResponse';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {HttpClient} from '@angular/common/http';
@Component({
selector: 'app-show-text',
......@@ -20,10 +19,9 @@ export class ShowTextPage {
HelperService = HelperService;
ObjectKeys = Object.keys;
public highlightOOV = false;
public htmlContentString: string;
public text: string;
public urlBase: string;
public isDownloading: boolean = false;
public isDownloading = false;
constructor(public navCtrl: NavController,
public corpusService: CorpusService,
......@@ -32,19 +30,19 @@ export class ShowTextPage {
public translateService: TranslateService,
public vocService: VocabularyService,
public http: HttpClient) {
this.updateFileUrl();
HelperService.waitForConfig().then(() => {
this.urlBase = HelperService.config['backendBaseUrl'] + HelperService.config['backendApiFilePath'];
});
}
generateDownloadLink(fileType: string) {
const formData = new FormData();
let content = document.querySelector('.text').outerHTML;
let content: string = document.querySelector('.text').outerHTML;
// add underline elements so we do not need to specify CSS options in the backend's PDF generator
content = content.replace(/(?<=oov">)(.+?)(?=<\/span>)/g, '<u>$1</u>');
content = content.replace(/(oov">)(.+?)(<\/span>)/g, '$1<u>$2</u>$3');
const authorTitle: string = this.corpusService.currentCorpus.author + ', ' + this.corpusService.currentCorpus.title;
const textRange: string = [this.corpusService.currentTextRange.start.join('.'),
this.corpusService.currentTextRange.end.join('.')].join('-');
content = `<p>${authorTitle} ${textRange}</p>` + content;
formData.append('html_content', content); // '<p>test</p>'
content = `<p>${authorTitle} ${this.corpusService.currentUrn.split(':').slice(-1)[0]}</p>` + content;
formData.append('html_content', content);
formData.append('file_type', fileType);
formData.append('urn', this.corpusService.currentUrn);
this.isDownloading = true;
......@@ -80,12 +78,4 @@ export class ShowTextPage {
}
return '';
}
updateFileUrl() {
const fileId: string = this.corpusService.currentUrn;
const fileTypeBase = '&type=';
this.urlBase = HelperService.config['backendBaseUrl'] + HelperService.config['backendApiFilePath'];
// + '?id=' + fileId + fileTypeBase;
// this.urlBase += '?html_content=';
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment