2018-03-02 11:07:03 +01:00
|
|
|
import { Component, OnInit, AfterViewInit } from '@angular/core';
|
2018-03-22 22:32:33 +01:00
|
|
|
import UIkit from 'uikit';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
2018-02-28 12:41:06 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-configuration',
|
|
|
|
templateUrl: './configuration.component.html',
|
|
|
|
styleUrls: ['./configuration.component.css']
|
|
|
|
})
|
2018-03-02 11:07:03 +01:00
|
|
|
export class ConfigurationComponent implements OnInit, AfterViewInit {
|
2018-02-28 12:41:06 +01:00
|
|
|
|
|
|
|
constructor() { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
// initialize settings
|
|
|
|
if (!localStorage.getItem('docname') || localStorage.getItem('docname') === 'undefined') {
|
|
|
|
localStorage.setItem('docname', '');
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem('docsnumber') || localStorage.getItem('docsnumber') === 'undefined') {
|
|
|
|
localStorage.setItem('docsnumber', '0');
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem('profileid') || localStorage.getItem('profileid') === 'undefined') {
|
|
|
|
localStorage.setItem('profileid', '');
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem('poswords') || localStorage.getItem('poswords') === 'undefined') {
|
|
|
|
localStorage.setItem('poswords', '{}');
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem('negwords') || localStorage.getItem('negwords') === 'undefined') {
|
|
|
|
localStorage.setItem('negwords', '{}');
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem('contextprev') || localStorage.getItem('contextprev') === 'undefined') {
|
|
|
|
localStorage.setItem('contextprev', '10');
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem('contextnext') || localStorage.getItem('contextnext') === 'undefined') {
|
|
|
|
localStorage.setItem('contextnext', '5');
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem('wordssplitnum') || localStorage.getItem('wordssplitnum') === 'undefined') {
|
2018-03-22 22:32:33 +01:00
|
|
|
localStorage.setItem('wordssplitnum', '1');
|
2018-02-28 12:41:06 +01:00
|
|
|
}
|
|
|
|
if (!localStorage.getItem('punctuation') || localStorage.getItem('punctuation') === 'undefined') {
|
|
|
|
localStorage.setItem('punctuation', '0');
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem('stopwords') || localStorage.getItem('stopwords') === 'undefined') {
|
|
|
|
localStorage.setItem('stopwords', '0');
|
|
|
|
}
|
2018-03-22 22:32:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
promptToLeave(nextUrl: string): boolean {
|
|
|
|
console.log(nextUrl);
|
|
|
|
if (nextUrl.indexOf('upload-content') >= 0 || nextUrl.indexOf('configure-profile') >= 0 || nextUrl.indexOf('save-profile') >= 0) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return UIkit.modal.confirm('<span class="uk-text-bold">' +
|
|
|
|
'Your changes have not been saved to your Profile!<br>Are you sure you want to leave?</span>', {escClose: true}).then(() => {
|
|
|
|
return true;
|
|
|
|
}, () => false);
|
2018-02-28 12:41:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:07:03 +01:00
|
|
|
ngAfterViewInit() {
|
|
|
|
// $('#child1').stickySidebar();
|
2018-03-22 22:32:33 +01:00
|
|
|
if (document.getElementById('enableStickyBarScript')) {
|
|
|
|
document.getElementById('enableStickyBarScript').remove();
|
|
|
|
}
|
|
|
|
const enableStickyBarScript = document.createElement('script');
|
|
|
|
enableStickyBarScript.setAttribute('id', 'enableStickyBarScript');
|
|
|
|
enableStickyBarScript.innerHTML = '$(\"#child1\").stickySidebar();\n';
|
2018-03-02 11:07:03 +01:00
|
|
|
document.body.appendChild(enableStickyBarScript);
|
|
|
|
}
|
|
|
|
|
2018-02-28 12:41:06 +01:00
|
|
|
}
|