Clean up lang field setting in pad.tmpl

This continues work by @cjeller1592 in #435.
pull/443/head
Matt Baer 4 years ago
parent 50c4e944a4
commit 11e636359d
  1. 17
      templates/pad.tmpl

@ -186,21 +186,14 @@
var xpostTarg = H.get('crosspostTarget', '[]'); var xpostTarg = H.get('crosspostTarget', '[]');
var http = new XMLHttpRequest(); var http = new XMLHttpRequest();
var lang = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage);
lang = lang.substring(0, 2);
var post = H.getTitleStrict(content); var post = H.getTitleStrict(content);
var params = { var params = {
body: post.content, body: post.content,
title: post.title, title: post.title,
font: font, font: font
{{ if or .Post.Slug .Post.Id }} };
};
{{ else }}
lang: lang
};
{{ end }}
{{ if .Post.Slug }} {{ if .Post.Slug }}
var url = "/api/collections/{{.EditCollection.Alias}}/posts/{{.Post.Id}}"; var url = "/api/collections/{{.EditCollection.Alias}}/posts/{{.Post.Id}}";
{{ else if .Post.Id }} {{ else if .Post.Id }}
@ -210,6 +203,10 @@
} }
params.token = token; params.token = token;
{{ else }} {{ else }}
var lang = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage);
lang = lang.substring(0, 2);
params.lang = lang;
var url = "/api/posts"; var url = "/api/posts";
var postTarget = H.get('postTarget', 'anonymous'); var postTarget = H.get('postTarget', 'anonymous');
if (postTarget != 'anonymous') { if (postTarget != 'anonymous') {

Loading…
Cancel
Save