refactor(url): convert getter methods to variables
This commit is contained in:
parent
a5ab217ac6
commit
3914b827fb
@ -4,17 +4,9 @@ const env = {
|
||||
}
|
||||
|
||||
const url = {
|
||||
get reject() {
|
||||
return `/api/annotation/reject`;
|
||||
},
|
||||
|
||||
get rejectRedir() {
|
||||
return `/envelope/${env.envKey}`;
|
||||
},
|
||||
|
||||
get share() {
|
||||
return `/api/readonly`;
|
||||
}
|
||||
reject: `/api/annotation/reject`,
|
||||
rejectRedir: `/envelope/${env.envKey}`,
|
||||
share: `/api/readonly`
|
||||
};
|
||||
|
||||
function submitForm(form) {
|
||||
|
||||
@ -1 +1 @@
|
||||
function submitForm(n){fetch(n.action,{method:n.method,body:new FormData(n),headers:{"X-Requested-With":"XMLHttpRequest"}})}function createRequest(n,t,i,r="application/json"){return fetch(t,{credentials:"include",method:n,headers:{"Content-Type":r,"X-XSRF-TOKEN":env.xsrfToken},body:JSON.stringify(i)})}function createPost(n,t,i="application/json"){return createRequest("POST",n,t,i)}function rejectEnvelope(n){return createPost(url.reject,n,Content.JSON)}function redirect(n){return window.location.href=n}function redirRejected(){return redirect(url.rejectRedir)}function shareEnvelope(n,t){return createPost(url.share,{receiverMail:n,dateValid:t},Content.JSON)}const env={xsrfToken:document.getElementsByName("__RequestVerificationToken")[0].value,envKey:document.querySelector('meta[name="env-key"]').getAttribute("content")},url={get reject(){return`/api/annotation/reject`},get rejectRedir(){return`/envelope/${env.envKey}`},get share(){return`/api/readonly`}};
|
||||
function submitForm(n){fetch(n.action,{method:n.method,body:new FormData(n),headers:{"X-Requested-With":"XMLHttpRequest"}})}function createRequest(n,t,i,r="application/json"){return fetch(t,{credentials:"include",method:n,headers:{"Content-Type":r,"X-XSRF-TOKEN":env.xsrfToken},body:JSON.stringify(i)})}function createPost(n,t,i="application/json"){return createRequest("POST",n,t,i)}function rejectEnvelope(n){return createPost(url.reject,n,Content.JSON)}function redirect(n){return window.location.href=n}function redirRejected(){return redirect(url.rejectRedir)}function shareEnvelope(n,t){return createPost(url.share,{receiverMail:n,dateValid:t},Content.JSON)}const env={xsrfToken:document.getElementsByName("__RequestVerificationToken")[0].value,envKey:document.querySelector('meta[name="env-key"]').getAttribute("content")},url={reject:`/api/annotation/reject`,rejectRedir:`/envelope/${env.envKey}`,share:`/api/readonly`};
|
||||
Loading…
x
Reference in New Issue
Block a user