text
This commit is contained in:
parent
3b6571c008
commit
798aefc0ea
@ -22,7 +22,7 @@
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="{{'submission.title' | i18n}}" formControlName="title" type="text" required>
|
||||
<input matInput placeholder="{{'submission.title' | i18n}}" formControlName="title" type="text" required (focus)="onTitleFocus($event)">
|
||||
<mat-error>
|
||||
{{'submission.title.error' | i18n}}
|
||||
</mat-error>
|
||||
|
@ -44,6 +44,18 @@ export class PageSubmission implements OnInit {
|
||||
return this.form.controls[ controlName ].errors != null;
|
||||
}
|
||||
|
||||
onTitleFocus(event): void {
|
||||
fetch(this.form.get("url").value)
|
||||
.then((response) => response.text())
|
||||
.then((html) => {
|
||||
const doc = new DOMParser().parseFromString(html, "text/html");
|
||||
const title = doc.querySelectorAll('title')[ 0 ];
|
||||
return title.innerText;
|
||||
}).then((title) => {
|
||||
this.form.get("title").setValue(title);
|
||||
})
|
||||
}
|
||||
|
||||
create(): void {
|
||||
|
||||
if (this.working) {
|
||||
|
@ -10,7 +10,6 @@ small a:not(.entry):hover {
|
||||
|
||||
.text {
|
||||
white-space: break-spaces;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
span.voted {
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
a.title {
|
||||
white-space: break-spaces;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
small a {
|
||||
|
Loading…
Reference in New Issue
Block a user