start grid
This commit is contained in:
@ -45,8 +45,7 @@ function getStorageKey(lgid) {
|
||||
return `res_${lgid}`;
|
||||
}
|
||||
|
||||
async function doRefreshLgres(template) {
|
||||
template ??= '';
|
||||
async function doRefreshLgres(template = '') {
|
||||
const lgid = getCurrentLgId();
|
||||
const r = await get(`language/${lgid}${template}`);
|
||||
const dict = await r.json();
|
||||
@ -81,7 +80,6 @@ function getLanguage(lgres, key, defaultValue) {
|
||||
}
|
||||
|
||||
function applyLanguage(dom, result) {
|
||||
dom ??= document.body;
|
||||
for (let text of dom.querySelectorAll('[data-lgid]')) {
|
||||
const key = text.dataset.lgid;
|
||||
if (text.tagName === 'INPUT') {
|
||||
@ -100,8 +98,7 @@ function applyLanguage(dom, result) {
|
||||
}
|
||||
}
|
||||
|
||||
async function init(dom, options) {
|
||||
options ??= {};
|
||||
async function init(dom = document.body, options = {}) {
|
||||
const lgid = getCurrentLgId();
|
||||
let lgres = localStorage.getItem(getStorageKey(lgid));
|
||||
let result;
|
||||
|
@ -8,8 +8,7 @@ function combineUrl(url) {
|
||||
return (consts.path || '') + url;
|
||||
}
|
||||
|
||||
function get(url, options) {
|
||||
options ??= {};
|
||||
function get(url, options = {}) {
|
||||
return fetch(combineUrl(url), {
|
||||
method: options.method || 'GET',
|
||||
headers: {
|
||||
@ -21,8 +20,7 @@ function get(url, options) {
|
||||
});
|
||||
}
|
||||
|
||||
function post(url, data, options) {
|
||||
options ??= {};
|
||||
function post(url, data, options = {}) {
|
||||
// let contentType;
|
||||
if (data instanceof FormData) {
|
||||
// contentType = 'multipart/form-data';
|
||||
@ -47,7 +45,7 @@ function post(url, data, options) {
|
||||
});
|
||||
}
|
||||
|
||||
function upload(url, data, options) {
|
||||
function upload(url, data, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new XMLHttpRequest();
|
||||
request.onreadystatechange = function () {
|
||||
@ -59,7 +57,6 @@ function upload(url, data, options) {
|
||||
}
|
||||
}
|
||||
};
|
||||
options ??= {};
|
||||
if (typeof options.progress === 'function') {
|
||||
request.upload.addEventListener('progress', function (ev) {
|
||||
if (ev.lengthComputable) {
|
||||
|
Reference in New Issue
Block a user