This commit is contained in:
_Bastler 2021-10-06 07:38:24 +02:00
parent 3b6571c008
commit 798aefc0ea
4 changed files with 13 additions and 3 deletions

View File

@ -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>

View File

@ -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) {

View File

@ -10,7 +10,6 @@ small a:not(.entry):hover {
.text {
white-space: break-spaces;
word-break: break-word;
}
span.voted {

View File

@ -2,7 +2,6 @@
a.title {
white-space: break-spaces;
word-wrap: break-word;
}
small a {