Skip to content

Commit ad0ce21

Browse files
committed
Багфикс: невозможно прочитать JSON при инициализации
1 parent 9f99721 commit ad0ce21

1 file changed

Lines changed: 46 additions & 46 deletions

File tree

library.js

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,52 @@ function displayLaunchPage_() {
2828
}
2929
}
3030

31+
String.prototype.formatName = function () {
32+
return this.toLowerCase()
33+
.replace(/['`,?!@#$%^&*()+-./\\]/g, ' ')
34+
.replace(/\s{2,}/g, ' ')
35+
.replace(/ё/g, 'е')
36+
.trim();
37+
};
38+
39+
Date.prototype.setBound = function (value) {
40+
if (value == 'startDay') {
41+
this.setHours(0, 0, 0, 0);
42+
} else if (value == 'endDay') {
43+
this.setHours(23, 59, 59, 999);
44+
}
45+
return this;
46+
};
47+
48+
Date.prototype.getTimestampUNIX = function (bound) {
49+
return Math.trunc(this.setBound(bound).getTime() / 1000);
50+
};
51+
52+
Object.prototype.isEmpty = function () {
53+
return Object.keys(this).length == 0;
54+
}
55+
56+
Array.prototype.toObject = function (parseMethod) {
57+
return this.reduce((accumulator, element, i) => (accumulator[parseMethod(element)] = i, accumulator), {});
58+
}
59+
60+
JSON.parseFromString = function (content) {
61+
try {
62+
return JSON.parse(content);
63+
} catch (error) {
64+
Admin.printError('Не удалось преобразовать строку JSON в объект JavaScript\n', error.stack, '\n', content);
65+
return undefined;
66+
}
67+
}
68+
69+
JSON.parseFromResponse = function (response) {
70+
let content = response.getContentText();
71+
if (content.length == 0) {
72+
return { msg: 'Пустое тело ответа', status: response.getResponseCode() };
73+
}
74+
return JSON.parseFromString(content);
75+
}
76+
3177
const CustomUrlFetchApp = (function () {
3278
let countRequest = 0;
3379
return {
@@ -3431,49 +3477,3 @@ const Admin = (function () {
34313477
UserProperties.deleteAllProperties();
34323478
}
34333479
})();
3434-
3435-
String.prototype.formatName = function () {
3436-
return this.toLowerCase()
3437-
.replace(/['`,?!@#$%^&*()+-./\\]/g, ' ')
3438-
.replace(/\s{2,}/g, ' ')
3439-
.replace(/ё/g, 'е')
3440-
.trim();
3441-
};
3442-
3443-
Date.prototype.setBound = function (value) {
3444-
if (value == 'startDay') {
3445-
this.setHours(0, 0, 0, 0);
3446-
} else if (value == 'endDay') {
3447-
this.setHours(23, 59, 59, 999);
3448-
}
3449-
return this;
3450-
};
3451-
3452-
Date.prototype.getTimestampUNIX = function (bound) {
3453-
return Math.trunc(this.setBound(bound).getTime() / 1000);
3454-
};
3455-
3456-
Object.prototype.isEmpty = function () {
3457-
return Object.keys(this).length == 0;
3458-
}
3459-
3460-
Array.prototype.toObject = function (parseMethod) {
3461-
return this.reduce((accumulator, element, i) => (accumulator[parseMethod(element)] = i, accumulator), {});
3462-
}
3463-
3464-
JSON.parseFromString = function (content) {
3465-
try {
3466-
return JSON.parse(content);
3467-
} catch (error) {
3468-
Admin.printError('Не удалось преобразовать строку JSON в объект JavaScript\n', error.stack, '\n', content);
3469-
return undefined;
3470-
}
3471-
}
3472-
3473-
JSON.parseFromResponse = function (response) {
3474-
let content = response.getContentText();
3475-
if (content.length == 0) {
3476-
return { msg: 'Пустое тело ответа', status: response.getResponseCode() };
3477-
}
3478-
return JSON.parseFromString(content);
3479-
}

0 commit comments

Comments
 (0)