mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
Move js call of tasks/newCounter to js api file
This commit is contained in:
parent
30b08bd87c
commit
b05f40f77c
2 changed files with 26 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
This file is a part of myTinyTodo.
|
||||
(C) Copyright 2009-2010,2020-2023 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
(C) Copyright 2009-2010,2020-2025 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL version 2 or any later. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
|
|
@ -2744,17 +2744,7 @@ function newTaskCounter()
|
|||
});
|
||||
});
|
||||
|
||||
fetch(_mtt.apiUrl + 'tasks/newCounter', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin', // old browsers
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'MTT-Token': _mtt.options.token,
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
_mtt.db.request("newTaskCounter", params, json => {
|
||||
if (json && json.ok) {
|
||||
let counters = {};
|
||||
let curCounter = 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
This file is a part of myTinyTodo.
|
||||
(C) Copyright 2010,2020-2023 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
(C) Copyright 2010,2020-2025 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL version 2 or any later. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
|
|
@ -227,6 +227,29 @@ MytinytodoAjaxApi.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
newTaskCounter(params, callback) {
|
||||
fetch(mytinytodo.apiUrl + 'tasks/newCounter', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin', // old browsers
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'MTT-Token': mytinytodo.options.token,
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) throw response;
|
||||
return response.json();
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e instanceof Error) console.log("newTaskCounter fetch error: ", e);
|
||||
else console.log("newTaskCounter fetch error, HTTP status code: " + e.status);
|
||||
})
|
||||
.then(json => {
|
||||
callback(json)
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
// Lists
|
||||
loadLists(params, callback) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue